Bug 991981 - Test for TypedObjectGet not being neutering-aware. r=nmatsakis
authorJeff Walden <jwalden@mit.edu>
Wed, 14 May 2014 17:05:22 -0700
changeset 210072 1ae70cece64666ec6a76d0b2dd9b2b02287b54c2
parent 210071 be9320beb260c8ad584f88b99c57cb35a6241380
child 210073 ef6465b02d0d15a0f29b4f0d8823994feb6658da
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersnmatsakis
bugs991981
milestone35.0a1
Bug 991981 - Test for TypedObjectGet not being neutering-aware. r=nmatsakis
js/src/tests/ecma_6/TypedObject/map-neutered-midway.js
new file mode 100644
--- /dev/null
+++ b/js/src/tests/ecma_6/TypedObject/map-neutered-midway.js
@@ -0,0 +1,43 @@
+// |reftest| skip-if(!this.hasOwnProperty("TypedObject")||!xulRuntime.shell) -- needs TypedObject, neuter()
+/*
+ * Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/licenses/publicdomain/
+ */
+
+var BUGNUMBER = 991981;
+var summary =
+  "Behavior of mapping from an array neutered midway through mapping";
+
+function mapOneDimArrayOfUint8(dataHandling)
+{
+  var FourByteArray = TypedObject.uint8.array(4);
+  var FourByteArrayArray = FourByteArray.array(4);
+
+  var buf = new ArrayBuffer(16);
+  var arr = new FourByteArrayArray(buf);
+
+  var count = 0;
+  assertThrowsInstanceOf(function()
+  {
+    arr.map(function(v)
+    {
+      if (count++ > 0)
+        neuter(buf, dataHandling);
+      return new FourByteArray();
+    });
+  }, TypeError, "mapping of a neutered object worked?");
+}
+
+function runTests()
+{
+  print(BUGNUMBER + ": " + summary);
+
+  mapOneDimArrayOfUint8("change-data");
+  mapOneDimArrayOfUint8("same-data");
+
+  if (typeof reportCompare === "function")
+    reportCompare(true, true);
+  print("Tests complete");
+}
+
+runTests();