Bug 983344. Add a test. r=sfink
authorJeff Walden <jwalden@mit.edu>
Thu, 13 Mar 2014 21:23:50 -0700
changeset 216508 43bdcb0d3c73eaf7d237782a0cedfdbdf13f2433
parent 216507 4a11304b51d51643e07fe121f02b146f10437b37
child 216509 01539198e45436265e476c76ab5ab75ffd5a8685
push idunknown
push userunknown
push dateunknown
reviewerssfink
bugs983344
milestone36.0a1
Bug 983344. Add a test. r=sfink
js/src/tests/js1_8_5/extensions/typedarray-set-neutering.js
new file mode 100644
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/typedarray-set-neutering.js
@@ -0,0 +1,77 @@
+// |reftest| skip-if(!xulRuntime.shell)
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 983344;
+var summary =
+  "Uint8Array.prototype.set issues when this array changes during setting";
+
+print(BUGNUMBER + ": " + summary);
+
+/**************
+ * BEGIN TEST *
+ **************/
+
+var ab1 = new ArrayBuffer(200);
+var a1 = new Uint8Array(ab1);
+var a1_2 = new Uint8Array(10);
+
+var src1 = [ 10, 20, 30, 40,
+             10, 20, 30, 40,
+             10, 20, 30, 40,
+             10, 20, 30, 40,
+             10, 20, 30, 40,
+             10, 20, 30, 40,
+             10, 20, 30, 40,
+             10, 20, 30, 40,
+             10, 20, 30, 40,
+             10, 20, 30, 40,
+             ];
+Object.defineProperty(src1, 4, {
+  get: function () {
+    neuter(ab1, "change-data");
+    gc();
+    return 200;
+  }
+});
+
+a1.set(src1);
+
+// Not really needed
+Array.reverse(a1_2);
+
+var ab2 = new ArrayBuffer(200);
+var a2 = new Uint8Array(ab2);
+var a2_2 = new Uint8Array(10);
+
+var src2 = [ 10, 20, 30, 40,
+             10, 20, 30, 40,
+             10, 20, 30, 40,
+             10, 20, 30, 40,
+             10, 20, 30, 40,
+             10, 20, 30, 40,
+             10, 20, 30, 40,
+             10, 20, 30, 40,
+             10, 20, 30, 40,
+             10, 20, 30, 40,
+             ];
+Object.defineProperty(src2, 4, {
+  get: function () {
+    neuter(ab2, "same-data");
+    gc();
+    return 200;
+  }
+});
+
+a2.set(src2);
+
+// Not really needed
+Array.reverse(a2_2);
+
+/******************************************************************************/
+
+if (typeof reportCompare === "function")
+  reportCompare(true, true);
+
+print("Tests complete");