summaryrefslogtreecommitdiffstats
path: root/js/src/tests/js1_8_5/extensions
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /js/src/tests/js1_8_5/extensions
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'js/src/tests/js1_8_5/extensions')
-rw-r--r--js/src/tests/js1_8_5/extensions/array-length-protochange.js35
-rw-r--r--js/src/tests/js1_8_5/extensions/arraybuffer-prototype.js28
-rw-r--r--js/src/tests/js1_8_5/extensions/browser.js6
-rw-r--r--js/src/tests/js1_8_5/extensions/censor-strict-caller.js34
-rw-r--r--js/src/tests/js1_8_5/extensions/clone-complex-object.js313
-rw-r--r--js/src/tests/js1_8_5/extensions/clone-errors.js41
-rw-r--r--js/src/tests/js1_8_5/extensions/clone-forge.js39
-rw-r--r--js/src/tests/js1_8_5/extensions/clone-leaf-object.js64
-rw-r--r--js/src/tests/js1_8_5/extensions/clone-many-transferables.js25
-rw-r--r--js/src/tests/js1_8_5/extensions/clone-object-deep.js25
-rw-r--r--js/src/tests/js1_8_5/extensions/clone-object.js129
-rw-r--r--js/src/tests/js1_8_5/extensions/clone-regexp.js37
-rw-r--r--js/src/tests/js1_8_5/extensions/clone-simple.js33
-rw-r--r--js/src/tests/js1_8_5/extensions/clone-transferables.js112
-rw-r--r--js/src/tests/js1_8_5/extensions/clone-typed-array.js104
-rw-r--r--js/src/tests/js1_8_5/extensions/clone-v1-typed-array-data.dat32
-rw-r--r--js/src/tests/js1_8_5/extensions/clone-v1-typed-array.js130
-rw-r--r--js/src/tests/js1_8_5/extensions/column-numbers.js10
-rw-r--r--js/src/tests/js1_8_5/extensions/dataview.js1635
-rw-r--r--js/src/tests/js1_8_5/extensions/decompile-for-of.js27
-rw-r--r--js/src/tests/js1_8_5/extensions/destructure-accessor.js75
-rw-r--r--js/src/tests/js1_8_5/extensions/empty.txt0
-rw-r--r--js/src/tests/js1_8_5/extensions/file-mapped-arraybuffers.js41
-rw-r--r--js/src/tests/js1_8_5/extensions/file-mapped-arraybuffers.txt1
-rw-r--r--js/src/tests/js1_8_5/extensions/is-generator.js23
-rw-r--r--js/src/tests/js1_8_5/extensions/mutable-proto-special-form.js91
-rw-r--r--js/src/tests/js1_8_5/extensions/object-toSource-undefined-getter.js9
-rw-r--r--js/src/tests/js1_8_5/extensions/object-toSource-with-symbol-keys.js14
-rw-r--r--js/src/tests/js1_8_5/extensions/proxy-proto-setter.js50
-rw-r--r--js/src/tests/js1_8_5/extensions/recursion.js60
-rw-r--r--js/src/tests/js1_8_5/extensions/redeclaration-of-catch-warning.js37
-rw-r--r--js/src/tests/js1_8_5/extensions/regress-558541.js12
-rw-r--r--js/src/tests/js1_8_5/extensions/regress-604781-1.js24
-rw-r--r--js/src/tests/js1_8_5/extensions/regress-604781-2.js13
-rw-r--r--js/src/tests/js1_8_5/extensions/regress-627984-1.js16
-rw-r--r--js/src/tests/js1_8_5/extensions/regress-627984-2.js15
-rw-r--r--js/src/tests/js1_8_5/extensions/regress-627984-3.js14
-rw-r--r--js/src/tests/js1_8_5/extensions/regress-627984-4.js15
-rw-r--r--js/src/tests/js1_8_5/extensions/regress-627984-5.js13
-rw-r--r--js/src/tests/js1_8_5/extensions/regress-627984-6.js15
-rw-r--r--js/src/tests/js1_8_5/extensions/regress-627984-7.js9
-rw-r--r--js/src/tests/js1_8_5/extensions/regress-631723.js10
-rw-r--r--js/src/tests/js1_8_5/extensions/regress-636697.js11
-rw-r--r--js/src/tests/js1_8_5/extensions/regress-636818.js9
-rw-r--r--js/src/tests/js1_8_5/extensions/regress-637985.js8
-rw-r--r--js/src/tests/js1_8_5/extensions/regress-645160.js8
-rw-r--r--js/src/tests/js1_8_5/extensions/regress-650753.js8
-rw-r--r--js/src/tests/js1_8_5/extensions/regress-677589.js10
-rw-r--r--js/src/tests/js1_8_5/extensions/regress-677924.js14
-rw-r--r--js/src/tests/js1_8_5/extensions/regress-691746.js11
-rw-r--r--js/src/tests/js1_8_5/extensions/regress-696109.js13
-rw-r--r--js/src/tests/js1_8_5/extensions/selfhosted-detecting-strict.js27
-rw-r--r--js/src/tests/js1_8_5/extensions/set-property-non-extensible.js30
-rw-r--r--js/src/tests/js1_8_5/extensions/sharedtypedarray.js263
-rw-r--r--js/src/tests/js1_8_5/extensions/shell.js115
-rw-r--r--js/src/tests/js1_8_5/extensions/sps-generators.js39
-rw-r--r--js/src/tests/js1_8_5/extensions/symbol-uneval.js13
-rw-r--r--js/src/tests/js1_8_5/extensions/toSource-0.js14
-rw-r--r--js/src/tests/js1_8_5/extensions/typedarray-copyWithin-arguments-detaching.js112
-rw-r--r--js/src/tests/js1_8_5/extensions/typedarray-set-neutering.js49
-rw-r--r--js/src/tests/js1_8_5/extensions/typedarray-subarray-of-subarray.js33
-rw-r--r--js/src/tests/js1_8_5/extensions/typedarray.js648
-rw-r--r--js/src/tests/js1_8_5/extensions/watch-undefined-setter.js19
-rw-r--r--js/src/tests/js1_8_5/extensions/weakmap.js124
64 files changed, 4994 insertions, 0 deletions
diff --git a/js/src/tests/js1_8_5/extensions/array-length-protochange.js b/js/src/tests/js1_8_5/extensions/array-length-protochange.js
new file mode 100644
index 000000000..aeec8e9a2
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/array-length-protochange.js
@@ -0,0 +1,35 @@
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 548671;
+var summary =
+ "Don't use a shared-permanent inherited property to implement " +
+ "[].length or (function(){}).length";
+
+print(BUGNUMBER + ": " + summary);
+
+/**************
+ * BEGIN TEST *
+ **************/
+
+var a = [1, 2, 3];
+a.__proto__ = null;
+reportCompare("length" in a, true, "length should be own property of array");
+reportCompare(Object.hasOwnProperty.call(a, "length"), true,
+ "length should be own property of array");
+reportCompare(a.length, 3, "array length should be 3");
+
+var a = [], b = [];
+b.__proto__ = a;
+reportCompare(b.hasOwnProperty("length"), true,
+ "length should be own property of array");
+b.length = 42;
+reportCompare(b.length, 42, "should have mutated b's (own) length");
+reportCompare(a.length, 0, "should not have mutated a's (own) length");
+
+
+if (typeof reportCompare === "function")
+ reportCompare(true, true);
+
+print("All tests passed!");
diff --git a/js/src/tests/js1_8_5/extensions/arraybuffer-prototype.js b/js/src/tests/js1_8_5/extensions/arraybuffer-prototype.js
new file mode 100644
index 000000000..c61b31776
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/arraybuffer-prototype.js
@@ -0,0 +1,28 @@
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 665961;
+var summary =
+ "ArrayBuffer cannot access properties defined on the prototype chain.";
+print(BUGNUMBER + ": " + summary);
+
+/**************
+ * BEGIN TEST *
+ **************/
+
+ArrayBuffer.prototype.prop = "on prototype";
+var b = new ArrayBuffer([]);
+assertEq(b.prop, "on prototype");
+
+var c = new ArrayBuffer([]);
+assertEq(c.prop, "on prototype");
+c.prop = "direct";
+assertEq(c.prop, "direct");
+
+assertEq(ArrayBuffer.prototype.prop, "on prototype");
+assertEq(new ArrayBuffer([]).prop, "on prototype");
+
+assertEq(c.nonexistent, undefined);
+
+reportCompare(true, true);
diff --git a/js/src/tests/js1_8_5/extensions/browser.js b/js/src/tests/js1_8_5/extensions/browser.js
new file mode 100644
index 000000000..fc8ffefac
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/browser.js
@@ -0,0 +1,6 @@
+// The page loaded in the browser is jsreftest.html, which is located in
+// js/src/tests. That makes Worker script URLs resolve relative to the wrong
+// directory. workerDir is the workaround.
+workerDir = (document.location.href.replace(/\/[^/?]*(\?.*)?$/, '/') +
+ 'js1_8_5/extensions/');
+
diff --git a/js/src/tests/js1_8_5/extensions/censor-strict-caller.js b/js/src/tests/js1_8_5/extensions/censor-strict-caller.js
new file mode 100644
index 000000000..8662bebf2
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/censor-strict-caller.js
@@ -0,0 +1,34 @@
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 588251;
+var summary =
+ "fun.caller should throw if that value corresponds to a strict mode " +
+ "function";
+
+print(BUGNUMBER + ": " + summary);
+
+/**************
+ * BEGIN TEST *
+ **************/
+
+function nonstrict() { return nonstrict.caller; }
+function strict() { "use strict"; return nonstrict(); }
+try
+{
+ strict();
+ throw 17;
+}
+catch (e)
+{
+ assertEq(e instanceof TypeError, true,
+ "expected TypeError accessing strict mode caller, got: " + e);
+}
+
+/******************************************************************************/
+
+if (typeof reportCompare === "function")
+ reportCompare(true, true);
+
+print("All tests passed!");
diff --git a/js/src/tests/js1_8_5/extensions/clone-complex-object.js b/js/src/tests/js1_8_5/extensions/clone-complex-object.js
new file mode 100644
index 000000000..7a20dbb38
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/clone-complex-object.js
@@ -0,0 +1,313 @@
+// |reftest| skip-if(!xulRuntime.shell)
+// -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+// Set of properties on a cloned object that are legitimately non-enumerable,
+// grouped by object type.
+var non_enumerable = { 'Array': [ 'length' ],
+ 'String': [ 'length' ] };
+
+// Set of properties on a cloned object that are legitimately non-configurable,
+// grouped by object type. The property name '0' stands in for any indexed
+// property.
+var non_configurable = { 'String': [ 0 ],
+ '(typed array)': [ 0 ] };
+
+// Set of properties on a cloned object that are legitimately non-writable,
+// grouped by object type. The property name '0' stands in for any indexed
+// property.
+var non_writable = { 'String': [ 0 ] };
+
+function classOf(obj) {
+ var classString = Object.prototype.toString.call(obj);
+ var [ all, classname ] = classString.match(/\[object (\w+)/);
+ return classname;
+}
+
+function isIndex(p) {
+ var u = p >>> 0;
+ return ("" + u == p && u != 0xffffffff);
+}
+
+function notIndex(p) {
+ return !isIndex(p);
+}
+
+function tableContains(table, cls, prop) {
+ if (isIndex(prop))
+ prop = 0;
+ if (cls.match(/\wArray$/))
+ cls = "(typed array)";
+ var exceptionalProps = table[cls] || [];
+ return exceptionalProps.indexOf(prop) != -1;
+}
+
+function shouldBeConfigurable(cls, prop) {
+ return !tableContains(non_configurable, cls, prop);
+}
+
+function shouldBeWritable(cls, prop) {
+ return !tableContains(non_writable, cls, prop);
+}
+
+function ownProperties(obj) {
+ return Object.getOwnPropertyNames(obj).
+ map(function (p) { return [p, Object.getOwnPropertyDescriptor(obj, p)]; });
+}
+
+function isCloneable(pair) {
+ return typeof pair[0] === 'string' && pair[1].enumerable;
+}
+
+function compareProperties(a, b, stack, path) {
+ var ca = classOf(a);
+
+ // 'b', the original object, may have non-enumerable or XMLName properties;
+ // ignore them. 'a', the clone, should not have any non-enumerable
+ // properties (except .length, if it's an Array or String) or XMLName
+ // properties.
+ var pb = ownProperties(b).filter(isCloneable);
+ var pa = ownProperties(a);
+ for (var i = 0; i < pa.length; i++) {
+ var propname = pa[i][0];
+ assertEq(typeof propname, "string", "clone should not have E4X properties " + path);
+ if (!pa[i][1].enumerable) {
+ if (tableContains(non_enumerable, ca, propname)) {
+ // remove it so that the comparisons below will work
+ pa.splice(i, 1);
+ i--;
+ } else {
+ throw new Error("non-enumerable clone property " + uneval(pa[i][0]) + " " + path);
+ }
+ }
+ }
+
+ // Check that, apart from properties whose names are array indexes,
+ // the enumerable properties appear in the same order.
+ var aNames = pa.map(function (pair) { return pair[1]; }).filter(notIndex);
+ var bNames = pa.map(function (pair) { return pair[1]; }).filter(notIndex);
+ assertEq(aNames.join(","), bNames.join(","), path);
+
+ // Check that the lists are the same when including array indexes.
+ function byName(a, b) { a = a[0]; b = b[0]; return a < b ? -1 : a === b ? 0 : 1; }
+ pa.sort(byName);
+ pb.sort(byName);
+ assertEq(pa.length, pb.length, "should see the same number of properties " + path);
+ for (var i = 0; i < pa.length; i++) {
+ var aName = pa[i][0];
+ var bName = pb[i][0];
+ assertEq(aName, bName, path);
+
+ var path2 = isIndex(aName) ? path + "[" + aName + "]" : path + "." + aName;
+ var da = pa[i][1];
+ var db = pb[i][1];
+ assertEq(da.configurable, shouldBeConfigurable(ca, aName), path2);
+ assertEq(da.writable, shouldBeWritable(ca, aName), path2);
+ assertEq("value" in da, true, path2);
+ var va = da.value;
+ var vb = b[pb[i][0]];
+ stack.push([va, vb, path2]);
+ }
+}
+
+function isClone(a, b) {
+ var stack = [[a, b, 'obj']];
+ var memory = new WeakMap();
+ var rmemory = new WeakMap();
+
+ while (stack.length > 0) {
+ var pair = stack.pop();
+ var x = pair[0], y = pair[1], path = pair[2];
+ if (typeof x !== "object" || x === null) {
+ // x is primitive.
+ assertEq(x, y, "equal primitives");
+ } else if (x instanceof Date) {
+ assertEq(x.getTime(), y.getTime(), "equal times for cloned Dates");
+ } else if (memory.has(x)) {
+ // x is an object we have seen before in a.
+ assertEq(y, memory.get(x), "repeated object the same");
+ assertEq(rmemory.get(y), x, "repeated object's clone already seen");
+ } else {
+ // x is an object we have not seen before.
+ // Check that we have not seen y before either.
+ assertEq(rmemory.has(y), false);
+
+ var xcls = classOf(x);
+ var ycls = classOf(y);
+ assertEq(xcls, ycls, "same [[Class]]");
+
+ // clone objects should have the default prototype of the class
+ assertEq(Object.getPrototypeOf(x), this[xcls].prototype);
+
+ compareProperties(x, y, stack, path);
+
+ // Record that we have seen this pair of objects.
+ memory.set(x, y);
+ rmemory.set(y, x);
+ }
+ }
+ return true;
+}
+
+function check(val) {
+ var clone = deserialize(serialize(val));
+ assertEq(isClone(val, clone), true);
+ return clone;
+}
+
+// Various recursive objects
+
+// Recursive array.
+var a = [];
+a[0] = a;
+check(a);
+
+// Recursive Object.
+var b = {};
+b.next = b;
+check(b);
+
+// Mutually recursive objects.
+var a = [];
+var b = {};
+var c = {};
+a[0] = b;
+a[1] = b;
+a[2] = b;
+b.next = a;
+check(a);
+check(b);
+
+// A date
+check(new Date);
+
+// A recursive object that is very large.
+a = [];
+b = a;
+for (var i = 0; i < 10000; i++) {
+ b[0] = {};
+ b[1] = [];
+ b = b[1];
+}
+b[0] = {owner: a};
+b[1] = [];
+check(a);
+
+// Date objects should not be identical even if representing the same date
+var ar = [ new Date(1000), new Date(1000) ];
+var clone = check(ar);
+assertEq(clone[0] === clone[1], false);
+
+// Identity preservation for various types of objects
+
+function checkSimpleIdentity(v)
+{
+ a = check([ v, v ]);
+ assertEq(a[0] === a[1], true);
+ return a;
+}
+
+var v = new Boolean(true);
+checkSimpleIdentity(v);
+
+v = new Number(17);
+checkSimpleIdentity(v);
+
+v = new String("yo");
+checkSimpleIdentity(v);
+
+v = "fish";
+checkSimpleIdentity(v);
+
+v = new Int8Array([ 10, 20 ]);
+checkSimpleIdentity(v);
+
+v = new ArrayBuffer(7);
+checkSimpleIdentity(v);
+
+v = new Date(1000);
+b = [ v, v, { 'date': v } ];
+clone = check(b);
+assertEq(clone[0] === clone[1], true);
+assertEq(clone[0], clone[2]['date']);
+assertEq(clone[0] === v, false);
+
+// Reduced and modified from postMessage_structured_clone test
+let foo = { };
+let baz = { };
+let obj = { 'foo': foo,
+ 'bar': { 'foo': foo },
+ 'expando': { 'expando': baz },
+ 'baz': baz };
+check(obj);
+
+for (obj of new getTestContent)
+ check(obj);
+
+// Stolen wholesale from postMessage_structured_clone_helper.js
+function getTestContent()
+{
+ yield "hello";
+ yield 2+3;
+ yield 12;
+ yield null;
+ yield "complex" + "string";
+ yield new Object();
+ yield new Date(1306113544);
+ yield [1, 2, 3, 4, 5];
+ let obj = new Object();
+ obj.foo = 3;
+ obj.bar = "hi";
+ obj.baz = new Date(1306113544);
+ obj.boo = obj;
+ yield obj;
+
+ let recursiveobj = new Object();
+ recursiveobj.a = recursiveobj;
+ recursiveobj.foo = new Object();
+ recursiveobj.foo.bar = "bar";
+ recursiveobj.foo.backref = recursiveobj;
+ recursiveobj.foo.baz = 84;
+ recursiveobj.foo.backref2 = recursiveobj;
+ recursiveobj.bar = new Object();
+ recursiveobj.bar.foo = "foo";
+ recursiveobj.bar.backref = recursiveobj;
+ recursiveobj.bar.baz = new Date(1306113544);
+ recursiveobj.bar.backref2 = recursiveobj;
+ recursiveobj.expando = recursiveobj;
+ yield recursiveobj;
+
+ obj = new Object();
+ obj.expando1 = 1;
+ obj.foo = new Object();
+ obj.foo.bar = 2;
+ obj.bar = new Object();
+ obj.bar.foo = obj.foo;
+ obj.expando = new Object();
+ obj.expando.expando = new Object();
+ obj.expando.expando.obj = obj;
+ obj.expando2 = 4;
+ obj.baz = obj.expando.expando;
+ obj.blah = obj.bar;
+ obj.foo.baz = obj.blah;
+ obj.foo.blah = obj.blah;
+ yield obj;
+
+ let diamond = new Object();
+ obj = new Object();
+ obj.foo = "foo";
+ obj.bar = 92;
+ obj.backref = diamond;
+ diamond.ref1 = obj;
+ diamond.ref2 = obj;
+ yield diamond;
+
+ let doubleref = new Object();
+ obj = new Object();
+ doubleref.ref1 = obj;
+ doubleref.ref2 = obj;
+ yield doubleref;
+}
+
+reportCompare(0, 0, 'ok');
diff --git a/js/src/tests/js1_8_5/extensions/clone-errors.js b/js/src/tests/js1_8_5/extensions/clone-errors.js
new file mode 100644
index 000000000..f65578a06
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/clone-errors.js
@@ -0,0 +1,41 @@
+// |reftest| skip-if(!xulRuntime.shell)
+// -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+function check(v) {
+ try {
+ serialize(v);
+ } catch (exc) {
+ return;
+ }
+ throw new Error("serializing " + uneval(v) + " should have failed with an exception");
+}
+
+// Unsupported object types.
+check(new Error("oops"));
+check(this);
+check(Math);
+check(function () {});
+check(new Proxy({}, {}));
+
+// A failing getter.
+check({get x() { throw new Error("fail"); }});
+
+// Mismatched scopes.
+for (let [write_scope, read_scope] of [['SameProcessSameThread', 'SameProcessDifferentThread'],
+ ['SameProcessSameThread', 'DifferentProcess'],
+ ['SameProcessDifferentThread', 'DifferentProcess']])
+{
+ var ab = new ArrayBuffer(12);
+ var buffer = serialize(ab, [ab], { scope: write_scope });
+ var caught = false;
+ try {
+ deserialize(buffer, { scope: read_scope });
+ } catch (exc) {
+ caught = true;
+ }
+ assertEq(caught, true, `${write_scope} clone buffer should not be deserializable as ${read_scope}`);
+}
+
+reportCompare(0, 0, "ok");
diff --git a/js/src/tests/js1_8_5/extensions/clone-forge.js b/js/src/tests/js1_8_5/extensions/clone-forge.js
new file mode 100644
index 000000000..3cdb0ea0d
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/clone-forge.js
@@ -0,0 +1,39 @@
+// |reftest| skip-if(!xulRuntime.shell)
+// -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+function assertThrows(f) {
+ var ok = false;
+ try {
+ f();
+ } catch (exc) {
+ ok = true;
+ }
+ if (!ok)
+ throw new TypeError("Assertion failed: " + f + " did not throw as expected");
+}
+
+function byteArray(str) {
+ return str.split('').map(c => c.charCodeAt(0));
+}
+
+// Don't allow forging bogus Date objects.
+var mutated = byteArray(serialize(new Date(NaN)).clonebuffer);
+
+var a = [1/0, -1/0,
+ Number.MIN_VALUE, -Number.MIN_VALUE,
+ Math.PI, 1286523948674.5,
+ Number.MAX_VALUE, -Number.MAX_VALUE,
+ 8.64e15 + 1, -(8.64e15 + 1)];
+for (var i = 0; i < a.length; i++) {
+ var n = a[i];
+ var nbuf = serialize(n);
+ var data = byteArray(nbuf.clonebuffer);
+ for (var j = 0; j < 8; j++)
+ mutated[j+8] = data[j];
+ nbuf.clonebuffer = String.fromCharCode.apply(null, mutated);
+ assertThrows(function () { deserialize(nbuf); });
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/js1_8_5/extensions/clone-leaf-object.js b/js/src/tests/js1_8_5/extensions/clone-leaf-object.js
new file mode 100644
index 000000000..b50b307ba
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/clone-leaf-object.js
@@ -0,0 +1,64 @@
+// |reftest| skip-if(!xulRuntime.shell)
+// -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+var a = [new Boolean(true),
+ new Boolean(false),
+ new Number(0),
+ new Number(-0),
+ new Number(Math.PI),
+ new Number(0x7fffffff),
+ new Number(-0x7fffffff),
+ new Number(0x80000000),
+ new Number(-0x80000000),
+ new Number(0xffffffff),
+ new Number(-0xffffffff),
+ new Number(0x100000000),
+ new Number(-0x100000000),
+ new Number(Number.MIN_VALUE),
+ new Number(-Number.MIN_VALUE),
+ new Number(Number.MAX_VALUE),
+ new Number(-Number.MAX_VALUE),
+ new Number(1/0),
+ new Number(-1/0),
+ new Number(0/0),
+ new String(""),
+ new String("\0123\u4567"),
+ new Date(0),
+ new Date(-0),
+ new Date(0x7fffffff),
+ new Date(-0x7fffffff),
+ new Date(0x80000000),
+ new Date(-0x80000000),
+ new Date(0xffffffff),
+ new Date(-0xffffffff),
+ new Date(0x100000000),
+ new Date(-0x100000000),
+ new Date(1286523948674),
+ new Date(8.64e15), // hard-coded in ES5 spec, hard-coded here
+ new Date(-8.64e15),
+ new Date(NaN)];
+
+function primitive(a) {
+ return a instanceof Date ? +a : a.constructor(a);
+}
+
+for (var i = 0; i < a.length; i++) {
+ var x = a[i];
+ var expectedSource = x.toSource();
+ var expectedPrimitive = primitive(x);
+ var expectedProto = x.__proto__;
+ var expectedString = Object.prototype.toString.call(x);
+ x.expando = 1;
+ x.__proto__ = {};
+
+ var y = deserialize(serialize(x));
+ assertEq(y.toSource(), expectedSource);
+ assertEq(primitive(y), expectedPrimitive);
+ assertEq(y.__proto__, expectedProto);
+ assertEq(Object.prototype.toString.call(y), expectedString);
+ assertEq("expando" in y, false);
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/js1_8_5/extensions/clone-many-transferables.js b/js/src/tests/js1_8_5/extensions/clone-many-transferables.js
new file mode 100644
index 000000000..7434a09aa
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/clone-many-transferables.js
@@ -0,0 +1,25 @@
+// |reftest| skip-if(!xulRuntime.shell) -- requires serialize()
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+function test()
+{
+ // On my system, with an unfixed build where transfer-list processing is
+ // quadratic, 5e5 elements makes this test take ~70s in a shell opt build.
+ // Debug build is well into timeout-land at 300+s. As long as at least *one*
+ // platform times out for a quadratic algorithm, a regression should be
+ // obvious. (Time to run the test in even a debug shell is ~17s, well short
+ // of timing out.)
+ var transfers = [];
+ for (var i = 0; i < 5e5; i++)
+ transfers.push(new ArrayBuffer());
+
+ // If serialization is quadratic in the length of |transfers|, the test will
+ // time out. If the test doesn't time out, it passed.
+ serialize({}, transfers);
+}
+
+test();
+
+if (typeof reportCompare === "function")
+ reportCompare(0, 0, 'ok');
diff --git a/js/src/tests/js1_8_5/extensions/clone-object-deep.js b/js/src/tests/js1_8_5/extensions/clone-object-deep.js
new file mode 100644
index 000000000..685577b92
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/clone-object-deep.js
@@ -0,0 +1,25 @@
+// |reftest| skip-if(!xulRuntime.shell)
+// -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+function test() {
+ var check = clone_object_check;
+
+ // Invoke with the simple parameter to compile the function before doing
+ // deep clone, on --ion-eager case, to avoid timeout.
+ check({x: null, y: undefined});
+
+ // Try cloning a deep object. Don't fail with "too much recursion".
+ var b = {};
+ var current = b;
+ for (var i = 0; i < 10000; i++) {
+ var next = {};
+ current['x' + i] = next;
+ current = next;
+ }
+ check(b, "deepObject"); // takes 2 seconds :-\
+}
+
+test();
+reportCompare(0, 0, 'ok');
diff --git a/js/src/tests/js1_8_5/extensions/clone-object.js b/js/src/tests/js1_8_5/extensions/clone-object.js
new file mode 100644
index 000000000..29a38217a
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/clone-object.js
@@ -0,0 +1,129 @@
+// |reftest| skip-if(!xulRuntime.shell)
+// -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+function test() {
+ var check = clone_object_check;
+
+ check({});
+ check([]);
+ check({x: 0});
+ check({x: 0.7, p: "forty-two", y: null, z: undefined});
+ check(Array.prototype);
+ check(Object.prototype);
+
+ // before and after
+ var b, a;
+
+ // Slow array.
+ b = [, 1, 2, 3];
+ b.expando = true;
+ b[5] = 5;
+ b[0] = 0;
+ b[4] = 4;
+ delete b[2];
+ check(b);
+
+ // Check cloning properties other than basic data properties. (check()
+ // asserts that the properties of the clone are configurable, writable,
+ // enumerable data properties.)
+ b = {};
+ Object.defineProperties(b, {
+ x: {enumerable: true, get: function () { return 12479; }},
+ y: {enumerable: true, configurable: true, writable: false, value: 0},
+ z: {enumerable: true, configurable: false, writable: true, value: 0},
+ hidden: {enumerable:false, value: 1334}});
+ check(b);
+
+ // Check corner cases involving property names.
+ b = {"-1": -1,
+ 0xffffffff: null,
+ 0x100000000: null,
+ "": 0,
+ "\xff\x7f\u7fff\uffff\ufeff\ufffe": 1, // random unicode id
+ "\ud800 \udbff \udc00 \udfff": 2}; // busted surrogate pairs
+ check(b);
+
+ b = [];
+ b[-1] = -1;
+ b[0xffffffff] = null;
+ b[0x100000000] = null;
+ b[""] = 0;
+ b["\xff\x7f\u7fff\uffff\ufeff\ufffe"] = 1;
+ b["\ud800 \udbff \udc00 \udfff"] = 2;
+ check(b);
+
+ // An array's .length property is not enumerable, so it is not cloned.
+ b = Array(5);
+ assertEq(b.length, 5);
+ a = check(b);
+ assertEq(a.length, 0);
+
+ b[1] = "ok";
+ a = check(b);
+ assertEq(a.length, 2);
+
+ // Check that prototypes are not cloned, per spec.
+ b = Object.create({x:1});
+ b.y = 2;
+ b.z = 3;
+ check(b);
+
+ // Check that cloning does not separate merge points in the tree.
+ var same = {};
+ b = {one: same, two: same};
+ a = check(b);
+ assertEq(a.one === a.two, true);
+
+ b = [same, same];
+ a = check(b);
+ assertEq(a[0] === a[1], true);
+
+ /*
+ XXX TODO spin this out into its own test
+ // This fails quickly with an OOM error. An exception would be nicer.
+ function Infinitree() {
+ return { get left() { return new Infinitree; },
+ get right() { return new Infinitree; }};
+ }
+ var threw = false;
+ try {
+ serialize(new Infinitree);
+ } catch (exc) {
+ threw = true;
+ }
+ assertEq(threw, true);
+ */
+
+ // Clone an array with holes.
+ check([0, 1, 2, , 4, 5, 6]);
+
+ // Array holes should not take up space.
+ b = [];
+ b[255] = 1;
+ check(b);
+ assertEq(serialize(b).clonebuffer.length < 255, true);
+
+ // Self-modifying object.
+ // This should never read through to b's prototype.
+ b = Object.create({y: 2},
+ {x: {enumerable: true,
+ configurable: true,
+ get: function() { if (this.hasOwnProperty("y")) delete this.y; return 1; }},
+ y: {enumerable: true,
+ configurable: true,
+ writable: true,
+ value: 3}});
+ check(b, "selfModifyingObject");
+
+ // Ignore properties with object-ids.
+ var uri = "http://example.net";
+ b = {x: 1, y: 2};
+ Object.defineProperty(b, Array(uri, "x"), {enumerable: true, value: 3});
+ Object.defineProperty(b, Array(uri, "y"), {enumerable: true, value: 5});
+ check(b);
+}
+
+test();
+reportCompare(0, 0, 'ok');
diff --git a/js/src/tests/js1_8_5/extensions/clone-regexp.js b/js/src/tests/js1_8_5/extensions/clone-regexp.js
new file mode 100644
index 000000000..97f755785
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/clone-regexp.js
@@ -0,0 +1,37 @@
+// |reftest| skip-if(!xulRuntime.shell)
+// -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+function testRegExp(b, c=b) {
+ var a = deserialize(serialize(b));
+ assertEq(a === b, false);
+ assertEq(Object.getPrototypeOf(a), RegExp.prototype);
+ assertEq(Object.prototype.toString.call(a), "[object RegExp]");
+ for (p in a)
+ throw new Error("cloned RegExp should have no enumerable properties");
+
+ assertEq(a.source, c.source);
+ assertEq(a.global, c.global);
+ assertEq(a.ignoreCase, c.ignoreCase);
+ assertEq(a.multiline, c.multiline);
+ assertEq(a.sticky, c.sticky);
+ assertEq("expando" in a, false);
+}
+
+testRegExp(RegExp(""));
+testRegExp(/(?:)/);
+testRegExp(/^(.*)$/gimy);
+testRegExp(RegExp.prototype);
+
+var re = /\bx\b/gi;
+re.expando = true;
+testRegExp(re);
+// `source` and the flag accessors are defined on RegExp.prototype, so they're
+// not available after re.__proto__ has been changed. We solve that by passing
+// in an additional copy of the same RegExp to compare the
+// serialized-then-deserialized clone with."
+re.__proto__ = {};
+testRegExp(re, /\bx\b/gi);
+
+reportCompare(0, 0, 'ok');
diff --git a/js/src/tests/js1_8_5/extensions/clone-simple.js b/js/src/tests/js1_8_5/extensions/clone-simple.js
new file mode 100644
index 000000000..b7684dd02
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/clone-simple.js
@@ -0,0 +1,33 @@
+// |reftest| skip-if(!xulRuntime.shell)
+// -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+function testEq(b) {
+ var a = deserialize(serialize(b));
+ assertEq(a, b);
+}
+
+testEq(void 0);
+testEq(null);
+
+testEq(true);
+testEq(false);
+
+testEq(0);
+testEq(-0);
+testEq(1/0);
+testEq(-1/0);
+testEq(0/0);
+testEq(Math.PI);
+
+testEq("");
+testEq("\0");
+testEq("a"); // unit string
+testEq("ab"); // length-2 string
+testEq("abc\0123\r\n"); // nested null character
+testEq("\xff\x7f\u7fff\uffff\ufeff\ufffe"); // random unicode stuff
+testEq("\ud800 \udbff \udc00 \udfff"); // busted surrogate pairs
+testEq(Array(1024).join(Array(1024).join("x"))); // 2MB string
+
+reportCompare(0, 0, 'ok');
diff --git a/js/src/tests/js1_8_5/extensions/clone-transferables.js b/js/src/tests/js1_8_5/extensions/clone-transferables.js
new file mode 100644
index 000000000..673684b95
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/clone-transferables.js
@@ -0,0 +1,112 @@
+// |reftest| skip-if(!xulRuntime.shell)
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+function* buffer_options() {
+ for (var scope of ["SameProcessSameThread", "SameProcessDifferentThread", "DifferentProcess"]) {
+ for (var size of [0, 8, 16, 200, 1000, 4096, 8192, 65536]) {
+ yield { scope, size };
+ }
+ }
+}
+
+
+function test() {
+ for (var {scope, size} of buffer_options()) {
+ var old = new ArrayBuffer(size);
+ var copy = deserialize(serialize([old, old], [old], { scope }), { scope });
+ assertEq(old.byteLength, 0);
+ assertEq(copy[0] === copy[1], true);
+ copy = copy[0];
+ assertEq(copy.byteLength, size);
+
+ var constructors = [ Int8Array,
+ Uint8Array,
+ Int16Array,
+ Uint16Array,
+ Int32Array,
+ Uint32Array,
+ Float32Array,
+ Float64Array,
+ Uint8ClampedArray,
+ DataView ];
+
+ for (var ctor of constructors) {
+ var dataview = (ctor === DataView);
+
+ var buf = new ArrayBuffer(size);
+ var old_arr = new ctor(buf);
+ assertEq(buf.byteLength, size);
+ assertEq(buf, old_arr.buffer);
+ if (!dataview)
+ assertEq(old_arr.length, size / old_arr.BYTES_PER_ELEMENT);
+
+ var copy_arr = deserialize(serialize(old_arr, [ buf ], { scope }), { scope });
+ assertEq(buf.byteLength, 0,
+ "donor array buffer should be detached");
+ if (!dataview) {
+ assertEq(old_arr.length, 0,
+ "donor typed array should be detached");
+ }
+ assertEq(copy_arr.buffer.byteLength == size, true);
+ if (!dataview)
+ assertEq(copy_arr.length, size / old_arr.BYTES_PER_ELEMENT);
+
+ buf = null;
+ old_arr = null;
+ gc(); // Tickle the ArrayBuffer -> view management
+ }
+
+ for (var ctor of constructors) {
+ var dataview = (ctor === DataView);
+
+ var buf = new ArrayBuffer(size);
+ var old_arr = new ctor(buf);
+ var dv = new DataView(buf); // Second view
+ var copy_arr = deserialize(serialize(old_arr, [ buf ], { scope }), { scope });
+ assertEq(buf.byteLength, 0,
+ "donor array buffer should be detached");
+ assertEq(old_arr.byteLength, 0,
+ "donor typed array should be detached");
+ if (!dataview) {
+ assertEq(old_arr.length, 0,
+ "donor typed array should be detached");
+ }
+ assertEq(dv.byteLength, 0,
+ "all views of donor array buffer should have zero " +
+ "length because their underlying buffer is detached");
+
+ buf = null;
+ old_arr = null;
+ gc(); // Tickle the ArrayBuffer -> view management
+ }
+
+ // Mutate the buffer during the clone operation. The modifications should be visible.
+ if (size >= 4) {
+ old = new ArrayBuffer(size);
+ var view = new Int32Array(old);
+ view[0] = 1;
+ var mutator = { get foo() { view[0] = 2; } };
+ var copy = deserialize(serialize([ old, mutator ], [ old ], { scope }), { scope });
+ var viewCopy = new Int32Array(copy[0]);
+ assertEq(view.length, 0); // Underlying buffer now detached.
+ assertEq(viewCopy[0], 2);
+ }
+
+ // Detach the buffer during the clone operation. Should throw an
+ // exception.
+ if (size >= 4) {
+ old = new ArrayBuffer(size);
+ var mutator = {
+ get foo() {
+ deserialize(serialize(old, [old], { scope }), { scope });
+ }
+ };
+ // The throw is not yet implemented, bug 919259.
+ //var copy = deserialize(serialize([ old, mutator ], [old]));
+ }
+ }
+}
+
+test();
+reportCompare(0, 0, 'ok');
diff --git a/js/src/tests/js1_8_5/extensions/clone-typed-array.js b/js/src/tests/js1_8_5/extensions/clone-typed-array.js
new file mode 100644
index 000000000..77f0376e9
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/clone-typed-array.js
@@ -0,0 +1,104 @@
+// |reftest| skip-if(!xulRuntime.shell)
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+function assertArraysEqual(a, b) {
+ assertEq(a.constructor, b.constructor);
+ assertEq(a.length, b.length);
+ for (var i = 0; i < a.length; i++)
+ assertEq(a[i], b[i]);
+}
+
+function check(b) {
+ var a = deserialize(serialize(b));
+ assertArraysEqual(a, b);
+}
+
+function checkPrototype(ctor) {
+ var threw = false;
+ try {
+ serialize(ctor.prototype);
+ throw new Error("serializing " + ctor.name + ".prototype should throw a TypeError");
+ } catch (exc) {
+ if (!(exc instanceof TypeError))
+ throw exc;
+ }
+}
+
+function test() {
+ // Test cloning ArrayBuffer objects.
+ check(new ArrayBuffer(0));
+ check(new ArrayBuffer(7));
+ checkPrototype(ArrayBuffer);
+
+ // Test cloning typed array objects.
+ var ctors = [
+ Int8Array,
+ Uint8Array,
+ Int16Array,
+ Uint16Array,
+ Int32Array,
+ Uint32Array,
+ Float32Array,
+ Float64Array,
+ Uint8ClampedArray];
+
+ var b;
+ for (var i = 0; i < ctors.length; i++) {
+ var ctor = ctors[i];
+
+ // check empty array
+ b = new ctor(0);
+ check(b);
+
+ // check array with some elements
+ b = new ctor(100);
+ var v = 1;
+ for (var j = 0; j < 100; j++) {
+ b[j] = v;
+ v *= 7;
+ }
+ b[99] = NaN; // check serializing NaNs too
+ check(b);
+
+ // try the prototype
+ checkPrototype(ctor);
+ }
+
+ // Two TypedArrays backed by the same ArrayBuffer should be cloned into two
+ // TypedArrays still sharing a buffer. This also tests cloning TypedArrays
+ // where the arr->data pointer is not 8-byte-aligned.
+
+ var base = new Int8Array([0, 1, 2, 3]);
+ b = [new Int8Array(base.buffer, 0, 3), new Int8Array(base.buffer, 1, 3)];
+ var a = deserialize(serialize(b));
+ base[1] = -1;
+ a[0][2] = -2;
+ assertArraysEqual(b[0], new Int8Array([0, -1, 2])); // shared with base
+ assertArraysEqual(b[1], new Int8Array([-1, 2, 3])); // shared with base
+ assertArraysEqual(a[0], new Int8Array([0, 1, -2])); // not shared with base
+ assertArraysEqual(a[1], new Int8Array([1, -2, 3])); // not shared with base, shared with a[0]
+
+ assertEq(b[0].buffer, b[1].buffer);
+ assertEq(b[1].byteOffset, 1);
+ assertEq(b[1].byteLength, 3);
+ assertEq(b[1].buffer.byteLength, 4);
+
+ // ArrayBuffer clones do not preserve properties
+
+ base = new Int8Array([0, 1, 2, 3]);
+ b = [new Int8Array(base.buffer, 0, 3), new Int8Array(base.buffer, 1, 3)];
+ base.buffer.prop = "yes";
+ base.buffer.loop = b[0];
+ base.buffer.loops = [ b[0], b[1] ];
+ a = deserialize(serialize(b));
+ assertEq("prop" in a[0].buffer, false);
+ assertEq("prop" in a[1].buffer, false);
+ assertEq("loop" in a[0].buffer, false);
+ assertEq("loop" in a[1].buffer, false);
+ assertEq("loops" in a[0].buffer, false);
+ assertEq("loops" in a[1].buffer, false);
+}
+
+test();
+reportCompare(0, 0, 'ok');
diff --git a/js/src/tests/js1_8_5/extensions/clone-v1-typed-array-data.dat b/js/src/tests/js1_8_5/extensions/clone-v1-typed-array-data.dat
new file mode 100644
index 000000000..9ced34100
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/clone-v1-typed-array-data.dat
@@ -0,0 +1,32 @@
+var captured = [];
+captured[0] = serialize(0); captured[0].clonebuffer = String.fromCharCode(0, 0, 0, 0, 9, 0, 255, 255);
+captured[1] = serialize(0); captured[1].clonebuffer = String.fromCharCode(7, 0, 0, 0, 9, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0);
+captured[2] = (new TypeError("unsupported type for structured data", "js1_8_5/extensions/clone-v1-typed-array.js", 19));
+captured[3] = serialize(0); captured[3].clonebuffer = String.fromCharCode(0, 0, 0, 0, 0, 1, 255, 255);
+captured[4] = serialize(0); captured[4].clonebuffer = String.fromCharCode(100, 0, 0, 0, 0, 1, 255, 255, 1, 7, 49, 87, 97, 167, 145, 247, 193, 71, 241, 151, 33, 231, 81, 55, 129, 135, 177, 216, 224, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
+captured[5] = (new TypeError("unsupported type for structured data", "js1_8_5/extensions/clone-v1-typed-array.js", 19));
+captured[6] = serialize(0); captured[6].clonebuffer = String.fromCharCode(0, 0, 0, 0, 1, 1, 255, 255);
+captured[7] = serialize(0); captured[7].clonebuffer = String.fromCharCode(100, 0, 0, 0, 1, 1, 255, 255, 1, 7, 49, 87, 97, 167, 145, 247, 193, 71, 241, 151, 33, 231, 81, 55, 129, 135, 177, 216, 224, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
+captured[8] = (new TypeError("unsupported type for structured data", "js1_8_5/extensions/clone-v1-typed-array.js", 19));
+captured[9] = serialize(0); captured[9].clonebuffer = String.fromCharCode(0, 0, 0, 0, 2, 1, 255, 255);
+captured[10] = serialize(0); captured[10].clonebuffer = String.fromCharCode(100, 0, 0, 0, 2, 1, 255, 255, 1, 0, 7, 0, 49, 0, 87, 1, 97, 9, 167, 65, 145, 203, 247, 144, 193, 246, 71, 191, 241, 58, 151, 156, 33, 72, 231, 248, 81, 206, 55, 164, 129, 125, 135, 110, 177, 5, 216, 39, 224, 22, 0, 160, 0, 96, 0, 160, 0, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
+captured[11] = (new TypeError("unsupported type for structured data", "js1_8_5/extensions/clone-v1-typed-array.js", 19));
+captured[12] = serialize(0); captured[12].clonebuffer = String.fromCharCode(0, 0, 0, 0, 3, 1, 255, 255);
+captured[13] = serialize(0); captured[13].clonebuffer = String.fromCharCode(100, 0, 0, 0, 3, 1, 255, 255, 1, 0, 7, 0, 49, 0, 87, 1, 97, 9, 167, 65, 145, 203, 247, 144, 193, 246, 71, 191, 241, 58, 151, 156, 33, 72, 231, 248, 81, 206, 55, 164, 129, 125, 135, 110, 177, 5, 216, 39, 224, 22, 0, 160, 0, 96, 0, 160, 0, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
+captured[14] = (new TypeError("unsupported type for structured data", "js1_8_5/extensions/clone-v1-typed-array.js", 19));
+captured[15] = serialize(0); captured[15].clonebuffer = String.fromCharCode(0, 0, 0, 0, 4, 1, 255, 255);
+captured[16] = serialize(0); captured[16].clonebuffer = String.fromCharCode(100, 0, 0, 0, 4, 1, 255, 255, 1, 0, 0, 0, 7, 0, 0, 0, 49, 0, 0, 0, 87, 1, 0, 0, 97, 9, 0, 0, 167, 65, 0, 0, 145, 203, 1, 0, 247, 144, 12, 0, 193, 246, 87, 0, 71, 191, 103, 2, 241, 58, 214, 16, 151, 156, 219, 117, 33, 72, 1, 57, 231, 248, 8, 143, 81, 206, 62, 233, 55, 164, 183, 96, 129, 125, 5, 165, 135, 110, 38, 131, 177, 5, 13, 150, 216, 39, 91, 26, 224, 22, 126, 184, 0, 160, 114, 11, 0, 96, 34, 80, 0, 160, 240, 48, 0, 128, 148, 86, 0, 0, 16, 94, 0, 0, 112, 146, 0, 0, 0, 1, 0, 0, 0, 8, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
+captured[17] = (new TypeError("unsupported type for structured data", "js1_8_5/extensions/clone-v1-typed-array.js", 19));
+captured[18] = serialize(0); captured[18].clonebuffer = String.fromCharCode(0, 0, 0, 0, 5, 1, 255, 255);
+captured[19] = serialize(0); captured[19].clonebuffer = String.fromCharCode(100, 0, 0, 0, 5, 1, 255, 255, 1, 0, 0, 0, 7, 0, 0, 0, 49, 0, 0, 0, 87, 1, 0, 0, 97, 9, 0, 0, 167, 65, 0, 0, 145, 203, 1, 0, 247, 144, 12, 0, 193, 246, 87, 0, 71, 191, 103, 2, 241, 58, 214, 16, 151, 156, 219, 117, 33, 72, 1, 57, 231, 248, 8, 143, 81, 206, 62, 233, 55, 164, 183, 96, 129, 125, 5, 165, 135, 110, 38, 131, 177, 5, 13, 150, 216, 39, 91, 26, 224, 22, 126, 184, 0, 160, 114, 11, 0, 96, 34, 80, 0, 160, 240, 48, 0, 128, 148, 86, 0, 0, 16, 94, 0, 0, 112, 146, 0, 0, 0, 1, 0, 0, 0, 8, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
+captured[20] = (new TypeError("unsupported type for structured data", "js1_8_5/extensions/clone-v1-typed-array.js", 19));
+captured[21] = serialize(0); captured[21].clonebuffer = String.fromCharCode(0, 0, 0, 0, 6, 1, 255, 255);
+captured[22] = serialize(0); captured[22].clonebuffer = String.fromCharCode(100, 0, 0, 0, 6, 1, 255, 255, 0, 0, 128, 63, 0, 0, 224, 64, 0, 0, 68, 66, 0, 128, 171, 67, 0, 16, 22, 69, 0, 78, 131, 70, 128, 200, 229, 71, 112, 15, 73, 73, 130, 237, 175, 74, 210, 239, 25, 76, 216, 177, 134, 77, 57, 183, 235, 78, 82, 64, 78, 80, 72, 120, 180, 81, 63, 233, 29, 83, 23, 44, 138, 84, 40, 205, 241, 85, 131, 147, 83, 87, 19, 33, 185, 88, 240, 252, 33, 90, 82, 189, 141, 91, 80, 11, 248, 92, 230, 9, 89, 94, 169, 232, 189, 95, 148, 43, 38, 97, 34, 102, 145, 98, 187, 114, 254, 99, 100, 164, 94, 101, 215, 207, 194, 102, 220, 117, 42, 104, 33, 39, 149, 105, 61, 130, 2, 107, 234, 99, 100, 108, 109, 215, 199, 109, 127, 220, 46, 111, 239, 0, 153, 112, 209, 224, 5, 114, 110, 73, 106, 115, 65, 0, 205, 116, 57, 96, 51, 118, 49, 244, 156, 119, 171, 85, 9, 121, 236, 85, 112, 122, 46, 75, 210, 123, 200, 1, 56, 125, 143, 1, 161, 126, 0, 0, 128, 127, 0, 0, 128, 127, 0, 0, 128, 127, 0, 0, 128, 127, 0, 0, 128, 127, 0, 0, 128, 127, 0, 0, 128, 127, 0, 0, 128, 127, 0, 0, 128, 127, 0, 0, 128, 127, 0, 0, 128, 127, 0, 0, 128, 127, 0, 0, 128, 127, 0, 0, 128, 127, 0, 0, 128, 127, 0, 0, 128, 127, 0, 0, 128, 127, 0, 0, 128, 127, 0, 0, 128, 127, 0, 0, 128, 127, 0, 0, 128, 127, 0, 0, 128, 127, 0, 0, 128, 127, 0, 0, 128, 127, 0, 0, 128, 127, 0, 0, 128, 127, 0, 0, 128, 127, 0, 0, 128, 127, 0, 0, 128, 127, 0, 0, 128, 127, 0, 0, 128, 127, 0, 0, 128, 127, 0, 0, 128, 127, 0, 0, 128, 127, 0, 0, 128, 127, 0, 0, 128, 127, 0, 0, 128, 127, 0, 0, 128, 127, 0, 0, 128, 127, 0, 0, 128, 127, 0, 0, 128, 127, 0, 0, 128, 127, 0, 0, 128, 127, 0, 0, 128, 127, 0, 0, 128, 127, 0, 0, 128, 127, 0, 0, 128, 127, 0, 0, 128, 127, 0, 0, 128, 127, 0, 0, 128, 127, 0, 0, 128, 127, 0, 0, 128, 127, 0, 0, 128, 127, 0, 0, 192, 127);
+captured[23] = (new TypeError("unsupported type for structured data", "js1_8_5/extensions/clone-v1-typed-array.js", 19));
+captured[24] = serialize(0); captured[24].clonebuffer = String.fromCharCode(0, 0, 0, 0, 7, 1, 255, 255);
+captured[25] = serialize(0); captured[25].clonebuffer = String.fromCharCode(100, 0, 0, 0, 7, 1, 255, 255, 0, 0, 0, 0, 0, 0, 240, 63, 0, 0, 0, 0, 0, 0, 28, 64, 0, 0, 0, 0, 0, 128, 72, 64, 0, 0, 0, 0, 0, 112, 117, 64, 0, 0, 0, 0, 0, 194, 162, 64, 0, 0, 0, 0, 192, 105, 208, 64, 0, 0, 0, 0, 16, 185, 252, 64, 0, 0, 0, 0, 238, 33, 41, 65, 0, 0, 0, 64, 176, 253, 85, 65, 0, 0, 0, 56, 250, 61, 131, 65, 0, 0, 0, 241, 58, 214, 176, 65, 0, 0, 192, 37, 231, 118, 221, 65, 0, 0, 8, 65, 10, 200, 9, 66, 0, 0, 231, 248, 8, 143, 54, 66, 0, 32, 202, 217, 39, 189, 99, 66, 0, 220, 144, 222, 130, 69, 145, 66, 0, 129, 125, 5, 165, 57, 190, 66, 224, 208, 205, 100, 112, 114, 234, 66, 196, 22, 52, 88, 34, 36, 23, 67, 236, 147, 45, 13, 158, 63, 68, 67, 110, 225, 135, 75, 170, 183, 113, 67, 128, 202, 45, 4, 106, 1, 159, 67, 48, 17, 168, 195, 60, 33, 203, 67, 10, 15, 51, 43, 21, 189, 247, 67, 41, 173, 204, 133, 114, 197, 36, 68, 132, 23, 19, 53, 196, 44, 82, 68, 39, 105, 225, 92, 87, 206, 127, 68, 2, 60, 69, 113, 140, 212, 171, 68, 130, 148, 28, 227, 250, 89, 216, 68, 242, 1, 185, 134, 187, 78, 5, 69, 180, 225, 225, 21, 228, 164, 50, 69, 126, 165, 37, 147, 71, 80, 96, 69, 156, 225, 129, 65, 125, 140, 140, 69, 104, 165, 81, 153, 237, 250, 184, 69, 187, 112, 39, 230, 143, 219, 229, 69, 164, 130, 98, 233, 29, 32, 19, 70, 80, 50, 54, 44, 26, 188, 64, 70, 12, 216, 94, 205, 45, 73, 109, 70, 10, 253, 178, 19, 8, 160, 153, 70, 105, 157, 60, 17, 7, 108, 198, 70, 188, 9, 21, 47, 134, 158, 243, 70, 132, 104, 50, 105, 181, 42, 33, 71, 231, 54, 24, 120, 189, 10, 78, 71, 10, 48, 21, 201, 101, 73, 122, 71, 9, 138, 242, 15, 57, 0, 167, 71, 200, 56, 244, 237, 49, 32, 212, 71, 175, 177, 53, 176, 43, 156, 1, 72, 242, 246, 93, 116, 76, 209, 46, 72, 20, 56, 210, 229, 34, 247, 90, 72, 18, 241, 23, 137, 62, 152, 135, 72, 240, 242, 244, 183, 54, 165, 180, 72, 146, 84, 246, 224, 143, 16, 226, 72, 0, 20, 175, 201, 251, 156, 15, 73, 128, 49, 121, 80, 92, 169, 59, 73, 80, 11, 106, 198, 48, 52, 104, 73, 230, 201, 156, 173, 170, 45, 149, 73, 169, 48, 233, 87, 245, 135, 194, 73, 148, 10, 236, 172, 246, 54, 240, 73, 131, 18, 157, 174, 47, 96, 28, 74, 51, 112, 201, 184, 41, 212, 72, 74, 45, 66, 176, 129, 164, 185, 117, 74, 231, 57, 122, 241, 111, 2, 163, 74, 170, 242, 74, 243, 33, 162, 208, 74, 170, 40, 195, 105, 187, 27, 253, 74, 149, 195, 138, 252, 67, 120, 41, 75, 34, 107, 249, 124, 59, 73, 86, 75, 190, 61, 90, 13, 20, 128, 131, 75, 6, 246, 174, 139, 17, 16, 177, 75, 138, 46, 114, 180, 30, 220, 221, 75, 185, 232, 227, 221, 154, 32, 10, 76, 162, 107, 39, 130, 135, 220, 54, 76, 46, 126, 226, 145, 246, 0, 100, 76, 104, 46, 166, 191, 215, 128, 145, 76, 54, 209, 98, 143, 121, 161, 190, 76, 15, 119, 118, 93, 74, 205, 234, 76, 45, 168, 199, 17, 161, 115, 23, 77, 39, 179, 142, 239, 44, 133, 68, 77, 194, 220, 156, 81, 135, 244, 113, 77, 84, 130, 210, 206, 236, 107, 159, 77, 10, 50, 248, 52, 111, 126, 203, 77, 201, 43, 89, 78, 161, 14, 248, 77, 80, 6, 142, 36, 205, 12, 37, 78, 134, 69, 252, 127, 51, 107, 82, 78, 213, 188, 252, 15, 205, 29, 128, 78, 117, 74, 250, 219, 38, 52, 172, 78, 38, 1, 123, 0, 162, 173, 216, 78, 1, 161, 107, 192, 237, 151, 5, 79, 225, 44, 94, 8, 240, 228, 50, 79, 69, 103, 82, 7, 82, 136, 96, 79, 185, 52, 208, 140, 143, 238, 140, 79, 34, 46, 54, 155, 189, 80, 185, 79, 94, 104, 207, 231, 165, 38, 230, 79, 82, 123, 213, 42, 209, 97, 19, 80, 232, 203, 122, 5, 151, 245, 64, 80, 214, 228, 150, 73, 200, 173, 109, 80, 59, 8, 100, 64, 15, 248, 153, 80, 52, 135, 87, 88, 13, 185, 198, 80, 78, 150, 76, 173, 235, 225, 243, 80, 132, 3, 163, 55, 174, 101, 33, 81, 0, 0, 0, 0, 0, 0, 248, 127);
+captured[26] = (new TypeError("unsupported type for structured data", "js1_8_5/extensions/clone-v1-typed-array.js", 19));
+captured[27] = serialize(0); captured[27].clonebuffer = String.fromCharCode(0, 0, 0, 0, 8, 1, 255, 255);
+captured[28] = serialize(0); captured[28].clonebuffer = String.fromCharCode(100, 0, 0, 0, 8, 1, 255, 255, 1, 7, 49, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0);
+captured[29] = (new TypeError("unsupported type for structured data", "js1_8_5/extensions/clone-v1-typed-array.js", 19));
+captured[30] = serialize(0); captured[30].clonebuffer = String.fromCharCode(0, 0, 0, 0, 7, 0, 255, 255, 0, 0, 0, 0, 3, 0, 255, 255, 3, 0, 0, 0, 0, 1, 255, 255, 0, 1, 2, 0, 0, 0, 0, 0, 1, 0, 0, 0, 3, 0, 255, 255, 3, 0, 0, 0, 0, 1, 255, 255, 1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255);
diff --git a/js/src/tests/js1_8_5/extensions/clone-v1-typed-array.js b/js/src/tests/js1_8_5/extensions/clone-v1-typed-array.js
new file mode 100644
index 000000000..e8ba16355
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/clone-v1-typed-array.js
@@ -0,0 +1,130 @@
+// |reftest| skip-if(!xulRuntime.shell)
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+// This file is a copy of clone-typed-array.js from before v2 structured clone
+// was implemented. If you run this test under a v1-writing engine with the
+// environment variable JS_RECORD_RESULTS set, then it will output a log of
+// structured clone buffers resulting from running this test. You can then use
+// that log as input to another run of this same test on a newer engine, to
+// verify that older-format structured clone data can be deserialized properly.
+
+var old_serialize = serialize;
+var captured = [];
+
+if (os.getenv("JS_RECORD_RESULTS") !== undefined) {
+ serialize = function(o) {
+ var data;
+ try {
+ data = old_serialize(o);
+ captured.push(data);
+ return data;
+ } catch(e) {
+ captured.push(e);
+ throw(e);
+ }
+ };
+} else {
+ loadRelativeToScript("clone-v1-typed-array-data.dat");
+ serialize = function(d) {
+ var data = captured.shift();
+ if (data instanceof Error)
+ throw(data);
+ else
+ return data;
+ };
+}
+
+function assertArraysEqual(a, b) {
+ assertEq(a.constructor, b.constructor);
+ assertEq(a.length, b.length);
+ for (var i = 0; i < a.length; i++)
+ assertEq(a[i], b[i]);
+}
+
+function check(b) {
+ var a = deserialize(serialize(b));
+ assertArraysEqual(a, b);
+}
+
+function checkPrototype(ctor) {
+ var threw = false;
+ try {
+ serialize(ctor.prototype);
+ throw new Error("serializing " + ctor.name + ".prototype should throw a TypeError");
+ } catch (exc) {
+ if (!(exc instanceof TypeError))
+ throw exc;
+ }
+}
+
+function test() {
+ // Test cloning ArrayBuffer objects.
+ check(new ArrayBuffer(0));
+ check(new ArrayBuffer(7));
+ checkPrototype(ArrayBuffer);
+
+ // Test cloning typed array objects.
+ var ctors = [
+ Int8Array,
+ Uint8Array,
+ Int16Array,
+ Uint16Array,
+ Int32Array,
+ Uint32Array,
+ Float32Array,
+ Float64Array,
+ Uint8ClampedArray];
+
+ var b;
+ for (var i = 0; i < ctors.length; i++) {
+ var ctor = ctors[i];
+
+ // check empty array
+ b = new ctor(0);
+ check(b);
+
+ // check array with some elements
+ b = new ctor(100);
+ var v = 1;
+ for (var j = 0; j < 100; j++) {
+ b[j] = v;
+ v *= 7;
+ }
+ b[99] = NaN; // check serializing NaNs too
+ check(b);
+
+ // try the prototype
+ checkPrototype(ctor);
+ }
+
+ // Cloning should separately copy two TypedArrays backed by the same
+ // ArrayBuffer. This also tests cloning TypedArrays where the arr->data
+ // pointer is not 8-byte-aligned.
+
+ var base = new Int8Array([0, 1, 2, 3]);
+ b = [new Int8Array(base.buffer, 0, 3), new Int8Array(base.buffer, 1, 3)];
+ var a = deserialize(serialize(b));
+ base[1] = -1;
+ a[0][2] = -2;
+ assertArraysEqual(b[0], new Int8Array([0, -1, 2])); // shared with base
+ assertArraysEqual(b[1], new Int8Array([-1, 2, 3])); // shared with base
+ assertArraysEqual(a[0], new Int8Array([0, 1, -2])); // not shared with base
+ assertArraysEqual(a[1], new Int8Array([1, 2, 3])); // not shared with base or a[0]
+}
+
+test();
+reportCompare(0, 0, 'ok');
+
+if (os.getenv("JS_RECORD_RESULTS") !== undefined) {
+ print("var captured = [];");
+ for (var i in captured) {
+ var s = "captured[" + i + "] = ";
+ if (captured[i] instanceof Error) {
+ print(s + captured[i].toSource() + ";");
+ } else {
+ data = captured[i].clonebuffer.split('').map(c => c.charCodeAt(0));
+ print(s + "serialize(0); captured[" + i + "].clonebuffer = String.fromCharCode(" + data.join(", ") + ");");
+ }
+ }
+}
diff --git a/js/src/tests/js1_8_5/extensions/column-numbers.js b/js/src/tests/js1_8_5/extensions/column-numbers.js
new file mode 100644
index 000000000..721b05e9f
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/column-numbers.js
@@ -0,0 +1,10 @@
+actual = 'No Error';
+expected = /column-numbers\.js:4:11/;
+try {
+ throw new Error("test");
+}
+catch(ex) {
+ actual = ex.stack;
+ print('Caught exception ' + ex.stack);
+}
+reportMatch(expected, actual, 'column number present');
diff --git a/js/src/tests/js1_8_5/extensions/dataview.js b/js/src/tests/js1_8_5/extensions/dataview.js
new file mode 100644
index 000000000..dd36e0991
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/dataview.js
@@ -0,0 +1,1635 @@
+// |reftest| skip-if(!xulRuntime.shell)
+/*
+ * Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/licenses/publicdomain/
+ * Contributor: Tobias Schneider <schneider@jancona.com>
+ */
+
+//------------------------------------------------------------------------------
+var BUGNUMBER = 575688;
+var summary = 'DataView tests';
+
+function test() {
+ function die(message, uplevel) {
+ var e = new Error(message);
+ var frame = e.stack.split("\n")[uplevel];
+ print(message + " at " + frame.split("@")[1]);
+ print("Stack:\n" + e.stack);
+ throw(e);
+ }
+
+ function checkThrow(fun, type) {
+ var thrown = false;
+ try {
+ fun();
+ } catch (x) {
+ thrown = x;
+ }
+
+ if (!thrown) {
+ die('no exception thrown, expected ' + type.name, 2);
+ } else if (!(thrown instanceof type)) {
+ die('expected ' + type.name + ', got ' + thrown, 2);
+ }
+ }
+
+ function checkThrowTODO(fun, type) {
+ var thrown = false;
+ try {
+ fun();
+ } catch (x) {
+ thrown = x;
+ }
+
+ if (!thrown) {
+ print('(TODO) no exception thrown, expected ' + type.name);
+ } else if (!(thrown instanceof type)) {
+ print('(TODO) expected ' + type.name + ', got ' + thrown);
+ } else {
+ print('test unexpectedly passed: expected ' + type.name + ' exception');
+ }
+ }
+
+ enterFunc ('test');
+ printBugNumber(BUGNUMBER);
+ printStatus(summary);
+
+ // testConstructor
+ buffer = (new Uint8Array([1, 2])).buffer;
+ checkThrow(() => new DataView(buffer, 0, 3), RangeError);
+ checkThrow(() => new DataView(buffer, 1, 2), RangeError);
+ checkThrow(() => new DataView(buffer, 2, 1), RangeError);
+ checkThrow(() => new DataView(buffer, 2147483649, 0), RangeError);
+ checkThrow(() => new DataView(buffer, 0, 2147483649), RangeError);
+ checkThrow(() => new DataView(), TypeError);
+ checkThrow(() => new DataView(Object.create(new ArrayBuffer(5))), TypeError);
+
+ // testGetMethods
+
+ // testIntegerGets(start=0, length=16)
+ var data1 = [0,1,2,3,0x64,0x65,0x66,0x67,0x80,0x81,0x82,0x83,252,253,254,255];
+ var data1_r = data1.slice().reverse();
+ var buffer1 = new Uint8Array(data1).buffer;
+ var view1 = new DataView(buffer1, 0, 16);
+ view = view1;
+ assertEq(view.getInt8(0), 0);
+ assertEq(view.getInt8(8), -128);
+ assertEq(view.getInt8(15), -1);
+ assertEq(view.getUint8(0), 0);
+ assertEq(view.getUint8(8), 128);
+ assertEq(view.getUint8(15), 255);
+ // Little endian.
+ assertEq(view.getInt16(0, true), 256);
+ assertEq(view.getInt16(5, true), 0x6665);
+ assertEq(view.getInt16(9, true), -32127);
+ assertEq(view.getInt16(14, true), -2);
+ // Big endian.
+ assertEq(view.getInt16(0), 1);
+ assertEq(view.getInt16(5), 0x6566);
+ assertEq(view.getInt16(9), -32382);
+ assertEq(view.getInt16(14), -257);
+ // Little endian.
+ assertEq(view.getUint16(0, true), 256);
+ assertEq(view.getUint16(5, true), 0x6665);
+ assertEq(view.getUint16(9, true), 0x8281);
+ assertEq(view.getUint16(14, true), 0xfffe);
+ // Big endian.
+ assertEq(view.getUint16(0), 1);
+ assertEq(view.getUint16(5), 0x6566);
+ assertEq(view.getUint16(9), 0x8182);
+ assertEq(view.getUint16(14), 0xfeff);
+ // Little endian.
+ assertEq(view.getInt32(0, true), 0x3020100);
+ assertEq(view.getInt32(3, true), 0x66656403);
+ assertEq(view.getInt32(6, true), -2122291354);
+ assertEq(view.getInt32(9, true), -58490239);
+ assertEq(view.getInt32(12, true), -66052);
+ // Big endian.
+ assertEq(view.getInt32(0), 0x10203);
+ assertEq(view.getInt32(3), 0x3646566);
+ assertEq(view.getInt32(6), 0x66678081);
+ assertEq(view.getInt32(9), -2122152964);
+ assertEq(view.getInt32(12), -50462977);
+ // Little endian.
+ assertEq(view.getUint32(0, true), 0x3020100);
+ assertEq(view.getUint32(3, true), 0x66656403);
+ assertEq(view.getUint32(6, true), 0x81806766);
+ assertEq(view.getUint32(9, true), 0xfc838281);
+ assertEq(view.getUint32(12, true), 0xfffefdfc);
+ // Big endian.
+ assertEq(view.getUint32(0), 0x10203);
+ assertEq(view.getUint32(3), 0x3646566);
+ assertEq(view.getUint32(6), 0x66678081);
+ assertEq(view.getUint32(9), 0x818283fc);
+ assertEq(view.getUint32(12), 0xfcfdfeff);
+
+ // testFloatGets(start=0)
+
+ // testFloatGet expected=10
+ // Little endian
+ var data2 = [0,0,32,65];
+ var data2_r = data2.slice().reverse();
+ var buffer2 = new Uint8Array(data2).buffer;
+ view = new DataView(buffer2, 0, 4);
+ assertEq(view.getFloat32(0, true), 10);
+ var buffer2_pad3 = new Uint8Array(Array(3).concat(data2)).buffer;
+ view = new DataView(buffer2_pad3, 0, 7);
+ assertEq(view.getFloat32(3, true), 10);
+ var buffer2_pad7 = new Uint8Array(Array(7).concat(data2)).buffer;
+ view = new DataView(buffer2_pad7, 0, 11);
+ assertEq(view.getFloat32(7, true), 10);
+ var buffer2_pad10 = new Uint8Array(Array(10).concat(data2)).buffer;
+ view = new DataView(buffer2_pad10, 0, 14);
+ assertEq(view.getFloat32(10, true), 10);
+ // Big endian.
+ var buffer2_r = new Uint8Array(data2_r).buffer;
+ view = new DataView(buffer2_r, 0, 4);
+ assertEq(view.getFloat32(0, false), 10);
+ var buffer2_r_pad3 = new Uint8Array(Array(3).concat(data2_r)).buffer;
+ view = new DataView(buffer2_r_pad3, 0, 7);
+ assertEq(view.getFloat32(3, false), 10);
+ var buffer2_r_pad7 = new Uint8Array(Array(7).concat(data2_r)).buffer;
+ view = new DataView(buffer2_r_pad7, 0, 11);
+ assertEq(view.getFloat32(7, false), 10);
+ var buffer2_r_pad10 = new Uint8Array(Array(10).concat(data2_r)).buffer;
+ view = new DataView(buffer2_r_pad10, 0, 14);
+ assertEq(view.getFloat32(10, false), 10);
+
+ // testFloatGet expected=1.2300000190734863
+ // Little endian
+ var data3 = [164,112,157,63];
+ var data3_r = data3.slice().reverse();
+ var buffer3 = new Uint8Array(data3).buffer;
+ view = new DataView(buffer3, 0, 4);
+ assertEq(view.getFloat32(0, true), 1.2300000190734863);
+ var buffer3_pad3 = new Uint8Array(Array(3).concat(data3)).buffer;
+ view = new DataView(buffer3_pad3, 0, 7);
+ assertEq(view.getFloat32(3, true), 1.2300000190734863);
+ var buffer3_pad7 = new Uint8Array(Array(7).concat(data3)).buffer;
+ view = new DataView(buffer3_pad7, 0, 11);
+ assertEq(view.getFloat32(7, true), 1.2300000190734863);
+ var buffer3_pad10 = new Uint8Array(Array(10).concat(data3)).buffer;
+ view = new DataView(buffer3_pad10, 0, 14);
+ assertEq(view.getFloat32(10, true), 1.2300000190734863);
+ // Big endian.
+ var buffer3_r = new Uint8Array(data3_r).buffer;
+ view = new DataView(buffer3_r, 0, 4);
+ assertEq(view.getFloat32(0, false), 1.2300000190734863);
+ var buffer3_r_pad3 = new Uint8Array(Array(3).concat(data3_r)).buffer;
+ view = new DataView(buffer3_r_pad3, 0, 7);
+ assertEq(view.getFloat32(3, false), 1.2300000190734863);
+ var buffer3_r_pad7 = new Uint8Array(Array(7).concat(data3_r)).buffer;
+ view = new DataView(buffer3_r_pad7, 0, 11);
+ assertEq(view.getFloat32(7, false), 1.2300000190734863);
+ var buffer3_r_pad10 = new Uint8Array(Array(10).concat(data3_r)).buffer;
+ view = new DataView(buffer3_r_pad10, 0, 14);
+ assertEq(view.getFloat32(10, false), 1.2300000190734863);
+
+ // testFloatGet expected=-45621.37109375
+ // Little endian
+ var data4 = [95,53,50,199];
+ var data4_r = data4.slice().reverse();
+ var buffer4 = new Uint8Array(data4).buffer;
+ view = new DataView(buffer4, 0, 4);
+ assertEq(view.getFloat32(0, true), -45621.37109375);
+ var buffer4_pad3 = new Uint8Array(Array(3).concat(data4)).buffer;
+ view = new DataView(buffer4_pad3, 0, 7);
+ assertEq(view.getFloat32(3, true), -45621.37109375);
+ var buffer4_pad7 = new Uint8Array(Array(7).concat(data4)).buffer;
+ view = new DataView(buffer4_pad7, 0, 11);
+ assertEq(view.getFloat32(7, true), -45621.37109375);
+ var buffer4_pad10 = new Uint8Array(Array(10).concat(data4)).buffer;
+ view = new DataView(buffer4_pad10, 0, 14);
+ assertEq(view.getFloat32(10, true), -45621.37109375);
+ // Big endian.
+ var buffer4_r = new Uint8Array(data4_r).buffer;
+ view = new DataView(buffer4_r, 0, 4);
+ assertEq(view.getFloat32(0, false), -45621.37109375);
+ var buffer4_r_pad3 = new Uint8Array(Array(3).concat(data4_r)).buffer;
+ view = new DataView(buffer4_r_pad3, 0, 7);
+ assertEq(view.getFloat32(3, false), -45621.37109375);
+ var buffer4_r_pad7 = new Uint8Array(Array(7).concat(data4_r)).buffer;
+ view = new DataView(buffer4_r_pad7, 0, 11);
+ assertEq(view.getFloat32(7, false), -45621.37109375);
+ var buffer4_r_pad10 = new Uint8Array(Array(10).concat(data4_r)).buffer;
+ view = new DataView(buffer4_r_pad10, 0, 14);
+ assertEq(view.getFloat32(10, false), -45621.37109375);
+
+ // testFloatGet expected=NaN
+ // Little endian
+ var data5 = [255,255,255,127];
+ var data5_r = data5.slice().reverse();
+ var buffer5 = new Uint8Array(data5).buffer;
+ view = new DataView(buffer5, 0, 4);
+ assertEq(view.getFloat32(0, true), NaN);
+ var buffer5_pad3 = new Uint8Array(Array(3).concat(data5)).buffer;
+ view = new DataView(buffer5_pad3, 0, 7);
+ assertEq(view.getFloat32(3, true), NaN);
+ var buffer5_pad7 = new Uint8Array(Array(7).concat(data5)).buffer;
+ view = new DataView(buffer5_pad7, 0, 11);
+ assertEq(view.getFloat32(7, true), NaN);
+ var buffer5_pad10 = new Uint8Array(Array(10).concat(data5)).buffer;
+ view = new DataView(buffer5_pad10, 0, 14);
+ assertEq(view.getFloat32(10, true), NaN);
+ // Big endian.
+ var buffer5_r = new Uint8Array(data5_r).buffer;
+ view = new DataView(buffer5_r, 0, 4);
+ assertEq(view.getFloat32(0, false), NaN);
+ var buffer5_r_pad3 = new Uint8Array(Array(3).concat(data5_r)).buffer;
+ view = new DataView(buffer5_r_pad3, 0, 7);
+ assertEq(view.getFloat32(3, false), NaN);
+ var buffer5_r_pad7 = new Uint8Array(Array(7).concat(data5_r)).buffer;
+ view = new DataView(buffer5_r_pad7, 0, 11);
+ assertEq(view.getFloat32(7, false), NaN);
+ var buffer5_r_pad10 = new Uint8Array(Array(10).concat(data5_r)).buffer;
+ view = new DataView(buffer5_r_pad10, 0, 14);
+ assertEq(view.getFloat32(10, false), NaN);
+
+ // testFloatGet expected=NaN
+ // Little endian
+ var data6 = [255,255,255,255];
+ var data6_r = data6.slice().reverse();
+ var buffer6 = new Uint8Array(data6).buffer;
+ view = new DataView(buffer6, 0, 4);
+ assertEq(view.getFloat32(0, true), NaN);
+ var buffer6_pad3 = new Uint8Array(Array(3).concat(data6)).buffer;
+ view = new DataView(buffer6_pad3, 0, 7);
+ assertEq(view.getFloat32(3, true), NaN);
+ var buffer6_pad7 = new Uint8Array(Array(7).concat(data6)).buffer;
+ view = new DataView(buffer6_pad7, 0, 11);
+ assertEq(view.getFloat32(7, true), NaN);
+ var buffer6_pad10 = new Uint8Array(Array(10).concat(data6)).buffer;
+ view = new DataView(buffer6_pad10, 0, 14);
+ assertEq(view.getFloat32(10, true), NaN);
+ // Big endian.
+ var buffer6_r = new Uint8Array(data6_r).buffer;
+ view = new DataView(buffer6_r, 0, 4);
+ assertEq(view.getFloat32(0, false), NaN);
+ var buffer6_r_pad3 = new Uint8Array(Array(3).concat(data6_r)).buffer;
+ view = new DataView(buffer6_r_pad3, 0, 7);
+ assertEq(view.getFloat32(3, false), NaN);
+ var buffer6_r_pad7 = new Uint8Array(Array(7).concat(data6_r)).buffer;
+ view = new DataView(buffer6_r_pad7, 0, 11);
+ assertEq(view.getFloat32(7, false), NaN);
+ var buffer6_r_pad10 = new Uint8Array(Array(10).concat(data6_r)).buffer;
+ view = new DataView(buffer6_r_pad10, 0, 14);
+ assertEq(view.getFloat32(10, false), NaN);
+
+ // testFloatGet expected=10
+ // Little endian
+ var data7 = [0,0,0,0,0,0,36,64];
+ var data7_r = data7.slice().reverse();
+ var buffer7 = new Uint8Array(data7).buffer;
+ view = new DataView(buffer7, 0, 8);
+ assertEq(view.getFloat64(0, true), 10);
+ var buffer7_pad3 = new Uint8Array(Array(3).concat(data7)).buffer;
+ view = new DataView(buffer7_pad3, 0, 11);
+ assertEq(view.getFloat64(3, true), 10);
+ var buffer7_pad7 = new Uint8Array(Array(7).concat(data7)).buffer;
+ view = new DataView(buffer7_pad7, 0, 15);
+ assertEq(view.getFloat64(7, true), 10);
+ var buffer7_pad10 = new Uint8Array(Array(10).concat(data7)).buffer;
+ view = new DataView(buffer7_pad10, 0, 18);
+ assertEq(view.getFloat64(10, true), 10);
+ // Big endian.
+ var buffer7_r = new Uint8Array(data7_r).buffer;
+ view = new DataView(buffer7_r, 0, 8);
+ assertEq(view.getFloat64(0, false), 10);
+ var buffer7_r_pad3 = new Uint8Array(Array(3).concat(data7_r)).buffer;
+ view = new DataView(buffer7_r_pad3, 0, 11);
+ assertEq(view.getFloat64(3, false), 10);
+ var buffer7_r_pad7 = new Uint8Array(Array(7).concat(data7_r)).buffer;
+ view = new DataView(buffer7_r_pad7, 0, 15);
+ assertEq(view.getFloat64(7, false), 10);
+ var buffer7_r_pad10 = new Uint8Array(Array(10).concat(data7_r)).buffer;
+ view = new DataView(buffer7_r_pad10, 0, 18);
+ assertEq(view.getFloat64(10, false), 10);
+
+ // testFloatGet expected=1.23
+ // Little endian
+ var data8 = [174,71,225,122,20,174,243,63];
+ var data8_r = data8.slice().reverse();
+ var buffer8 = new Uint8Array(data8).buffer;
+ view = new DataView(buffer8, 0, 8);
+ assertEq(view.getFloat64(0, true), 1.23);
+ var buffer8_pad3 = new Uint8Array(Array(3).concat(data8)).buffer;
+ view = new DataView(buffer8_pad3, 0, 11);
+ assertEq(view.getFloat64(3, true), 1.23);
+ var buffer8_pad7 = new Uint8Array(Array(7).concat(data8)).buffer;
+ view = new DataView(buffer8_pad7, 0, 15);
+ assertEq(view.getFloat64(7, true), 1.23);
+ var buffer8_pad10 = new Uint8Array(Array(10).concat(data8)).buffer;
+ view = new DataView(buffer8_pad10, 0, 18);
+ assertEq(view.getFloat64(10, true), 1.23);
+ // Big endian.
+ var buffer8_r = new Uint8Array(data8_r).buffer;
+ view = new DataView(buffer8_r, 0, 8);
+ assertEq(view.getFloat64(0, false), 1.23);
+ var buffer8_r_pad3 = new Uint8Array(Array(3).concat(data8_r)).buffer;
+ view = new DataView(buffer8_r_pad3, 0, 11);
+ assertEq(view.getFloat64(3, false), 1.23);
+ var buffer8_r_pad7 = new Uint8Array(Array(7).concat(data8_r)).buffer;
+ view = new DataView(buffer8_r_pad7, 0, 15);
+ assertEq(view.getFloat64(7, false), 1.23);
+ var buffer8_r_pad10 = new Uint8Array(Array(10).concat(data8_r)).buffer;
+ view = new DataView(buffer8_r_pad10, 0, 18);
+ assertEq(view.getFloat64(10, false), 1.23);
+
+ // testFloatGet expected=-6213576.4839
+ // Little endian
+ var data9 = [181,55,248,30,242,179,87,193];
+ var data9_r = data9.slice().reverse();
+ var buffer9 = new Uint8Array(data9).buffer;
+ view = new DataView(buffer9, 0, 8);
+ assertEq(view.getFloat64(0, true), -6213576.4839);
+ var buffer9_pad3 = new Uint8Array(Array(3).concat(data9)).buffer;
+ view = new DataView(buffer9_pad3, 0, 11);
+ assertEq(view.getFloat64(3, true), -6213576.4839);
+ var buffer9_pad7 = new Uint8Array(Array(7).concat(data9)).buffer;
+ view = new DataView(buffer9_pad7, 0, 15);
+ assertEq(view.getFloat64(7, true), -6213576.4839);
+ var buffer9_pad10 = new Uint8Array(Array(10).concat(data9)).buffer;
+ view = new DataView(buffer9_pad10, 0, 18);
+ assertEq(view.getFloat64(10, true), -6213576.4839);
+ // Big endian.
+ var buffer9_r = new Uint8Array(data9_r).buffer;
+ view = new DataView(buffer9_r, 0, 8);
+ assertEq(view.getFloat64(0, false), -6213576.4839);
+ var buffer9_r_pad3 = new Uint8Array(Array(3).concat(data9_r)).buffer;
+ view = new DataView(buffer9_r_pad3, 0, 11);
+ assertEq(view.getFloat64(3, false), -6213576.4839);
+ var buffer9_r_pad7 = new Uint8Array(Array(7).concat(data9_r)).buffer;
+ view = new DataView(buffer9_r_pad7, 0, 15);
+ assertEq(view.getFloat64(7, false), -6213576.4839);
+ var buffer9_r_pad10 = new Uint8Array(Array(10).concat(data9_r)).buffer;
+ view = new DataView(buffer9_r_pad10, 0, 18);
+ assertEq(view.getFloat64(10, false), -6213576.4839);
+
+ // testFloatGet expected=NaN
+ // Little endian
+ var data10 = [255,255,255,255,255,255,255,127];
+ var data10_r = data10.slice().reverse();
+ var buffer10 = new Uint8Array(data10).buffer;
+ view = new DataView(buffer10, 0, 8);
+ assertEq(view.getFloat64(0, true), NaN);
+ var buffer10_pad3 = new Uint8Array(Array(3).concat(data10)).buffer;
+ view = new DataView(buffer10_pad3, 0, 11);
+ assertEq(view.getFloat64(3, true), NaN);
+ var buffer10_pad7 = new Uint8Array(Array(7).concat(data10)).buffer;
+ view = new DataView(buffer10_pad7, 0, 15);
+ assertEq(view.getFloat64(7, true), NaN);
+ var buffer10_pad10 = new Uint8Array(Array(10).concat(data10)).buffer;
+ view = new DataView(buffer10_pad10, 0, 18);
+ assertEq(view.getFloat64(10, true), NaN);
+ // Big endian.
+ var buffer10_r = new Uint8Array(data10_r).buffer;
+ view = new DataView(buffer10_r, 0, 8);
+ assertEq(view.getFloat64(0, false), NaN);
+ var buffer10_r_pad3 = new Uint8Array(Array(3).concat(data10_r)).buffer;
+ view = new DataView(buffer10_r_pad3, 0, 11);
+ assertEq(view.getFloat64(3, false), NaN);
+ var buffer10_r_pad7 = new Uint8Array(Array(7).concat(data10_r)).buffer;
+ view = new DataView(buffer10_r_pad7, 0, 15);
+ assertEq(view.getFloat64(7, false), NaN);
+ var buffer10_r_pad10 = new Uint8Array(Array(10).concat(data10_r)).buffer;
+ view = new DataView(buffer10_r_pad10, 0, 18);
+ assertEq(view.getFloat64(10, false), NaN);
+
+ // testFloatGet expected=NaN
+ // Little endian
+ var data11 = [255,255,255,255,255,255,255,255];
+ var data11_r = data11.slice().reverse();
+ var buffer11 = new Uint8Array(data11).buffer;
+ view = new DataView(buffer11, 0, 8);
+ assertEq(view.getFloat64(0, true), NaN);
+ var buffer11_pad3 = new Uint8Array(Array(3).concat(data11)).buffer;
+ view = new DataView(buffer11_pad3, 0, 11);
+ assertEq(view.getFloat64(3, true), NaN);
+ var buffer11_pad7 = new Uint8Array(Array(7).concat(data11)).buffer;
+ view = new DataView(buffer11_pad7, 0, 15);
+ assertEq(view.getFloat64(7, true), NaN);
+ var buffer11_pad10 = new Uint8Array(Array(10).concat(data11)).buffer;
+ view = new DataView(buffer11_pad10, 0, 18);
+ assertEq(view.getFloat64(10, true), NaN);
+ // Big endian.
+ var buffer11_r = new Uint8Array(data11_r).buffer;
+ view = new DataView(buffer11_r, 0, 8);
+ assertEq(view.getFloat64(0, false), NaN);
+ var buffer11_r_pad3 = new Uint8Array(Array(3).concat(data11_r)).buffer;
+ view = new DataView(buffer11_r_pad3, 0, 11);
+ assertEq(view.getFloat64(3, false), NaN);
+ var buffer11_r_pad7 = new Uint8Array(Array(7).concat(data11_r)).buffer;
+ view = new DataView(buffer11_r_pad7, 0, 15);
+ assertEq(view.getFloat64(7, false), NaN);
+ var buffer11_r_pad10 = new Uint8Array(Array(10).concat(data11_r)).buffer;
+ view = new DataView(buffer11_r_pad10, 0, 18);
+ assertEq(view.getFloat64(10, false), NaN);
+
+ // testIntegerGets(start=3, length=2)
+ var data12 = [31,32,33,0,1,2,3,100,101,102,103,128,129,130,131,252,253,254,255];
+ var data12_r = data12.slice().reverse();
+ var buffer12 = new Uint8Array(data12).buffer;
+ view = new DataView(buffer12, 3, 2);
+ assertEq(view.getInt8(0), 0);
+ checkThrow(() => view.getInt8(8), RangeError);
+ checkThrow(() => view.getInt8(15), RangeError);
+ assertEq(view.getUint8(0), 0);
+ checkThrow(() => view.getUint8(8), RangeError);
+ checkThrow(() => view.getUint8(15), RangeError);
+ // Little endian.
+ assertEq(view.getInt16(0, true), 256);
+ checkThrow(() => view.getInt16(5, true), RangeError);
+ checkThrow(() => view.getInt16(9, true), RangeError);
+ checkThrow(() => view.getInt16(14, true), RangeError);
+ // Big endian.
+ assertEq(view.getInt16(0), 1);
+ checkThrow(() => view.getInt16(5), RangeError);
+ checkThrow(() => view.getInt16(9), RangeError);
+ checkThrow(() => view.getInt16(14), RangeError);
+ // Little endian.
+ assertEq(view.getUint16(0, true), 256);
+ checkThrow(() => view.getUint16(5, true), RangeError);
+ checkThrow(() => view.getUint16(9, true), RangeError);
+ checkThrow(() => view.getUint16(14, true), RangeError);
+ // Big endian.
+ assertEq(view.getUint16(0), 1);
+ checkThrow(() => view.getUint16(5), RangeError);
+ checkThrow(() => view.getUint16(9), RangeError);
+ checkThrow(() => view.getUint16(14), RangeError);
+ // Little endian.
+ checkThrow(() => view.getInt32(0, true), RangeError);
+ checkThrow(() => view.getInt32(3, true), RangeError);
+ checkThrow(() => view.getInt32(6, true), RangeError);
+ checkThrow(() => view.getInt32(9, true), RangeError);
+ checkThrow(() => view.getInt32(12, true), RangeError);
+ // Big endian.
+ checkThrow(() => view.getInt32(0), RangeError);
+ checkThrow(() => view.getInt32(3), RangeError);
+ checkThrow(() => view.getInt32(6), RangeError);
+ checkThrow(() => view.getInt32(9), RangeError);
+ checkThrow(() => view.getInt32(12), RangeError);
+ // Little endian.
+ checkThrow(() => view.getUint32(0, true), RangeError);
+ checkThrow(() => view.getUint32(3, true), RangeError);
+ checkThrow(() => view.getUint32(6, true), RangeError);
+ checkThrow(() => view.getUint32(9, true), RangeError);
+ checkThrow(() => view.getUint32(12, true), RangeError);
+ // Big endian.
+ checkThrow(() => view.getUint32(0), RangeError);
+ checkThrow(() => view.getUint32(3), RangeError);
+ checkThrow(() => view.getUint32(6), RangeError);
+ checkThrow(() => view.getUint32(9), RangeError);
+ checkThrow(() => view.getUint32(12), RangeError);
+
+ // testFloatGets(start=3)
+
+ // testFloatGet expected=10
+ // Little endian
+ view = new DataView(buffer2, 3, 1);
+ checkThrow(() => view.getFloat32(0, true), RangeError);
+ view = new DataView(buffer2_pad3, 3, 4);
+ checkThrow(() => view.getFloat32(3, true), RangeError);
+ view = new DataView(buffer2_pad7, 3, 8);
+ checkThrow(() => view.getFloat32(7, true), RangeError);
+ view = new DataView(buffer2_pad10, 3, 11);
+ checkThrow(() => view.getFloat32(10, true), RangeError);
+ // Big endian.
+ view = new DataView(buffer2_r, 3, 1);
+ checkThrow(() => view.getFloat32(0, false), RangeError);
+ view = new DataView(buffer2_r_pad3, 3, 4);
+ checkThrow(() => view.getFloat32(3, false), RangeError);
+ view = new DataView(buffer2_r_pad7, 3, 8);
+ checkThrow(() => view.getFloat32(7, false), RangeError);
+ view = new DataView(buffer2_r_pad10, 3, 11);
+ checkThrow(() => view.getFloat32(10, false), RangeError);
+
+ // testFloatGet expected=1.2300000190734863
+ // Little endian
+ view = new DataView(buffer3, 3, 1);
+ checkThrow(() => view.getFloat32(0, true), RangeError);
+ view = new DataView(buffer3_pad3, 3, 4);
+ checkThrow(() => view.getFloat32(3, true), RangeError);
+ view = new DataView(buffer3_pad7, 3, 8);
+ checkThrow(() => view.getFloat32(7, true), RangeError);
+ view = new DataView(buffer3_pad10, 3, 11);
+ checkThrow(() => view.getFloat32(10, true), RangeError);
+ // Big endian.
+ view = new DataView(buffer3_r, 3, 1);
+ checkThrow(() => view.getFloat32(0, false), RangeError);
+ view = new DataView(buffer3_r_pad3, 3, 4);
+ checkThrow(() => view.getFloat32(3, false), RangeError);
+ view = new DataView(buffer3_r_pad7, 3, 8);
+ checkThrow(() => view.getFloat32(7, false), RangeError);
+ view = new DataView(buffer3_r_pad10, 3, 11);
+ checkThrow(() => view.getFloat32(10, false), RangeError);
+
+ // testFloatGet expected=-45621.37109375
+ // Little endian
+ view = new DataView(buffer4, 3, 1);
+ checkThrow(() => view.getFloat32(0, true), RangeError);
+ view = new DataView(buffer4_pad3, 3, 4);
+ checkThrow(() => view.getFloat32(3, true), RangeError);
+ view = new DataView(buffer4_pad7, 3, 8);
+ checkThrow(() => view.getFloat32(7, true), RangeError);
+ view = new DataView(buffer4_pad10, 3, 11);
+ checkThrow(() => view.getFloat32(10, true), RangeError);
+ // Big endian.
+ view = new DataView(buffer4_r, 3, 1);
+ checkThrow(() => view.getFloat32(0, false), RangeError);
+ view = new DataView(buffer4_r_pad3, 3, 4);
+ checkThrow(() => view.getFloat32(3, false), RangeError);
+ view = new DataView(buffer4_r_pad7, 3, 8);
+ checkThrow(() => view.getFloat32(7, false), RangeError);
+ view = new DataView(buffer4_r_pad10, 3, 11);
+ checkThrow(() => view.getFloat32(10, false), RangeError);
+
+ // testFloatGet expected=NaN
+ // Little endian
+ view = new DataView(buffer5, 3, 1);
+ checkThrow(() => view.getFloat32(0, true), RangeError);
+ view = new DataView(buffer5_pad3, 3, 4);
+ checkThrow(() => view.getFloat32(3, true), RangeError);
+ view = new DataView(buffer5_pad7, 3, 8);
+ checkThrow(() => view.getFloat32(7, true), RangeError);
+ view = new DataView(buffer5_pad10, 3, 11);
+ checkThrow(() => view.getFloat32(10, true), RangeError);
+ // Big endian.
+ view = new DataView(buffer5_r, 3, 1);
+ checkThrow(() => view.getFloat32(0, false), RangeError);
+ view = new DataView(buffer5_r_pad3, 3, 4);
+ checkThrow(() => view.getFloat32(3, false), RangeError);
+ view = new DataView(buffer5_r_pad7, 3, 8);
+ checkThrow(() => view.getFloat32(7, false), RangeError);
+ view = new DataView(buffer5_r_pad10, 3, 11);
+ checkThrow(() => view.getFloat32(10, false), RangeError);
+
+ // testFloatGet expected=NaN
+ // Little endian
+ view = new DataView(buffer6, 3, 1);
+ checkThrow(() => view.getFloat32(0, true), RangeError);
+ view = new DataView(buffer6_pad3, 3, 4);
+ checkThrow(() => view.getFloat32(3, true), RangeError);
+ view = new DataView(buffer6_pad7, 3, 8);
+ checkThrow(() => view.getFloat32(7, true), RangeError);
+ view = new DataView(buffer6_pad10, 3, 11);
+ checkThrow(() => view.getFloat32(10, true), RangeError);
+ // Big endian.
+ view = new DataView(buffer6_r, 3, 1);
+ checkThrow(() => view.getFloat32(0, false), RangeError);
+ view = new DataView(buffer6_r_pad3, 3, 4);
+ checkThrow(() => view.getFloat32(3, false), RangeError);
+ view = new DataView(buffer6_r_pad7, 3, 8);
+ checkThrow(() => view.getFloat32(7, false), RangeError);
+ view = new DataView(buffer6_r_pad10, 3, 11);
+ checkThrow(() => view.getFloat32(10, false), RangeError);
+
+ // testFloatGet expected=10
+ // Little endian
+ view = new DataView(buffer7, 3, 5);
+ checkThrow(() => view.getFloat64(0, true), RangeError);
+ view = new DataView(buffer7_pad3, 3, 8);
+ checkThrow(() => view.getFloat64(3, true), RangeError);
+ view = new DataView(buffer7_pad7, 3, 12);
+ checkThrow(() => view.getFloat64(7, true), RangeError);
+ view = new DataView(buffer7_pad10, 3, 15);
+ checkThrow(() => view.getFloat64(10, true), RangeError);
+ // Big endian.
+ view = new DataView(buffer7_r, 3, 5);
+ checkThrow(() => view.getFloat64(0, false), RangeError);
+ view = new DataView(buffer7_r_pad3, 3, 8);
+ checkThrow(() => view.getFloat64(3, false), RangeError);
+ view = new DataView(buffer7_r_pad7, 3, 12);
+ checkThrow(() => view.getFloat64(7, false), RangeError);
+ view = new DataView(buffer7_r_pad10, 3, 15);
+ checkThrow(() => view.getFloat64(10, false), RangeError);
+
+ // testFloatGet expected=1.23
+ // Little endian
+ view = new DataView(buffer8, 3, 5);
+ checkThrow(() => view.getFloat64(0, true), RangeError);
+ view = new DataView(buffer8_pad3, 3, 8);
+ checkThrow(() => view.getFloat64(3, true), RangeError);
+ view = new DataView(buffer8_pad7, 3, 12);
+ checkThrow(() => view.getFloat64(7, true), RangeError);
+ view = new DataView(buffer8_pad10, 3, 15);
+ checkThrow(() => view.getFloat64(10, true), RangeError);
+ // Big endian.
+ view = new DataView(buffer8_r, 3, 5);
+ checkThrow(() => view.getFloat64(0, false), RangeError);
+ view = new DataView(buffer8_r_pad3, 3, 8);
+ checkThrow(() => view.getFloat64(3, false), RangeError);
+ view = new DataView(buffer8_r_pad7, 3, 12);
+ checkThrow(() => view.getFloat64(7, false), RangeError);
+ view = new DataView(buffer8_r_pad10, 3, 15);
+ checkThrow(() => view.getFloat64(10, false), RangeError);
+
+ // testFloatGet expected=-6213576.4839
+ // Little endian
+ view = new DataView(buffer9, 3, 5);
+ checkThrow(() => view.getFloat64(0, true), RangeError);
+ view = new DataView(buffer9_pad3, 3, 8);
+ checkThrow(() => view.getFloat64(3, true), RangeError);
+ view = new DataView(buffer9_pad7, 3, 12);
+ checkThrow(() => view.getFloat64(7, true), RangeError);
+ view = new DataView(buffer9_pad10, 3, 15);
+ checkThrow(() => view.getFloat64(10, true), RangeError);
+ // Big endian.
+ view = new DataView(buffer9_r, 3, 5);
+ checkThrow(() => view.getFloat64(0, false), RangeError);
+ view = new DataView(buffer9_r_pad3, 3, 8);
+ checkThrow(() => view.getFloat64(3, false), RangeError);
+ view = new DataView(buffer9_r_pad7, 3, 12);
+ checkThrow(() => view.getFloat64(7, false), RangeError);
+ view = new DataView(buffer9_r_pad10, 3, 15);
+ checkThrow(() => view.getFloat64(10, false), RangeError);
+
+ // testFloatGet expected=NaN
+ // Little endian
+ view = new DataView(buffer10, 3, 5);
+ checkThrow(() => view.getFloat64(0, true), RangeError);
+ view = new DataView(buffer10_pad3, 3, 8);
+ checkThrow(() => view.getFloat64(3, true), RangeError);
+ view = new DataView(buffer10_pad7, 3, 12);
+ checkThrow(() => view.getFloat64(7, true), RangeError);
+ view = new DataView(buffer10_pad10, 3, 15);
+ checkThrow(() => view.getFloat64(10, true), RangeError);
+ // Big endian.
+ view = new DataView(buffer10_r, 3, 5);
+ checkThrow(() => view.getFloat64(0, false), RangeError);
+ view = new DataView(buffer10_r_pad3, 3, 8);
+ checkThrow(() => view.getFloat64(3, false), RangeError);
+ view = new DataView(buffer10_r_pad7, 3, 12);
+ checkThrow(() => view.getFloat64(7, false), RangeError);
+ view = new DataView(buffer10_r_pad10, 3, 15);
+ checkThrow(() => view.getFloat64(10, false), RangeError);
+
+ // testFloatGet expected=NaN
+ // Little endian
+ view = new DataView(buffer11, 3, 5);
+ checkThrow(() => view.getFloat64(0, true), RangeError);
+ view = new DataView(buffer11_pad3, 3, 8);
+ checkThrow(() => view.getFloat64(3, true), RangeError);
+ view = new DataView(buffer11_pad7, 3, 12);
+ checkThrow(() => view.getFloat64(7, true), RangeError);
+ view = new DataView(buffer11_pad10, 3, 15);
+ checkThrow(() => view.getFloat64(10, true), RangeError);
+ // Big endian.
+ view = new DataView(buffer11_r, 3, 5);
+ checkThrow(() => view.getFloat64(0, false), RangeError);
+ view = new DataView(buffer11_r_pad3, 3, 8);
+ checkThrow(() => view.getFloat64(3, false), RangeError);
+ view = new DataView(buffer11_r_pad7, 3, 12);
+ checkThrow(() => view.getFloat64(7, false), RangeError);
+ view = new DataView(buffer11_r_pad10, 3, 15);
+ checkThrow(() => view.getFloat64(10, false), RangeError);
+
+ // testGetNegativeIndexes
+ view = new DataView(buffer1, 0, 16);
+ checkThrow(() => view.getInt8(-1), RangeError);
+ checkThrow(() => view.getInt8(-2), RangeError);
+ checkThrow(() => view.getUint8(-1), RangeError);
+ checkThrow(() => view.getUint8(-2), RangeError);
+ checkThrow(() => view.getInt16(-1), RangeError);
+ checkThrow(() => view.getInt16(-2), RangeError);
+ checkThrow(() => view.getInt16(-3), RangeError);
+ checkThrow(() => view.getUint16(-1), RangeError);
+ checkThrow(() => view.getUint16(-2), RangeError);
+ checkThrow(() => view.getUint16(-3), RangeError);
+ checkThrow(() => view.getInt32(-1), RangeError);
+ checkThrow(() => view.getInt32(-3), RangeError);
+ checkThrow(() => view.getInt32(-5), RangeError);
+ checkThrow(() => view.getUint32(-1), RangeError);
+ checkThrow(() => view.getUint32(-3), RangeError);
+ checkThrow(() => view.getUint32(-5), RangeError);
+ view = new DataView(buffer7, 0, 8);
+ checkThrow(() => view.getFloat32(-1), RangeError);
+ checkThrow(() => view.getFloat32(-3), RangeError);
+ checkThrow(() => view.getFloat32(-5), RangeError);
+ checkThrow(() => view.getFloat64(-1), RangeError);
+ checkThrow(() => view.getFloat64(-5), RangeError);
+ checkThrow(() => view.getFloat64(-9), RangeError);
+
+ // Too large for signed 32 bit integer index
+ checkThrow(() => view.getInt8(2147483648), RangeError);
+ checkThrow(() => view.getInt8(2147483649), RangeError);
+ checkThrow(() => view.getUint8(2147483648), RangeError);
+ checkThrow(() => view.getUint8(2147483649), RangeError);
+ checkThrow(() => view.getInt16(2147483648), RangeError);
+ checkThrow(() => view.getInt16(2147483649), RangeError);
+ checkThrow(() => view.getUint16(2147483648), RangeError);
+ checkThrow(() => view.getUint16(2147483649), RangeError);
+ checkThrow(() => view.getInt32(2147483648), RangeError);
+ checkThrow(() => view.getInt32(2147483649), RangeError);
+ checkThrow(() => view.getUint32(2147483648), RangeError);
+ checkThrow(() => view.getUint32(2147483649), RangeError);
+ checkThrow(() => view.getFloat32(2147483648), RangeError);
+ checkThrow(() => view.getFloat32(2147483649), RangeError);
+ checkThrow(() => view.getFloat64(2147483648), RangeError);
+ checkThrow(() => view.getFloat64(2147483649), RangeError);
+
+ // Test for wrong type of |this|
+ checkThrow(() => view.getInt8.apply("dead", [0]), TypeError);
+ checkThrow(() => view.getUint8.apply("puppies", [0]), TypeError);
+ checkThrow(() => view.getInt16.apply("aren", [0]), TypeError);
+ checkThrow(() => view.getUint16.apply("t", [0]), TypeError);
+ checkThrow(() => view.getInt32.apply("much", [0]), TypeError);
+ checkThrow(() => view.getUint32.apply("fun", [0]), TypeError);
+ checkThrow(() => view.getFloat32.apply("(in", [0]), TypeError);
+ checkThrow(() => view.getFloat64.apply("bed)", [0]), TypeError);
+ checkThrow(() => view.setInt8.apply("dead", [0, 0]), TypeError);
+ checkThrow(() => view.setUint8.apply("puppies", [0, 0]), TypeError);
+ checkThrow(() => view.setInt16.apply("aren", [0, 0]), TypeError);
+ checkThrow(() => view.setUint16.apply("t", [0, 0]), TypeError);
+ checkThrow(() => view.setInt32.apply("much", [0, 0]), TypeError);
+ checkThrow(() => view.setUint32.apply("fun", [0, 0]), TypeError);
+ checkThrow(() => view.setFloat32.apply("(in", [0, 0]), TypeError);
+ checkThrow(() => view.setFloat64.apply("bed)", [0, 0]), TypeError);
+
+ // testSetMethods
+
+ // Test for set methods that work
+
+ // testIntegerSets(start=0, length=16)
+ var data13 = [204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204];
+ var data13_r = data13.slice().reverse();
+ var buffer13 = new Uint8Array(data13).buffer;
+ view = new DataView(buffer13, 0, 16);
+ view.setInt8(0, 0);
+ assertEq(view.getInt8(0), 0);
+ view.setInt8(8, -128);
+ assertEq(view.getInt8(8), -128);
+ view.setInt8(15, -1);
+ assertEq(view.getInt8(15), -1);
+ view.setUint8(0, 0);
+ assertEq(view.getUint8(0), 0);
+ view.setUint8(8, 128);
+ assertEq(view.getUint8(8), 128);
+ view.setUint8(15, 255);
+ assertEq(view.getUint8(15), 255);
+ view.setInt16(0, 256, true);
+ assertEq(view.getInt16(0, true), 256);
+ view.setInt16(5, 26213, true);
+ assertEq(view.getInt16(5, true), 26213);
+ view.setInt16(9, -32127, true);
+ assertEq(view.getInt16(9, true), -32127);
+ view.setInt16(14, -2, true);
+ assertEq(view.getInt16(14, true), -2);
+ view.setInt16(0, 1);
+ assertEq(view.getInt16(0), 1);
+ view.setInt16(5, 25958);
+ assertEq(view.getInt16(5), 25958);
+ view.setInt16(9, -32382);
+ assertEq(view.getInt16(9), -32382);
+ view.setInt16(14, -257);
+ assertEq(view.getInt16(14), -257);
+ view.setUint16(0, 256, true);
+ assertEq(view.getUint16(0, true), 256);
+ view.setUint16(5, 26213, true);
+ assertEq(view.getUint16(5, true), 26213);
+ view.setUint16(9, 33409, true);
+ assertEq(view.getUint16(9, true), 33409);
+ view.setUint16(14, 65534, true);
+ assertEq(view.getUint16(14, true), 65534);
+ view.setUint16(0, 1);
+ assertEq(view.getUint16(0), 1);
+ view.setUint16(5, 25958);
+ assertEq(view.getUint16(5), 25958);
+ view.setUint16(9, 33154);
+ assertEq(view.getUint16(9), 33154);
+ view.setUint16(14, 65279);
+ assertEq(view.getUint16(14), 65279);
+ view.setInt32(0, 50462976, true);
+ assertEq(view.getInt32(0, true), 50462976);
+ view.setInt32(3, 1717920771, true);
+ assertEq(view.getInt32(3, true), 1717920771);
+ view.setInt32(6, -2122291354, true);
+ assertEq(view.getInt32(6, true), -2122291354);
+ view.setInt32(9, -58490239, true);
+ assertEq(view.getInt32(9, true), -58490239);
+ view.setInt32(12, -66052, true);
+ assertEq(view.getInt32(12, true), -66052);
+ view.setInt32(0, 66051);
+ assertEq(view.getInt32(0), 66051);
+ view.setInt32(3, 56911206);
+ assertEq(view.getInt32(3), 56911206);
+ view.setInt32(6, 1718059137);
+ assertEq(view.getInt32(6), 1718059137);
+ view.setInt32(9, -2122152964);
+ assertEq(view.getInt32(9), -2122152964);
+ view.setInt32(12, -50462977);
+ assertEq(view.getInt32(12), -50462977);
+ view.setUint32(0, 50462976, true);
+ assertEq(view.getUint32(0, true), 50462976);
+ view.setUint32(3, 1717920771, true);
+ assertEq(view.getUint32(3, true), 1717920771);
+ view.setUint32(6, 2172675942, true);
+ assertEq(view.getUint32(6, true), 2172675942);
+ view.setUint32(9, 4236477057, true);
+ assertEq(view.getUint32(9, true), 4236477057);
+ view.setUint32(12, 4294901244, true);
+ assertEq(view.getUint32(12, true), 4294901244);
+ view.setUint32(0, 66051);
+ assertEq(view.getUint32(0), 66051);
+ view.setUint32(3, 56911206);
+ assertEq(view.getUint32(3), 56911206);
+ view.setUint32(6, 1718059137);
+ assertEq(view.getUint32(6), 1718059137);
+ view.setUint32(9, 2172814332);
+ assertEq(view.getUint32(9), 2172814332);
+ view.setUint32(12, 4244504319);
+ assertEq(view.getUint32(12), 4244504319);
+
+ // testFloatSets(start=undefined)
+
+ // testFloatSet expected=10
+ // Little endian
+ view = new DataView(buffer13, 0, 16);
+ view.setFloat32(0, 10, true);
+ assertEq(view.getFloat32(0, true), 10);
+ var buffer13_pad3 = new Uint8Array(Array(3).concat(data13)).buffer;
+ view = new DataView(buffer13_pad3, 0, 19);
+ view.setFloat32(3, 10, true);
+ assertEq(view.getFloat32(3, true), 10);
+ var buffer13_pad7 = new Uint8Array(Array(7).concat(data13)).buffer;
+ view = new DataView(buffer13_pad7, 0, 23);
+ view.setFloat32(7, 10, true);
+ assertEq(view.getFloat32(7, true), 10);
+ var buffer13_pad10 = new Uint8Array(Array(10).concat(data13)).buffer;
+ view = new DataView(buffer13_pad10, 0, 26);
+ view.setFloat32(10, 10, true);
+ assertEq(view.getFloat32(10, true), 10);
+ // Big endian.
+ var buffer13_r = new Uint8Array(data13_r).buffer;
+ view = new DataView(buffer13_r, 0, 16);
+ view.setFloat32(0, 10, false);
+ assertEq(view.getFloat32(0, false), 10);
+ var buffer13_r_pad3 = new Uint8Array(Array(3).concat(data13_r)).buffer;
+ view = new DataView(buffer13_r_pad3, 0, 19);
+ view.setFloat32(3, 10, false);
+ assertEq(view.getFloat32(3, false), 10);
+ var buffer13_r_pad7 = new Uint8Array(Array(7).concat(data13_r)).buffer;
+ view = new DataView(buffer13_r_pad7, 0, 23);
+ view.setFloat32(7, 10, false);
+ assertEq(view.getFloat32(7, false), 10);
+ var buffer13_r_pad10 = new Uint8Array(Array(10).concat(data13_r)).buffer;
+ view = new DataView(buffer13_r_pad10, 0, 26);
+ view.setFloat32(10, 10, false);
+ assertEq(view.getFloat32(10, false), 10);
+
+ // testFloatSet expected=1.2300000190734863
+ // Little endian
+ view = new DataView(buffer13, 0, 16);
+ view.setFloat32(0, 1.2300000190734863, true);
+ assertEq(view.getFloat32(0, true), 1.2300000190734863);
+ view = new DataView(buffer13_pad3, 0, 19);
+ view.setFloat32(3, 1.2300000190734863, true);
+ assertEq(view.getFloat32(3, true), 1.2300000190734863);
+ view = new DataView(buffer13_pad7, 0, 23);
+ view.setFloat32(7, 1.2300000190734863, true);
+ assertEq(view.getFloat32(7, true), 1.2300000190734863);
+ view = new DataView(buffer13_pad10, 0, 26);
+ view.setFloat32(10, 1.2300000190734863, true);
+ assertEq(view.getFloat32(10, true), 1.2300000190734863);
+ // Big endian.
+ view = new DataView(buffer13_r, 0, 16);
+ view.setFloat32(0, 1.2300000190734863, false);
+ assertEq(view.getFloat32(0, false), 1.2300000190734863);
+ view = new DataView(buffer13_r_pad3, 0, 19);
+ view.setFloat32(3, 1.2300000190734863, false);
+ assertEq(view.getFloat32(3, false), 1.2300000190734863);
+ view = new DataView(buffer13_r_pad7, 0, 23);
+ view.setFloat32(7, 1.2300000190734863, false);
+ assertEq(view.getFloat32(7, false), 1.2300000190734863);
+ view = new DataView(buffer13_r_pad10, 0, 26);
+ view.setFloat32(10, 1.2300000190734863, false);
+ assertEq(view.getFloat32(10, false), 1.2300000190734863);
+
+ // testFloatSet expected=-45621.37109375
+ // Little endian
+ view = new DataView(buffer13, 0, 16);
+ view.setFloat32(0, -45621.37109375, true);
+ assertEq(view.getFloat32(0, true), -45621.37109375);
+ view = new DataView(buffer13_pad3, 0, 19);
+ view.setFloat32(3, -45621.37109375, true);
+ assertEq(view.getFloat32(3, true), -45621.37109375);
+ view = new DataView(buffer13_pad7, 0, 23);
+ view.setFloat32(7, -45621.37109375, true);
+ assertEq(view.getFloat32(7, true), -45621.37109375);
+ view = new DataView(buffer13_pad10, 0, 26);
+ view.setFloat32(10, -45621.37109375, true);
+ assertEq(view.getFloat32(10, true), -45621.37109375);
+ // Big endian.
+ view = new DataView(buffer13_r, 0, 16);
+ view.setFloat32(0, -45621.37109375, false);
+ assertEq(view.getFloat32(0, false), -45621.37109375);
+ view = new DataView(buffer13_r_pad3, 0, 19);
+ view.setFloat32(3, -45621.37109375, false);
+ assertEq(view.getFloat32(3, false), -45621.37109375);
+ view = new DataView(buffer13_r_pad7, 0, 23);
+ view.setFloat32(7, -45621.37109375, false);
+ assertEq(view.getFloat32(7, false), -45621.37109375);
+ view = new DataView(buffer13_r_pad10, 0, 26);
+ view.setFloat32(10, -45621.37109375, false);
+ assertEq(view.getFloat32(10, false), -45621.37109375);
+
+ // testFloatSet expected=NaN
+ // Little endian
+ view = new DataView(buffer13, 0, 16);
+ view.setFloat32(0, NaN, true);
+ assertEq(view.getFloat32(0, true), NaN);
+ view = new DataView(buffer13_pad3, 0, 19);
+ view.setFloat32(3, NaN, true);
+ assertEq(view.getFloat32(3, true), NaN);
+ view = new DataView(buffer13_pad7, 0, 23);
+ view.setFloat32(7, NaN, true);
+ assertEq(view.getFloat32(7, true), NaN);
+ view = new DataView(buffer13_pad10, 0, 26);
+ view.setFloat32(10, NaN, true);
+ assertEq(view.getFloat32(10, true), NaN);
+ // Big endian.
+ view = new DataView(buffer13_r, 0, 16);
+ view.setFloat32(0, NaN, false);
+ assertEq(view.getFloat32(0, false), NaN);
+ view = new DataView(buffer13_r_pad3, 0, 19);
+ view.setFloat32(3, NaN, false);
+ assertEq(view.getFloat32(3, false), NaN);
+ view = new DataView(buffer13_r_pad7, 0, 23);
+ view.setFloat32(7, NaN, false);
+ assertEq(view.getFloat32(7, false), NaN);
+ view = new DataView(buffer13_r_pad10, 0, 26);
+ view.setFloat32(10, NaN, false);
+ assertEq(view.getFloat32(10, false), NaN);
+
+ // testFloatSet expected=-NaN
+ // Little endian
+ view = new DataView(buffer13, 0, 16);
+ view.setFloat32(0, -NaN, true);
+ assertEq(view.getFloat32(0, true), -NaN);
+ view = new DataView(buffer13_pad3, 0, 19);
+ view.setFloat32(3, -NaN, true);
+ assertEq(view.getFloat32(3, true), -NaN);
+ view = new DataView(buffer13_pad7, 0, 23);
+ view.setFloat32(7, -NaN, true);
+ assertEq(view.getFloat32(7, true), -NaN);
+ view = new DataView(buffer13_pad10, 0, 26);
+ view.setFloat32(10, -NaN, true);
+ assertEq(view.getFloat32(10, true), -NaN);
+ // Big endian.
+ view = new DataView(buffer13_r, 0, 16);
+ view.setFloat32(0, -NaN, false);
+ assertEq(view.getFloat32(0, false), -NaN);
+ view = new DataView(buffer13_r_pad3, 0, 19);
+ view.setFloat32(3, -NaN, false);
+ assertEq(view.getFloat32(3, false), -NaN);
+ view = new DataView(buffer13_r_pad7, 0, 23);
+ view.setFloat32(7, -NaN, false);
+ assertEq(view.getFloat32(7, false), -NaN);
+ view = new DataView(buffer13_r_pad10, 0, 26);
+ view.setFloat32(10, -NaN, false);
+ assertEq(view.getFloat32(10, false), -NaN);
+
+ // testFloatSet expected=10
+ // Little endian
+ view = new DataView(buffer13, 0, 16);
+ view.setFloat64(0, 10, true);
+ assertEq(view.getFloat64(0, true), 10);
+ view = new DataView(buffer13_pad3, 0, 19);
+ view.setFloat64(3, 10, true);
+ assertEq(view.getFloat64(3, true), 10);
+ view = new DataView(buffer13_pad7, 0, 23);
+ view.setFloat64(7, 10, true);
+ assertEq(view.getFloat64(7, true), 10);
+ view = new DataView(buffer13_pad10, 0, 26);
+ view.setFloat64(10, 10, true);
+ assertEq(view.getFloat64(10, true), 10);
+ // Big endian.
+ view = new DataView(buffer13_r, 0, 16);
+ view.setFloat64(0, 10, false);
+ assertEq(view.getFloat64(0, false), 10);
+ view = new DataView(buffer13_r_pad3, 0, 19);
+ view.setFloat64(3, 10, false);
+ assertEq(view.getFloat64(3, false), 10);
+ view = new DataView(buffer13_r_pad7, 0, 23);
+ view.setFloat64(7, 10, false);
+ assertEq(view.getFloat64(7, false), 10);
+ view = new DataView(buffer13_r_pad10, 0, 26);
+ view.setFloat64(10, 10, false);
+ assertEq(view.getFloat64(10, false), 10);
+
+ // testFloatSet expected=1.23
+ // Little endian
+ view = new DataView(buffer13, 0, 16);
+ view.setFloat64(0, 1.23, true);
+ assertEq(view.getFloat64(0, true), 1.23);
+ view = new DataView(buffer13_pad3, 0, 19);
+ view.setFloat64(3, 1.23, true);
+ assertEq(view.getFloat64(3, true), 1.23);
+ view = new DataView(buffer13_pad7, 0, 23);
+ view.setFloat64(7, 1.23, true);
+ assertEq(view.getFloat64(7, true), 1.23);
+ view = new DataView(buffer13_pad10, 0, 26);
+ view.setFloat64(10, 1.23, true);
+ assertEq(view.getFloat64(10, true), 1.23);
+ // Big endian.
+ view = new DataView(buffer13_r, 0, 16);
+ view.setFloat64(0, 1.23, false);
+ assertEq(view.getFloat64(0, false), 1.23);
+ view = new DataView(buffer13_r_pad3, 0, 19);
+ view.setFloat64(3, 1.23, false);
+ assertEq(view.getFloat64(3, false), 1.23);
+ view = new DataView(buffer13_r_pad7, 0, 23);
+ view.setFloat64(7, 1.23, false);
+ assertEq(view.getFloat64(7, false), 1.23);
+ view = new DataView(buffer13_r_pad10, 0, 26);
+ view.setFloat64(10, 1.23, false);
+ assertEq(view.getFloat64(10, false), 1.23);
+
+ // testFloatSet expected=-6213576.4839
+ // Little endian
+ view = new DataView(buffer13, 0, 16);
+ view.setFloat64(0, -6213576.4839, true);
+ assertEq(view.getFloat64(0, true), -6213576.4839);
+ view = new DataView(buffer13_pad3, 0, 19);
+ view.setFloat64(3, -6213576.4839, true);
+ assertEq(view.getFloat64(3, true), -6213576.4839);
+ view = new DataView(buffer13_pad7, 0, 23);
+ view.setFloat64(7, -6213576.4839, true);
+ assertEq(view.getFloat64(7, true), -6213576.4839);
+ view = new DataView(buffer13_pad10, 0, 26);
+ view.setFloat64(10, -6213576.4839, true);
+ assertEq(view.getFloat64(10, true), -6213576.4839);
+ // Big endian.
+ view = new DataView(buffer13_r, 0, 16);
+ view.setFloat64(0, -6213576.4839, false);
+ assertEq(view.getFloat64(0, false), -6213576.4839);
+ view = new DataView(buffer13_r_pad3, 0, 19);
+ view.setFloat64(3, -6213576.4839, false);
+ assertEq(view.getFloat64(3, false), -6213576.4839);
+ view = new DataView(buffer13_r_pad7, 0, 23);
+ view.setFloat64(7, -6213576.4839, false);
+ assertEq(view.getFloat64(7, false), -6213576.4839);
+ view = new DataView(buffer13_r_pad10, 0, 26);
+ view.setFloat64(10, -6213576.4839, false);
+ assertEq(view.getFloat64(10, false), -6213576.4839);
+
+ // testFloatSet expected=NaN
+ // Little endian
+ view = new DataView(buffer13, 0, 16);
+ view.setFloat64(0, NaN, true);
+ assertEq(view.getFloat64(0, true), NaN);
+ view = new DataView(buffer13_pad3, 0, 19);
+ view.setFloat64(3, NaN, true);
+ assertEq(view.getFloat64(3, true), NaN);
+ view = new DataView(buffer13_pad7, 0, 23);
+ view.setFloat64(7, NaN, true);
+ assertEq(view.getFloat64(7, true), NaN);
+ view = new DataView(buffer13_pad10, 0, 26);
+ view.setFloat64(10, NaN, true);
+ assertEq(view.getFloat64(10, true), NaN);
+ // Big endian.
+ view = new DataView(buffer13_r, 0, 16);
+ view.setFloat64(0, NaN, false);
+ assertEq(view.getFloat64(0, false), NaN);
+ view = new DataView(buffer13_r_pad3, 0, 19);
+ view.setFloat64(3, NaN, false);
+ assertEq(view.getFloat64(3, false), NaN);
+ view = new DataView(buffer13_r_pad7, 0, 23);
+ view.setFloat64(7, NaN, false);
+ assertEq(view.getFloat64(7, false), NaN);
+ view = new DataView(buffer13_r_pad10, 0, 26);
+ view.setFloat64(10, NaN, false);
+ assertEq(view.getFloat64(10, false), NaN);
+
+ // testFloatSet expected=-NaN
+ // Little endian
+ view = new DataView(buffer13, 0, 16);
+ view.setFloat64(0, -NaN, true);
+ assertEq(view.getFloat64(0, true), -NaN);
+ view = new DataView(buffer13_pad3, 0, 19);
+ view.setFloat64(3, -NaN, true);
+ assertEq(view.getFloat64(3, true), -NaN);
+ view = new DataView(buffer13_pad7, 0, 23);
+ view.setFloat64(7, -NaN, true);
+ assertEq(view.getFloat64(7, true), -NaN);
+ view = new DataView(buffer13_pad10, 0, 26);
+ view.setFloat64(10, -NaN, true);
+ assertEq(view.getFloat64(10, true), -NaN);
+ // Big endian.
+ view = new DataView(buffer13_r, 0, 16);
+ view.setFloat64(0, -NaN, false);
+ assertEq(view.getFloat64(0, false), -NaN);
+ view = new DataView(buffer13_r_pad3, 0, 19);
+ view.setFloat64(3, -NaN, false);
+ assertEq(view.getFloat64(3, false), -NaN);
+ view = new DataView(buffer13_r_pad7, 0, 23);
+ view.setFloat64(7, -NaN, false);
+ assertEq(view.getFloat64(7, false), -NaN);
+ view = new DataView(buffer13_r_pad10, 0, 26);
+ view.setFloat64(10, -NaN, false);
+ assertEq(view.getFloat64(10, false), -NaN);
+
+ // Test for set methods that might write beyond the range
+
+ // testIntegerSets(start=3, length=2)
+ view = new DataView(buffer13, 3, 2);
+ view.setInt8(0, 0);
+ assertEq(view.getInt8(0), 0);
+ checkThrow(() => view.setInt8(8, -128), RangeError);
+ checkThrow(() => view.setInt8(15, -1), RangeError);
+ view.setUint8(0, 0);
+ assertEq(view.getUint8(0), 0);
+ checkThrow(() => view.setUint8(8, 128), RangeError);
+ checkThrow(() => view.setUint8(15, 255), RangeError);
+ view.setInt16(0, 256, true);
+ assertEq(view.getInt16(0, true), 256);
+ checkThrow(() => view.setInt16(5, 26213, true), RangeError);
+ checkThrow(() => view.setInt16(9, -32127, true), RangeError);
+ checkThrow(() => view.setInt16(14, -2, true), RangeError);
+ view.setInt16(0, 1);
+ assertEq(view.getInt16(0), 1);
+ checkThrow(() => view.setInt16(5, 25958), RangeError);
+ checkThrow(() => view.setInt16(9, -32382), RangeError);
+ checkThrow(() => view.setInt16(14, -257), RangeError);
+ view.setUint16(0, 256, true);
+ assertEq(view.getUint16(0, true), 256);
+ checkThrow(() => view.setUint16(5, 26213, true), RangeError);
+ checkThrow(() => view.setUint16(9, 33409, true), RangeError);
+ checkThrow(() => view.setUint16(14, 65534, true), RangeError);
+ view.setUint16(0, 1);
+ assertEq(view.getUint16(0), 1);
+ checkThrow(() => view.setUint16(5, 25958), RangeError);
+ checkThrow(() => view.setUint16(9, 33154), RangeError);
+ checkThrow(() => view.setUint16(14, 65279), RangeError);
+ checkThrow(() => view.setInt32(0, 50462976, true), RangeError);
+ checkThrow(() => view.setInt32(3, 1717920771, true), RangeError);
+ checkThrow(() => view.setInt32(6, -2122291354, true), RangeError);
+ checkThrow(() => view.setInt32(9, -58490239, true), RangeError);
+ checkThrow(() => view.setInt32(12, -66052, true), RangeError);
+ checkThrow(() => view.setInt32(0, 66051), RangeError);
+ checkThrow(() => view.setInt32(3, 56911206), RangeError);
+ checkThrow(() => view.setInt32(6, 1718059137), RangeError);
+ checkThrow(() => view.setInt32(9, -2122152964), RangeError);
+ checkThrow(() => view.setInt32(12, -50462977), RangeError);
+ checkThrow(() => view.setUint32(0, 50462976, true), RangeError);
+ checkThrow(() => view.setUint32(3, 1717920771, true), RangeError);
+ checkThrow(() => view.setUint32(6, 2172675942, true), RangeError);
+ checkThrow(() => view.setUint32(9, 4236477057, true), RangeError);
+ checkThrow(() => view.setUint32(12, 4294901244, true), RangeError);
+ checkThrow(() => view.setUint32(0, 66051), RangeError);
+ checkThrow(() => view.setUint32(3, 56911206), RangeError);
+ checkThrow(() => view.setUint32(6, 1718059137), RangeError);
+ checkThrow(() => view.setUint32(9, 2172814332), RangeError);
+ checkThrow(() => view.setUint32(12, 4244504319), RangeError);
+
+ // testFloatSets(start=7)
+
+ // testFloatSet expected=10
+ // Little endian
+ view = new DataView(buffer13, 7, 9);
+ view.setFloat32(0, 10, true);
+ assertEq(view.getFloat32(0, true), 10);
+ view = new DataView(buffer13_pad3, 7, 12);
+ view.setFloat32(3, 10, true);
+ assertEq(view.getFloat32(3, true), 10);
+ view = new DataView(buffer13_pad7, 7, 16);
+ view.setFloat32(7, 10, true);
+ assertEq(view.getFloat32(7, true), 10);
+ view = new DataView(buffer13_pad10, 7, 19);
+ view.setFloat32(10, 10, true);
+ assertEq(view.getFloat32(10, true), 10);
+ // Big endian.
+ view = new DataView(buffer13_r, 7, 9);
+ view.setFloat32(0, 10, false);
+ assertEq(view.getFloat32(0, false), 10);
+ view = new DataView(buffer13_r_pad3, 7, 12);
+ view.setFloat32(3, 10, false);
+ assertEq(view.getFloat32(3, false), 10);
+ view = new DataView(buffer13_r_pad7, 7, 16);
+ view.setFloat32(7, 10, false);
+ assertEq(view.getFloat32(7, false), 10);
+ view = new DataView(buffer13_r_pad10, 7, 19);
+ view.setFloat32(10, 10, false);
+ assertEq(view.getFloat32(10, false), 10);
+
+ // testFloatSet expected=1.2300000190734863
+ // Little endian
+ view = new DataView(buffer13, 7, 9);
+ view.setFloat32(0, 1.2300000190734863, true);
+ assertEq(view.getFloat32(0, true), 1.2300000190734863);
+ view = new DataView(buffer13_pad3, 7, 12);
+ view.setFloat32(3, 1.2300000190734863, true);
+ assertEq(view.getFloat32(3, true), 1.2300000190734863);
+ view = new DataView(buffer13_pad7, 7, 16);
+ view.setFloat32(7, 1.2300000190734863, true);
+ assertEq(view.getFloat32(7, true), 1.2300000190734863);
+ view = new DataView(buffer13_pad10, 7, 19);
+ view.setFloat32(10, 1.2300000190734863, true);
+ assertEq(view.getFloat32(10, true), 1.2300000190734863);
+ // Big endian.
+ view = new DataView(buffer13_r, 7, 9);
+ view.setFloat32(0, 1.2300000190734863, false);
+ assertEq(view.getFloat32(0, false), 1.2300000190734863);
+ view = new DataView(buffer13_r_pad3, 7, 12);
+ view.setFloat32(3, 1.2300000190734863, false);
+ assertEq(view.getFloat32(3, false), 1.2300000190734863);
+ view = new DataView(buffer13_r_pad7, 7, 16);
+ view.setFloat32(7, 1.2300000190734863, false);
+ assertEq(view.getFloat32(7, false), 1.2300000190734863);
+ view = new DataView(buffer13_r_pad10, 7, 19);
+ view.setFloat32(10, 1.2300000190734863, false);
+ assertEq(view.getFloat32(10, false), 1.2300000190734863);
+
+ // testFloatSet expected=-45621.37109375
+ // Little endian
+ view = new DataView(buffer13, 7, 9);
+ view.setFloat32(0, -45621.37109375, true);
+ assertEq(view.getFloat32(0, true), -45621.37109375);
+ view = new DataView(buffer13_pad3, 7, 12);
+ view.setFloat32(3, -45621.37109375, true);
+ assertEq(view.getFloat32(3, true), -45621.37109375);
+ view = new DataView(buffer13_pad7, 7, 16);
+ view.setFloat32(7, -45621.37109375, true);
+ assertEq(view.getFloat32(7, true), -45621.37109375);
+ view = new DataView(buffer13_pad10, 7, 19);
+ view.setFloat32(10, -45621.37109375, true);
+ assertEq(view.getFloat32(10, true), -45621.37109375);
+ // Big endian.
+ view = new DataView(buffer13_r, 7, 9);
+ view.setFloat32(0, -45621.37109375, false);
+ assertEq(view.getFloat32(0, false), -45621.37109375);
+ view = new DataView(buffer13_r_pad3, 7, 12);
+ view.setFloat32(3, -45621.37109375, false);
+ assertEq(view.getFloat32(3, false), -45621.37109375);
+ view = new DataView(buffer13_r_pad7, 7, 16);
+ view.setFloat32(7, -45621.37109375, false);
+ assertEq(view.getFloat32(7, false), -45621.37109375);
+ view = new DataView(buffer13_r_pad10, 7, 19);
+ view.setFloat32(10, -45621.37109375, false);
+ assertEq(view.getFloat32(10, false), -45621.37109375);
+
+ // testFloatSet expected=NaN
+ // Little endian
+ view = new DataView(buffer13, 7, 9);
+ view.setFloat32(0, NaN, true);
+ assertEq(view.getFloat32(0, true), NaN);
+ view = new DataView(buffer13_pad3, 7, 12);
+ view.setFloat32(3, NaN, true);
+ assertEq(view.getFloat32(3, true), NaN);
+ view = new DataView(buffer13_pad7, 7, 16);
+ view.setFloat32(7, NaN, true);
+ assertEq(view.getFloat32(7, true), NaN);
+ view = new DataView(buffer13_pad10, 7, 19);
+ view.setFloat32(10, NaN, true);
+ assertEq(view.getFloat32(10, true), NaN);
+ // Big endian.
+ view = new DataView(buffer13_r, 7, 9);
+ view.setFloat32(0, NaN, false);
+ assertEq(view.getFloat32(0, false), NaN);
+ view = new DataView(buffer13_r_pad3, 7, 12);
+ view.setFloat32(3, NaN, false);
+ assertEq(view.getFloat32(3, false), NaN);
+ view = new DataView(buffer13_r_pad7, 7, 16);
+ view.setFloat32(7, NaN, false);
+ assertEq(view.getFloat32(7, false), NaN);
+ view = new DataView(buffer13_r_pad10, 7, 19);
+ view.setFloat32(10, NaN, false);
+ assertEq(view.getFloat32(10, false), NaN);
+
+ // testFloatSet expected=-NaN
+ // Little endian
+ view = new DataView(buffer13, 7, 9);
+ view.setFloat32(0, -NaN, true);
+ assertEq(view.getFloat32(0, true), -NaN);
+ view = new DataView(buffer13_pad3, 7, 12);
+ view.setFloat32(3, -NaN, true);
+ assertEq(view.getFloat32(3, true), -NaN);
+ view = new DataView(buffer13_pad7, 7, 16);
+ view.setFloat32(7, -NaN, true);
+ assertEq(view.getFloat32(7, true), -NaN);
+ view = new DataView(buffer13_pad10, 7, 19);
+ view.setFloat32(10, -NaN, true);
+ assertEq(view.getFloat32(10, true), -NaN);
+ // Big endian.
+ view = new DataView(buffer13_r, 7, 9);
+ view.setFloat32(0, -NaN, false);
+ assertEq(view.getFloat32(0, false), -NaN);
+ view = new DataView(buffer13_r_pad3, 7, 12);
+ view.setFloat32(3, -NaN, false);
+ assertEq(view.getFloat32(3, false), -NaN);
+ view = new DataView(buffer13_r_pad7, 7, 16);
+ view.setFloat32(7, -NaN, false);
+ assertEq(view.getFloat32(7, false), -NaN);
+ view = new DataView(buffer13_r_pad10, 7, 19);
+ view.setFloat32(10, -NaN, false);
+ assertEq(view.getFloat32(10, false), -NaN);
+
+ // testFloatSet expected=10
+ // Little endian
+ view = new DataView(buffer13, 7, 9);
+ view.setFloat64(0, 10, true);
+ assertEq(view.getFloat64(0, true), 10);
+ view = new DataView(buffer13_pad3, 7, 12);
+ view.setFloat64(3, 10, true);
+ assertEq(view.getFloat64(3, true), 10);
+ view = new DataView(buffer13_pad7, 7, 16);
+ view.setFloat64(7, 10, true);
+ assertEq(view.getFloat64(7, true), 10);
+ view = new DataView(buffer13_pad10, 7, 19);
+ view.setFloat64(10, 10, true);
+ assertEq(view.getFloat64(10, true), 10);
+ // Big endian.
+ view = new DataView(buffer13_r, 7, 9);
+ view.setFloat64(0, 10, false);
+ assertEq(view.getFloat64(0, false), 10);
+ view = new DataView(buffer13_r_pad3, 7, 12);
+ view.setFloat64(3, 10, false);
+ assertEq(view.getFloat64(3, false), 10);
+ view = new DataView(buffer13_r_pad7, 7, 16);
+ view.setFloat64(7, 10, false);
+ assertEq(view.getFloat64(7, false), 10);
+ view = new DataView(buffer13_r_pad10, 7, 19);
+ view.setFloat64(10, 10, false);
+ assertEq(view.getFloat64(10, false), 10);
+
+ // testFloatSet expected=1.23
+ // Little endian
+ view = new DataView(buffer13, 7, 9);
+ view.setFloat64(0, 1.23, true);
+ assertEq(view.getFloat64(0, true), 1.23);
+ view = new DataView(buffer13_pad3, 7, 12);
+ view.setFloat64(3, 1.23, true);
+ assertEq(view.getFloat64(3, true), 1.23);
+ view = new DataView(buffer13_pad7, 7, 16);
+ view.setFloat64(7, 1.23, true);
+ assertEq(view.getFloat64(7, true), 1.23);
+ view = new DataView(buffer13_pad10, 7, 19);
+ view.setFloat64(10, 1.23, true);
+ assertEq(view.getFloat64(10, true), 1.23);
+ // Big endian.
+ view = new DataView(buffer13_r, 7, 9);
+ view.setFloat64(0, 1.23, false);
+ assertEq(view.getFloat64(0, false), 1.23);
+ view = new DataView(buffer13_r_pad3, 7, 12);
+ view.setFloat64(3, 1.23, false);
+ assertEq(view.getFloat64(3, false), 1.23);
+ view = new DataView(buffer13_r_pad7, 7, 16);
+ view.setFloat64(7, 1.23, false);
+ assertEq(view.getFloat64(7, false), 1.23);
+ view = new DataView(buffer13_r_pad10, 7, 19);
+ view.setFloat64(10, 1.23, false);
+ assertEq(view.getFloat64(10, false), 1.23);
+
+ // testFloatSet expected=-6213576.4839
+ // Little endian
+ view = new DataView(buffer13, 7, 9);
+ view.setFloat64(0, -6213576.4839, true);
+ assertEq(view.getFloat64(0, true), -6213576.4839);
+ view = new DataView(buffer13_pad3, 7, 12);
+ view.setFloat64(3, -6213576.4839, true);
+ assertEq(view.getFloat64(3, true), -6213576.4839);
+ view = new DataView(buffer13_pad7, 7, 16);
+ view.setFloat64(7, -6213576.4839, true);
+ assertEq(view.getFloat64(7, true), -6213576.4839);
+ view = new DataView(buffer13_pad10, 7, 19);
+ view.setFloat64(10, -6213576.4839, true);
+ assertEq(view.getFloat64(10, true), -6213576.4839);
+ // Big endian.
+ view = new DataView(buffer13_r, 7, 9);
+ view.setFloat64(0, -6213576.4839, false);
+ assertEq(view.getFloat64(0, false), -6213576.4839);
+ view = new DataView(buffer13_r_pad3, 7, 12);
+ view.setFloat64(3, -6213576.4839, false);
+ assertEq(view.getFloat64(3, false), -6213576.4839);
+ view = new DataView(buffer13_r_pad7, 7, 16);
+ view.setFloat64(7, -6213576.4839, false);
+ assertEq(view.getFloat64(7, false), -6213576.4839);
+ view = new DataView(buffer13_r_pad10, 7, 19);
+ view.setFloat64(10, -6213576.4839, false);
+ assertEq(view.getFloat64(10, false), -6213576.4839);
+
+ // testFloatSet expected=NaN
+ // Little endian
+ view = new DataView(buffer13, 7, 9);
+ view.setFloat64(0, NaN, true);
+ assertEq(view.getFloat64(0, true), NaN);
+ view = new DataView(buffer13_pad3, 7, 12);
+ view.setFloat64(3, NaN, true);
+ assertEq(view.getFloat64(3, true), NaN);
+ view = new DataView(buffer13_pad7, 7, 16);
+ view.setFloat64(7, NaN, true);
+ assertEq(view.getFloat64(7, true), NaN);
+ view = new DataView(buffer13_pad10, 7, 19);
+ view.setFloat64(10, NaN, true);
+ assertEq(view.getFloat64(10, true), NaN);
+ // Big endian.
+ view = new DataView(buffer13_r, 7, 9);
+ view.setFloat64(0, NaN, false);
+ assertEq(view.getFloat64(0, false), NaN);
+ view = new DataView(buffer13_r_pad3, 7, 12);
+ view.setFloat64(3, NaN, false);
+ assertEq(view.getFloat64(3, false), NaN);
+ view = new DataView(buffer13_r_pad7, 7, 16);
+ view.setFloat64(7, NaN, false);
+ assertEq(view.getFloat64(7, false), NaN);
+ view = new DataView(buffer13_r_pad10, 7, 19);
+ view.setFloat64(10, NaN, false);
+ assertEq(view.getFloat64(10, false), NaN);
+
+ // testFloatSet expected=-NaN
+ // Little endian
+ view = new DataView(buffer13, 7, 9);
+ view.setFloat64(0, -NaN, true);
+ assertEq(view.getFloat64(0, true), -NaN);
+ view = new DataView(buffer13_pad3, 7, 12);
+ view.setFloat64(3, -NaN, true);
+ assertEq(view.getFloat64(3, true), -NaN);
+ view = new DataView(buffer13_pad7, 7, 16);
+ view.setFloat64(7, -NaN, true);
+ assertEq(view.getFloat64(7, true), -NaN);
+ view = new DataView(buffer13_pad10, 7, 19);
+ view.setFloat64(10, -NaN, true);
+ assertEq(view.getFloat64(10, true), -NaN);
+ // Big endian.
+ view = new DataView(buffer13_r, 7, 9);
+ view.setFloat64(0, -NaN, false);
+ assertEq(view.getFloat64(0, false), -NaN);
+ view = new DataView(buffer13_r_pad3, 7, 12);
+ view.setFloat64(3, -NaN, false);
+ assertEq(view.getFloat64(3, false), -NaN);
+ view = new DataView(buffer13_r_pad7, 7, 16);
+ view.setFloat64(7, -NaN, false);
+ assertEq(view.getFloat64(7, false), -NaN);
+ view = new DataView(buffer13_r_pad10, 7, 19);
+ view.setFloat64(10, -NaN, false);
+ assertEq(view.getFloat64(10, false), -NaN);
+
+ // Test for set methods that write to negative index
+
+ // testSetNegativeIndexes
+ view = new DataView(buffer1, 0, 16);
+ checkThrow(() => view.setInt8(-1, 0), RangeError);
+ checkThrow(() => view.setInt8(-2, 0), RangeError);
+ checkThrow(() => view.setUint8(-1, 0), RangeError);
+ checkThrow(() => view.setUint8(-2, 0), RangeError);
+ checkThrow(() => view.setInt16(-1, 0), RangeError);
+ checkThrow(() => view.setInt16(-2, 0), RangeError);
+ checkThrow(() => view.setInt16(-3, 0), RangeError);
+ checkThrow(() => view.setUint16(-1, 0), RangeError);
+ checkThrow(() => view.setUint16(-2, 0), RangeError);
+ checkThrow(() => view.setUint16(-3, 0), RangeError);
+ checkThrow(() => view.setInt32(-1, 0), RangeError);
+ checkThrow(() => view.setInt32(-3, 0), RangeError);
+ checkThrow(() => view.setInt32(-5, 0), RangeError);
+ checkThrow(() => view.setUint32(-1, 0), RangeError);
+ checkThrow(() => view.setUint32(-3, 0), RangeError);
+ checkThrow(() => view.setUint32(-5, 0), RangeError);
+ view = new DataView(buffer7, 0, 8);
+ checkThrow(() => view.setFloat32(-1, 0), RangeError);
+ checkThrow(() => view.setFloat32(-3, 0), RangeError);
+ checkThrow(() => view.setFloat32(-5, 0), RangeError);
+ checkThrow(() => view.setFloat64(-1, 0), RangeError);
+ checkThrow(() => view.setFloat64(-5, 0), RangeError);
+ checkThrow(() => view.setFloat64(-9, 0), RangeError);
+
+ // Too large for signed 32 bit integer index
+ checkThrow(() => view.setInt8(2147483649, 1), RangeError);
+ checkThrow(() => view.setUint8(2147483649, 1), RangeError);
+ checkThrow(() => view.setInt16(2147483649, 1), RangeError);
+ checkThrow(() => view.setUint16(2147483649, 1), RangeError);
+ checkThrow(() => view.setInt32(2147483649, 1), RangeError);
+ checkThrow(() => view.setUint32(2147483649, 1), RangeError);
+ checkThrow(() => view.setFloat32(2147483649, 1), RangeError);
+ checkThrow(() => view.setFloat64(2147483649, 1), RangeError);
+
+ // testAlignment
+ var intArray1 = [0, 1, 2, 3, 100, 101, 102, 103, 128, 129, 130, 131, 252, 253, 254, 255];
+ view = new DataView((new Uint8Array(intArray1)).buffer, 0);
+ assertEq(view.getUint32(0, false), 0x00010203);
+ view = new DataView((new Uint8Array(intArray1)).buffer, 1);
+ assertEq(view.getUint32(0, false), 0x01020364);
+ view = new DataView((new Uint8Array(intArray1)).buffer, 2);
+ assertEq(view.getUint32(0, false), 0x02036465);
+ view = new DataView((new Uint8Array(intArray1)).buffer, 3);
+ assertEq(view.getUint32(0, false), 0x03646566);
+ view = new DataView((new Uint8Array(intArray1)).buffer, 4);
+ assertEq(view.getUint32(0, false), 0x64656667);
+ view = new DataView((new Uint8Array(intArray1)).buffer, 5);
+ assertEq(view.getUint32(0, false), 0x65666780);
+ view = new DataView((new Uint8Array(intArray1)).buffer, 6);
+ assertEq(view.getUint32(0, false), 0x66678081);
+ view = new DataView((new Uint8Array(intArray1)).buffer, 7);
+ assertEq(view.getUint32(0, false), 0x67808182);
+
+ // Test for indexing into a DataView, which should not use the ArrayBuffer storage
+ view = new DataView((new Uint8Array([1, 2])).buffer);
+ assertEq(view[0], undefined);
+ view[0] = 3;
+ assertEq(view[0], 3);
+ assertEq(view.getUint8(0), 1);
+
+ // Test WebIDL-specific class and prototype class names
+ assertEq(Object.prototype.toString.apply(new Uint8Array(0)), "[object Uint8Array]");
+ assertEq(Object.prototype.toString.apply(new Float32Array(0)), "[object Float32Array]");
+ assertEq(Object.prototype.toString.apply(new ArrayBuffer()), "[object ArrayBuffer]");
+ assertEq(Object.prototype.toString.apply(new DataView(view.buffer)), "[object DataView]");
+ assertEq(Object.prototype.toString.apply(DataView.prototype), "[object DataView]");
+
+ // Technically the spec requires these throw a TypeError -- right now. It's
+ // not clear this is desirable. Once we implement @@toStringTag we can see
+ // whether ES6's desired semantics will work.
+ assertEq(Object.prototype.toString.apply(Uint8Array.prototype), "[object Uint8ArrayPrototype]");
+ assertEq(Object.prototype.toString.apply(Float32Array.prototype), "[object Float32ArrayPrototype]");
+
+ // Same applies for %TypedArray%.prototype, except because of its newness we
+ // give it the thoroughly-inscrutable "???" as its class name so (hopefully)
+ // people won't rely on it. ("???" is the class exposed by
+ // ({ [@@toStringTag]: nonUndefinedNonStringValue }).toString(), so
+ // it has slight precedent even if it's not-to-spec.)
+ checkThrowTODO(() => {
+ var typedArrayPrototype = Object.getPrototypeOf(Float32Array.prototype);
+ assertEq(Object.prototype.toString.apply(typedArrayPrototype),
+ "[object ???]");
+ }, TypeError);
+
+ // Accessing DataView fields on DataView.prototype should crash
+ checkThrow(() => DataView.prototype.byteLength, TypeError);
+ checkThrow(() => DataView.prototype.byteOffset, TypeError);
+ checkThrow(() => DataView.prototype.buffer, TypeError);
+
+ // Protos and proxies, oh my!
+ var alien = newGlobal();
+ var alien_data = alien.eval('data = ' + data1.toSource());
+ var alien_buffer = alien.eval('buffer = new Uint8Array(data).buffer');
+ var alien_view = alien.eval('view = new DataView(buffer, 0, 16)');
+
+ // proto is view of buffer: should throw
+ var o = Object.create(view1);
+ checkThrow(() => o.getUint8(4), TypeError); // WebIDL 4.4.7: Operations
+ checkThrow(() => o.buffer, TypeError); // WebIDL 4.4.6: Attributes, section 2
+ checkThrow(() => o.byteOffset, TypeError);
+ checkThrow(() => o.byteLength, TypeError);
+
+ // proxy for view of buffer: should work
+ assertEq(alien_view.buffer.byteLength > 0, true);
+ assertEq(alien_view.getUint8(4), 100);
+
+ // Bug 753996: when throwing an Error whose message contains the name of a
+ // function, the JS engine calls js_ValueToFunction to produce the function
+ // name to include in the message. js_ValueToFunction does not unwrap its
+ // argument. So if the function is actually a wrapper, then
+ // js_ValueToFunction will throw a TypeError ("X is not a function").
+ // Confusingly, this TypeError uses the decompiler, which *will* unwrap the
+ // object to get the wrapped function name out, so the final error will
+ // look something like "SomeFunction() is not a function".)
+ var weirdo = Object.create(alien.eval("new Date"));
+ var e = null;
+ try {
+ weirdo.getTime();
+ } catch (exc) {
+ e = exc;
+ }
+ if (!e) {
+ print("==== TODO but PASSED? ====");
+ print("Bug 753996 unexpectedly passed");
+ }
+
+ // proto is proxy for view of buffer: should throw TypeError
+ //
+ // As of this writing, bug 753996 causes this to throw the *wrong*
+ // TypeError, and in fact it throws a (thisglobal).TypeError instead of
+ // alien.TypeError.
+ var av = Object.create(alien_view);
+ checkThrowTODO(() => av.getUint8(4), alien.TypeError);
+ checkThrowTODO(() => av.buffer, alien.TypeError);
+
+ // view of object whose proto is buffer. This should not work per dherman.
+ // Note that DataView throws a TypeError while TypedArrays create a
+ // zero-length view. Odd though it seems, this is correct: TypedArrays have
+ // a constructor that takes a length argument; DataViews do not. So a
+ // TypedArray will do ToUint32 and end up passing a zero as the
+ // constructor's length argument.
+ buffer = Object.create(buffer1);
+ checkThrow(() => new DataView(buffer), TypeError);
+
+ // view of proxy for buffer
+ av = new DataView(alien_buffer);
+ assertEq(av.getUint8(4), 100);
+ assertEq(Object.getPrototypeOf(av), DataView.prototype);
+
+ // Bug 760904: call another compartment's constructor with an ArrayBuffer
+ // from this compartment.
+ var alien_constructor = alien.DataView;
+ var local_buffer = (new Int8Array(3)).buffer;
+ var foreign_exchange_student = new alien_constructor(local_buffer);
+
+ // gc bug 787775
+ var ab = new ArrayBuffer(4);
+ var dv = new DataView(ab);
+ dv = 1;
+ gc();
+
+ reportCompare(0, 0, 'done.');
+ exitFunc ('test');
+}
+
+test();
diff --git a/js/src/tests/js1_8_5/extensions/decompile-for-of.js b/js/src/tests/js1_8_5/extensions/decompile-for-of.js
new file mode 100644
index 000000000..b99e20a40
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/decompile-for-of.js
@@ -0,0 +1,27 @@
+// The decompiler can handle the implicit call to @@iterator in a for-of loop.
+
+var x;
+function check(code, msg) {
+ var s = "no exception thrown";
+ try {
+ eval(code);
+ } catch (exc) {
+ s = exc.message;
+ }
+
+ assertEq(s, msg);
+}
+
+x = {};
+check("for (var v of x) throw fit;", "x is not iterable");
+check("[...x]", "x is not iterable");
+check("Math.hypot(...x)", "x is not iterable");
+
+x[Symbol.iterator] = "potato";
+check("for (var v of x) throw fit;", "x is not iterable");
+
+x[Symbol.iterator] = {};
+check("for (var v of x) throw fit;", "x[Symbol.iterator] is not a function");
+
+if (typeof reportCompare === "function")
+ reportCompare(0, 0, "ok");
diff --git a/js/src/tests/js1_8_5/extensions/destructure-accessor.js b/js/src/tests/js1_8_5/extensions/destructure-accessor.js
new file mode 100644
index 000000000..e8c57bb93
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/destructure-accessor.js
@@ -0,0 +1,75 @@
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+var gTestfile = 'destructure-accessor.js';
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 536472;
+var summary =
+ 'ES5: { get x(v) { } } and { set x(v, v2) { } } should be syntax errors';
+
+print(BUGNUMBER + ": " + summary);
+
+//-----------------------------------------------------------------------------
+
+function expectOk(s)
+{
+ try
+ {
+ eval(s);
+ return;
+ }
+ catch (e)
+ {
+ assertEq(true, false,
+ "expected no error parsing '" + "', got : " + e);
+ }
+}
+
+function expectSyntaxError(s)
+{
+ try
+ {
+ eval(s);
+ throw new Error("no error thrown");
+ }
+ catch (e)
+ {
+ assertEq(e instanceof SyntaxError, true,
+ "expected syntax error parsing '" + s + "', got: " + e);
+ }
+}
+
+expectSyntaxError("({ get x([]) { } })");
+expectSyntaxError("({ get x({}) { } })");
+expectSyntaxError("({ get x(a, []) { } })");
+expectSyntaxError("({ get x(a, {}) { } })");
+expectSyntaxError("({ get x([], a) { } })");
+expectSyntaxError("({ get x({}, a) { } })");
+expectSyntaxError("({ get x([], a, []) { } })");
+expectSyntaxError("({ get x([], a, {}) { } })");
+expectSyntaxError("({ get x({}, a, []) { } })");
+expectSyntaxError("({ get x({}, a, {}) { } })");
+
+expectOk("({ get x() { } })");
+
+
+expectSyntaxError("({ set x() { } })");
+expectSyntaxError("({ set x(a, []) { } })");
+expectSyntaxError("({ set x(a, b, c) { } })");
+
+expectOk("({ set x([]) { } })");
+expectOk("({ set x({}) { } })");
+expectOk("({ set x([a]) { } })");
+expectOk("({ set x([a, b]) { } })");
+expectOk("({ set x([a,]) { } })");
+expectOk("({ set x([a, b,]) { } })");
+expectOk("({ set x([, b]) { } })");
+expectOk("({ set x([, b,]) { } })");
+expectOk("({ set x([, b, c]) { } })");
+expectOk("({ set x([, b, c,]) { } })");
+expectOk("({ set x({ a: a }) { } })");
+expectOk("({ set x({ a: a, b: b }) { } })");
+
+//-----------------------------------------------------------------------------
+
+reportCompare(true, true);
diff --git a/js/src/tests/js1_8_5/extensions/empty.txt b/js/src/tests/js1_8_5/extensions/empty.txt
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/empty.txt
diff --git a/js/src/tests/js1_8_5/extensions/file-mapped-arraybuffers.js b/js/src/tests/js1_8_5/extensions/file-mapped-arraybuffers.js
new file mode 100644
index 000000000..cea0cd799
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/file-mapped-arraybuffers.js
@@ -0,0 +1,41 @@
+// |reftest| skip-if(!xulRuntime.shell)
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+function viewToString(view)
+{
+ return String.fromCharCode.apply(null, view);
+}
+
+function assertThrows(f, wantException)
+{
+ try {
+ f();
+ assertEq(true, false, "expected " + wantException + " exception");
+ } catch (e) {
+ assertEq(e.name, wantException.name, e.toString());
+ }
+}
+
+function test() {
+ var filename = "file-mapped-arraybuffers.txt";
+ var buffer = createMappedArrayBuffer(filename);
+ var view = new Uint8Array(buffer);
+ assertEq(viewToString(view), "01234567abcdefghijkl");
+
+ var buffer2 = createMappedArrayBuffer(filename, 8);
+ view = new Uint8Array(buffer2);
+ assertEq(viewToString(view), "abcdefghijkl");
+
+ var buffer3 = createMappedArrayBuffer(filename, 0, 8);
+ view = new Uint8Array(buffer3);
+ assertEq(viewToString(view), "01234567");
+
+ // Check that invalid sizes and offsets are caught
+ assertThrows(() => createMappedArrayBuffer("empty.txt", 8), RangeError);
+ assertThrows(() => createMappedArrayBuffer("empty.txt", 0, 8), Error);
+}
+
+if (getBuildConfiguration()["mapped-array-buffer"])
+ test();
+reportCompare(0, 0, 'ok');
diff --git a/js/src/tests/js1_8_5/extensions/file-mapped-arraybuffers.txt b/js/src/tests/js1_8_5/extensions/file-mapped-arraybuffers.txt
new file mode 100644
index 000000000..4289a17b8
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/file-mapped-arraybuffers.txt
@@ -0,0 +1 @@
+01234567abcdefghijkl \ No newline at end of file
diff --git a/js/src/tests/js1_8_5/extensions/is-generator.js b/js/src/tests/js1_8_5/extensions/is-generator.js
new file mode 100644
index 000000000..6c77adda8
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/is-generator.js
@@ -0,0 +1,23 @@
+/*
+ * Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/licenses/publicdomain/
+ */
+
+/*
+ * Bug 648355: Function.prototype.isGenerator
+ */
+
+reportCompare(true, "isGenerator" in Function.prototype, "Function.prototype.isGenerator present");
+
+reportCompare(false, (function(){}).isGenerator(), "lambda is not a generator fn");
+reportCompare(false, Function.prototype.toString.isGenerator(), "native is not a generator fn");
+reportCompare(false, (function(){with(obj){}}).isGenerator(), "heavyweight is not a generator fn");
+reportCompare(false, (function(){obj}).isGenerator(), "upvar function is not a generator fn");
+
+reportCompare(true, (function(){yield}).isGenerator(), "simple generator fn");
+reportCompare(true, (function(){with(obj){yield}}).isGenerator(), "heavyweight generator fn");
+reportCompare(true, (function(){yield; obj}).isGenerator(), "upvar generator fn");
+
+reportCompare(false, Function.prototype.isGenerator.call(42), "number is not a generator fn");
+reportCompare(false, Function.prototype.isGenerator.call({}), "vanilla object is not a generator fn");
+reportCompare(false, Function.prototype.isGenerator.call(new Date()), "date object is not a generator fn");
diff --git a/js/src/tests/js1_8_5/extensions/mutable-proto-special-form.js b/js/src/tests/js1_8_5/extensions/mutable-proto-special-form.js
new file mode 100644
index 000000000..b196507f2
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/mutable-proto-special-form.js
@@ -0,0 +1,91 @@
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 948583;
+var summary =
+ "Make __proto__ in object literals a special form not influenced by " +
+ "|Object.prototype|";
+
+print(BUGNUMBER + ": " + summary);
+
+/**************
+ * BEGIN TEST *
+ **************/
+
+var passed = true;
+
+function performProtoTests(msg)
+{
+ print("Testing " + msg);
+ assertEq(passed, true, "passed wrong at start of test set");
+
+ assertEq(Object.getPrototypeOf({ __proto__: null }), null);
+ assertEq(Object.getPrototypeOf({ __proto__: undefined }), Object.prototype);
+ assertEq(Object.getPrototypeOf({ __proto__: 17 }), Object.prototype);
+
+ var obj = {};
+ assertEq(Object.getPrototypeOf({ __proto__: obj }), obj);
+
+ assertEq(passed, true, "passed wrong at end of test set");
+ print("Tests of " + msg + " passed!");
+}
+
+function poisonProto(obj)
+{
+ Object.defineProperty(obj, "__proto__",
+ {
+ configurable: true,
+ enumerable: true,
+ set: function(v) { passed = false; },
+ });
+}
+
+performProtoTests("initial behavior");
+
+var desc = Object.getOwnPropertyDescriptor(Object.prototype, "__proto__");
+var setProto = desc.set;
+delete Object.prototype.__proto__;
+
+performProtoTests("behavior after Object.prototype.__proto__ deletion");
+
+Object.defineProperty(Object.prototype, "__proto__",
+ {
+ configurable: true,
+ enumerable: false,
+ set: function(v) { passed = false; },
+ });
+
+performProtoTests("behavior after making Object.prototype.__proto__ a " +
+ "custom setter");
+
+Object.defineProperty(Object.prototype, "__proto__", { set: undefined });
+
+performProtoTests("behavior after making Object.prototype.__proto__'s " +
+ "[[Set]] === undefined");
+
+try
+{
+ var superProto = Object.create(null);
+ poisonProto(superProto);
+ setProto.call(Object.prototype, superProto);
+
+ performProtoTests("behavior after mutating Object.prototype.[[Prototype]]");
+
+ // Note: The handler below will have to be updated to exempt a scriptable
+ // getPrototypeOf trap (to instead consult the target whose [[Prototype]]
+ // is safely non-recursive), if we ever implement one.
+ var death = new Proxy(Object.create(null),
+ new Proxy({}, { get: function() { passed = false; } }));
+
+ setProto.call(Object.prototype, death);
+
+ performProtoTests("behavior after making Object.prototype.[[Prototype]] a " +
+ "proxy that throws for any access");
+}
+catch (e) {}
+
+if (typeof reportCompare === "function")
+ reportCompare(true, true);
+
+print("Tests complete");
diff --git a/js/src/tests/js1_8_5/extensions/object-toSource-undefined-getter.js b/js/src/tests/js1_8_5/extensions/object-toSource-undefined-getter.js
new file mode 100644
index 000000000..a207e00c9
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/object-toSource-undefined-getter.js
@@ -0,0 +1,9 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/licenses/publicdomain/ */
+
+var desc = { get: undefined, set: undefined, configurable: true, enumerable: true };
+var obj = Object.defineProperty({}, "prop", desc);
+assertEq(obj.toSource(), "({})");
+
+if (typeof reportCompare === "function")
+ reportCompare(0, 0);
diff --git a/js/src/tests/js1_8_5/extensions/object-toSource-with-symbol-keys.js b/js/src/tests/js1_8_5/extensions/object-toSource-with-symbol-keys.js
new file mode 100644
index 000000000..cbd019e1e
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/object-toSource-with-symbol-keys.js
@@ -0,0 +1,14 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/licenses/publicdomain/ */
+
+var obj = {};
+obj[Symbol.iterator] = 1;
+assertEq(obj.toSource(), "({[Symbol.iterator]:1})");
+obj[Symbol(undefined)] = 2;
+obj[Symbol('ponies')] = 3;
+obj[Symbol.for('ponies')] = 4;
+assertEq(obj.toSource(),
+ '({[Symbol.iterator]:1, [Symbol()]:2, [Symbol("ponies")]:3, [Symbol.for("ponies")]:4})');
+
+if (typeof reportCompare === "function")
+ reportCompare(0, 0);
diff --git a/js/src/tests/js1_8_5/extensions/proxy-proto-setter.js b/js/src/tests/js1_8_5/extensions/proxy-proto-setter.js
new file mode 100644
index 000000000..37e620cd1
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/proxy-proto-setter.js
@@ -0,0 +1,50 @@
+// |reftest| skip-if(!xulRuntime.shell)
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+// Contributor: Blake Kaplan
+
+function expect(actual, arg) {
+ reportCompare(expect.expected, actual, arg);
+}
+
+var window = { set x(y) { expect(this, y) }, y: 4 };
+expect.expected = window;
+window.x = "setting through a setter directly";
+window.y = 5;
+reportCompare(5, window.y, "setting properties works");
+var easy = { easy: 'yes', __proto__: window }
+expect.expected = easy;
+easy.x = "setting through a setter all-native on prototype";
+easy.y = 6;
+reportCompare(5, window.y, "window.y remains as it was");
+reportCompare(6, easy.y, "shadowing works properly");
+
+var sandbox = evalcx('');
+sandbox.window = window;
+sandbox.print = print;
+sandbox.expect = expect;
+var hard = evalcx('Object.create(window)', sandbox);
+expect.expected = hard;
+hard.x = "a setter through proxy -> native";
+hard.y = 6;
+reportCompare(5, window.y, "window.y remains as it was through a proxy");
+reportCompare(6, hard.y, "shadowing works on proxies");
+
+hard.__proto__ = { 'passed': true }
+reportCompare(true, hard.passed, "can set proxy.__proto__ through a native");
+
+var inverse = evalcx('({ set x(y) { expect(this, y); }, y: 4 })', sandbox);
+expect.expected = inverse;
+inverse.x = "setting through a proxy directly";
+inverse.y = 5;
+reportCompare(5, inverse.y, "setting properties works on proxies");
+
+var inversehard = Object.create(inverse);
+expect.expected = inversehard;
+inversehard.x = "setting through a setter with a proxy on the proto chain";
+inversehard.y = 6;
+reportCompare(5, inverse.y, "inverse.y remains as it was");
+reportCompare(6, inversehard.y, "shadowing works native -> proxy");
+
+inversehard.__proto__ = { 'passed': true }
+reportCompare(true, inversehard.passed, "can set native.__proto__ through a proxy");
diff --git a/js/src/tests/js1_8_5/extensions/recursion.js b/js/src/tests/js1_8_5/extensions/recursion.js
new file mode 100644
index 000000000..339e11202
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/recursion.js
@@ -0,0 +1,60 @@
+/*
+ * Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/licenses/publicdomain/
+ * Contributor:
+ * Christian Holler <decoder@own-hero.net>
+ */
+
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 622167;
+var summary = 'Handle infinite recursion';
+print(BUGNUMBER + ": " + summary);
+
+/**************
+ * BEGIN TEST *
+ **************/
+
+function eval() { eval(); }
+
+function DoWhile_3()
+{
+ eval();
+}
+
+try
+{
+ DoWhile_3();
+}
+catch(e) { }
+
+var r;
+function f()
+{
+ r = arguments;
+ test();
+ yield 170;
+}
+
+function test()
+{
+ function foopy()
+ {
+ try
+ {
+ for (var i in f());
+ }
+ catch (e)
+ {
+ gc();
+ }
+ }
+ foopy();
+}
+test();
+
+/******************************************************************************/
+
+if (typeof reportCompare === "function")
+ reportCompare(true, true);
+
+print("All tests passed!");
diff --git a/js/src/tests/js1_8_5/extensions/redeclaration-of-catch-warning.js b/js/src/tests/js1_8_5/extensions/redeclaration-of-catch-warning.js
new file mode 100644
index 000000000..30d1a201e
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/redeclaration-of-catch-warning.js
@@ -0,0 +1,37 @@
+// |reftest| skip-if(!xulRuntime.shell)
+//
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 622646;
+var summary = "Shadowing an exception identifier in a catch block with a " +
+ "|const| or |let| declaration should throw an error";
+
+print(BUGNUMBER + ": " + summary);
+
+/**************
+ * BEGIN TEST *
+ **************/
+
+options("strict");
+
+function assertRedeclarationErrorThrown(expression)
+{
+ try
+ {
+ evaluate(expression);
+ throw new Error("Redeclaration error wasn't thrown");
+ }
+ catch(e)
+ {
+ assertEq(e.message.indexOf("catch") > 0, true,
+ "wrong error, got " + e.message);
+ }
+}
+
+assertRedeclarationErrorThrown("try {} catch(e) { const e = undefined; }");
+assertRedeclarationErrorThrown("try {} catch(e) { let e; }");
+
+if (typeof reportCompare === "function")
+ reportCompare(true, true);
diff --git a/js/src/tests/js1_8_5/extensions/regress-558541.js b/js/src/tests/js1_8_5/extensions/regress-558541.js
new file mode 100644
index 000000000..a6a40037a
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/regress-558541.js
@@ -0,0 +1,12 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 4 -*- */
+/*
+ * Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/licenses/publicdomain/
+ * Contributor: Jeff Walden <jwalden+code@mit.edu>
+ */
+
+options("strict");
+for (var i = 0; i < 5; i++)
+ Boolean.prototype = 42;
+
+reportCompare(true, true);
diff --git a/js/src/tests/js1_8_5/extensions/regress-604781-1.js b/js/src/tests/js1_8_5/extensions/regress-604781-1.js
new file mode 100644
index 000000000..a7c43f95d
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/regress-604781-1.js
@@ -0,0 +1,24 @@
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+var watcherCount, setterCount;
+function watcher(id, oldval, newval) { watcherCount++; return newval; }
+function setter(newval) { setterCount++; }
+
+var p = { set x(v) { setter(v); } };
+p.watch('x', watcher);
+
+watcherCount = setterCount = 0;
+p.x = 2;
+assertEq(setterCount, 1);
+assertEq(watcherCount, 1);
+
+var o = Object.defineProperty({}, 'x', { set:setter, enumerable:true, configurable:true });
+o.watch('x', watcher);
+
+watcherCount = setterCount = 0;
+o.x = 2;
+assertEq(setterCount, 1);
+assertEq(watcherCount, 1);
+
+reportCompare(0, 0, 'ok');
diff --git a/js/src/tests/js1_8_5/extensions/regress-604781-2.js b/js/src/tests/js1_8_5/extensions/regress-604781-2.js
new file mode 100644
index 000000000..7aba4a274
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/regress-604781-2.js
@@ -0,0 +1,13 @@
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+var log;
+function watcher(id, old, newval) { log += 'watcher'; return newval; }
+var o = { set x(v) { log += 'setter'; } };
+o.watch('x', watcher);
+Object.defineProperty(o, 'x', {value: 3, writable: true});
+log = '';
+o.x = 3;
+assertEq(log, 'watcher');
+
+reportCompare(0, 0, 'ok');
diff --git a/js/src/tests/js1_8_5/extensions/regress-627984-1.js b/js/src/tests/js1_8_5/extensions/regress-627984-1.js
new file mode 100644
index 000000000..a3726630a
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/regress-627984-1.js
@@ -0,0 +1,16 @@
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+// See bug 627984, comment 17, item 1.
+var obj;
+var methods = [];
+for (var i = 0; i < 2; i++) {
+ obj = {m: function () { return this.x; }};
+ obj.watch("m", function (id, oldval, newval) { methods[i] = oldval; });
+ obj.m = 0;
+}
+assertEq(typeof methods[0], "function");
+assertEq(typeof methods[1], "function");
+assertEq(methods[0] !== methods[1], true);
+
+reportCompare(0, 0, 'ok');
diff --git a/js/src/tests/js1_8_5/extensions/regress-627984-2.js b/js/src/tests/js1_8_5/extensions/regress-627984-2.js
new file mode 100644
index 000000000..c4f1b508c
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/regress-627984-2.js
@@ -0,0 +1,15 @@
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+// See bug 627984, comment 17, item 2.
+var obj = {};
+var x;
+obj.watch("m", function (id, oldval, newval) {
+ x = this.m;
+ return newval;
+ });
+delete obj.m;
+obj.m = function () { return this.method; };
+obj.m = 2;
+
+reportCompare(0, 0, 'ok');
diff --git a/js/src/tests/js1_8_5/extensions/regress-627984-3.js b/js/src/tests/js1_8_5/extensions/regress-627984-3.js
new file mode 100644
index 000000000..cbe4e10fa
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/regress-627984-3.js
@@ -0,0 +1,14 @@
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+// Don't write string value to method slot.
+// See bug 627984, comment 17, item 2.
+var obj = {};
+obj.watch("m", function (id, oldval, newval) {
+ return 'ok';
+ });
+delete obj.m;
+obj.m = function () { return this.x; };
+assertEq(obj.m, 'ok');
+
+reportCompare(0, 0, 'ok');
diff --git a/js/src/tests/js1_8_5/extensions/regress-627984-4.js b/js/src/tests/js1_8_5/extensions/regress-627984-4.js
new file mode 100644
index 000000000..bbc017ffb
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/regress-627984-4.js
@@ -0,0 +1,15 @@
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+// See bug 627984, comment 17, item 3.
+var obj = {};
+obj.watch("m", function (id, oldval, newval) {
+ delete obj.m;
+ obj.m = function () {};
+ return newval;
+ });
+delete obj.m;
+obj.m = 1;
+assertEq(obj.m, 1);
+
+reportCompare(0, 0, 'ok');
diff --git a/js/src/tests/js1_8_5/extensions/regress-627984-5.js b/js/src/tests/js1_8_5/extensions/regress-627984-5.js
new file mode 100644
index 000000000..704d8421c
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/regress-627984-5.js
@@ -0,0 +1,13 @@
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+// Bug 627984 comment 11.
+var o = ({});
+o.p = function() {};
+o.watch('p', function() { });
+o.q = function() {}
+delete o.p;
+o.p = function() {};
+assertEq(o.p, void 0);
+
+reportCompare(0, 0, 'ok');
diff --git a/js/src/tests/js1_8_5/extensions/regress-627984-6.js b/js/src/tests/js1_8_5/extensions/regress-627984-6.js
new file mode 100644
index 000000000..cb1a0fca9
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/regress-627984-6.js
@@ -0,0 +1,15 @@
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+// Bug 627984 description.
+var o = Array;
+o.p = function() {};
+o.watch('p', function() { });
+for(var x in o) {
+ o[x];
+}
+delete o.p;
+o.p = function() {};
+assertEq(o.p, void 0);
+
+reportCompare(0, 0, 'ok');
diff --git a/js/src/tests/js1_8_5/extensions/regress-627984-7.js b/js/src/tests/js1_8_5/extensions/regress-627984-7.js
new file mode 100644
index 000000000..b13a0e912
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/regress-627984-7.js
@@ -0,0 +1,9 @@
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+// See bug 627984 comment 20.
+var obj = {m: function () {}};
+obj.watch("m", function () { throw 'FAIL'; });
+var f = obj.m; // don't call the watchpoint
+
+reportCompare(0, 0, 'ok');
diff --git a/js/src/tests/js1_8_5/extensions/regress-631723.js b/js/src/tests/js1_8_5/extensions/regress-631723.js
new file mode 100644
index 000000000..f7c755603
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/regress-631723.js
@@ -0,0 +1,10 @@
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+var o = {a:1, b:2};
+o.watch("p", function() { return 13; });
+delete o.p;
+o.p = 0;
+assertEq(o.p, 13);
+
+reportCompare(0, 0, 'ok');
diff --git a/js/src/tests/js1_8_5/extensions/regress-636697.js b/js/src/tests/js1_8_5/extensions/regress-636697.js
new file mode 100644
index 000000000..6b3b1de37
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/regress-636697.js
@@ -0,0 +1,11 @@
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+var a = {set p(x) {}};
+a.watch('p', function () {});
+var b = Object.create(a);
+b.watch('p', function () {});
+delete b.p;
+b.p = 0;
+
+reportCompare(0, 0, 'ok');
diff --git a/js/src/tests/js1_8_5/extensions/regress-636818.js b/js/src/tests/js1_8_5/extensions/regress-636818.js
new file mode 100644
index 000000000..9fa1bc379
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/regress-636818.js
@@ -0,0 +1,9 @@
+// |reftest| skip-if(!xulRuntime.shell)
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+a = evalcx('');
+a.__proto__ = ''.__proto__;
+a.length = 3; // don't assert
+
+reportCompare(0, 0, 'ok');
diff --git a/js/src/tests/js1_8_5/extensions/regress-637985.js b/js/src/tests/js1_8_5/extensions/regress-637985.js
new file mode 100644
index 000000000..305bfc820
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/regress-637985.js
@@ -0,0 +1,8 @@
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+var obj = {};
+obj.watch(-1, function(){});
+obj.unwatch("-1"); // don't assert
+
+reportCompare(0, 0, 'ok'); \ No newline at end of file
diff --git a/js/src/tests/js1_8_5/extensions/regress-645160.js b/js/src/tests/js1_8_5/extensions/regress-645160.js
new file mode 100644
index 000000000..933d3e261
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/regress-645160.js
@@ -0,0 +1,8 @@
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+function potatoMasher(obj, arg) { this.eval(arg); }
+potatoMasher(this, "var s = Error().stack");
+assertEq(/potatoMasher/.exec(s) instanceof Array, true);
+
+reportCompare(0, 0, 'ok');
diff --git a/js/src/tests/js1_8_5/extensions/regress-650753.js b/js/src/tests/js1_8_5/extensions/regress-650753.js
new file mode 100644
index 000000000..a518ec52a
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/regress-650753.js
@@ -0,0 +1,8 @@
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+var x = {}, h = new WeakMap;
+h.set(x, null);
+gc();
+
+reportCompare(0, 0, 'ok');
diff --git a/js/src/tests/js1_8_5/extensions/regress-677589.js b/js/src/tests/js1_8_5/extensions/regress-677589.js
new file mode 100644
index 000000000..0bdb2e79f
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/regress-677589.js
@@ -0,0 +1,10 @@
+// |reftest| skip-if(!xulRuntime.shell)
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+try {
+ clone(null); // don't crash
+} catch (exc if exc instanceof TypeError) {
+}
+
+reportCompare(0, 0, 'ok');
diff --git a/js/src/tests/js1_8_5/extensions/regress-677924.js b/js/src/tests/js1_8_5/extensions/regress-677924.js
new file mode 100644
index 000000000..2323fab4f
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/regress-677924.js
@@ -0,0 +1,14 @@
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+try {
+ version(4096); // don't assert
+} catch (exc) {
+}
+
+try {
+ version(-1); // don't assert
+} catch (exc) {
+}
+
+reportCompare(0, 0, 'ok');
diff --git a/js/src/tests/js1_8_5/extensions/regress-691746.js b/js/src/tests/js1_8_5/extensions/regress-691746.js
new file mode 100644
index 000000000..26f732d07
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/regress-691746.js
@@ -0,0 +1,11 @@
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+var obj = {};
+try {
+ obj.watch(QName(), function () {});
+} catch (exc) {
+}
+gc();
+
+reportCompare(0, 0, 'ok');
diff --git a/js/src/tests/js1_8_5/extensions/regress-696109.js b/js/src/tests/js1_8_5/extensions/regress-696109.js
new file mode 100644
index 000000000..4a56340d3
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/regress-696109.js
@@ -0,0 +1,13 @@
+// |reftest| skip-if(!xulRuntime.shell)
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/licenses/publicdomain/
+ * Contributor: Dave Herman <dherman@mozilla.com>
+ */
+
+// Bug 696109 - fixed a precedence bug in with/while nodes
+Reflect.parse("with({foo})bar");
+Reflect.parse("while({foo})bar");
+
+reportCompare(true, true);
diff --git a/js/src/tests/js1_8_5/extensions/selfhosted-detecting-strict.js b/js/src/tests/js1_8_5/extensions/selfhosted-detecting-strict.js
new file mode 100644
index 000000000..cb4c026ea
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/selfhosted-detecting-strict.js
@@ -0,0 +1,27 @@
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 843004;
+var summary =
+ "Don't emit a strict warning for the undefined-property detection pattern in self-hosted code";
+
+print(BUGNUMBER + ": " + summary);
+
+/**************
+ * BEGIN TEST *
+ **************/
+
+options("strict", "werror");
+
+// Don't strict-warn (and throw, because of strict) when self-hosted code uses
+// detecting-safe undefined-property accesses (|options.weekday !== undefined|
+// and similar in ToDateTimeOptions, to be precise).
+new Date().toLocaleString("en-US", {});
+
+// If we get here, the test passed.
+
+if (typeof reportCompare === "function")
+ reportCompare(true, true);
+
+print("Tests complete");
diff --git a/js/src/tests/js1_8_5/extensions/set-property-non-extensible.js b/js/src/tests/js1_8_5/extensions/set-property-non-extensible.js
new file mode 100644
index 000000000..3d077356a
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/set-property-non-extensible.js
@@ -0,0 +1,30 @@
+// |reftest| skip
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 600128;
+var summary =
+ "Properly handle attempted addition of properties to non-extensible objects";
+
+print(BUGNUMBER + ": " + summary);
+
+/**************
+ * BEGIN TEST *
+ **************/
+
+var o = Object.freeze({});
+for (var i = 0; i < 10; i++)
+ print(o.u = "");
+
+Object.freeze(this);
+for (let j = 0; j < 10; j++)
+ print(u = "");
+
+
+/******************************************************************************/
+
+if (typeof reportCompare === "function")
+ reportCompare(true, true);
+
+print("All tests passed!");
diff --git a/js/src/tests/js1_8_5/extensions/sharedtypedarray.js b/js/src/tests/js1_8_5/extensions/sharedtypedarray.js
new file mode 100644
index 000000000..68388ed86
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/sharedtypedarray.js
@@ -0,0 +1,263 @@
+// |reftest| skip-if(!xulRuntime.shell)
+/* -*- Mode: js2; tab-width: 40; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/*
+ * Any copyright is dedicated to the Public Domain.
+ * https://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+// Minimal test cases. Note that on 64-bit a SharedArrayBuffer is
+// very expensive under these rules - a 4GB area is reserved for it.
+// So don't go allocating a ton of them.
+//
+// These tests cannot test that sharing works across workers. There
+// are or will be tests, in dom/workers, that do that.
+
+if (!this.SharedArrayBuffer) {
+ reportCompare(true,true);
+ quit(0);
+}
+
+var b;
+
+function testSharedArrayBuffer() {
+ b = new SharedArrayBuffer("4096"); // Test string conversion, too
+ assertEq(b instanceof SharedArrayBuffer, true);
+ assertEq(b.byteLength, 4096);
+
+ b.fnord = "Hi there";
+ assertEq(b.fnord, "Hi there");
+
+ SharedArrayBuffer.prototype.abracadabra = "no wishing for wishes!";
+ assertEq(b.abracadabra, "no wishing for wishes!");
+
+ // SharedArrayBuffer is not a conversion operator, not even for instances of itself
+ assertThrowsInstanceOf(() => SharedArrayBuffer(b), TypeError);
+
+ // can't convert any other object either
+ assertThrowsInstanceOf(() => SharedArrayBuffer({}), TypeError);
+
+ // byteLength can be invoked as per normal, indirectly
+ assertEq(Object.getOwnPropertyDescriptor(SharedArrayBuffer.prototype,"byteLength").get.call(b), 4096);
+
+ // however byteLength is not generic
+ assertThrowsInstanceOf(() => Object.getOwnPropertyDescriptor(SharedArrayBuffer.prototype,"byteLength").get.call({}), TypeError);
+
+}
+
+function testSharedTypedArray() {
+ var x1 = new Int8Array(b);
+ var x2 = new Int32Array(b);
+
+ assertEq(ArrayBuffer.isView(x1), true); // ArrayBuffer.isView() works even if the buffer is a SharedArrayBuffer
+ assertEq(ArrayBuffer.isView(x2), true);
+ assertEq(ArrayBuffer.isView({}), false);
+
+ assertEq(x1.buffer, b);
+ assertEq(x2.buffer, b);
+
+ assertEq(x1.byteLength, b.byteLength);
+ assertEq(x2.byteLength, b.byteLength);
+
+ assertEq(x1.byteOffset, 0);
+ assertEq(x2.byteOffset, 0);
+
+ assertEq(x1.length, b.byteLength);
+ assertEq(x2.length, b.byteLength / 4);
+
+ var x3 = new Int8Array(b, 20);
+ assertEq(x3.length, b.byteLength - 20);
+ assertEq(x3.byteOffset, 20);
+
+ var x3 = new Int32Array(b, 20, 10);
+ assertEq(x3.length, 10);
+ assertEq(x3.byteOffset, 20);
+
+ // Mismatched type
+ assertThrowsInstanceOf(() => Int8Array(x2), TypeError);
+
+ // Unconvertable object
+ assertThrowsInstanceOf(() => Int8Array({}), TypeError);
+
+ // negative start
+ assertThrowsInstanceOf(() => new Int8Array(b, -7), RangeError);
+
+ // not congruent mod element size
+ assertThrowsInstanceOf(() => new Int32Array(b, 3), RangeError);
+
+ // start out of range
+ assertThrowsInstanceOf(() => new Int32Array(b, 4104), RangeError);
+
+ // end out of range
+ assertThrowsInstanceOf(() => new Int32Array(b, 4092, 2), RangeError);
+
+ // Views alias the storage
+ x2[0] = -1;
+ assertEq(x1[0], -1);
+ x1[0] = 1;
+ x1[1] = 1;
+ x1[2] = 1;
+ x1[3] = 1;
+ assertEq(x2[0], 0x01010101);
+
+ assertEq(x2[5], 0);
+ x3[0] = -1;
+ assertEq(x2[5], -1);
+
+ // Out-of-range accesses yield undefined
+ assertEq(x2[1023], 0);
+ assertEq(x2[1024], undefined);
+ assertEq(x2[2047], undefined);
+}
+
+function testSharedTypedArrayMethods() {
+ var v = new Int32Array(b);
+ for ( var i=0 ; i < v.length ; i++ )
+ v[i] = i;
+
+ // Rudimentary tests - they don't test any boundary conditions
+
+ // subarray
+ var w = v.subarray(10, 20);
+ assertEq(w.length, 10);
+ for ( var i=0 ; i < w.length ; i++ )
+ assertEq(w[i], v[i+10]);
+ for ( var i=0 ; i < w.length ; i++ )
+ w[i] = -w[i];
+ for ( var i=0 ; i < w.length ; i++ )
+ assertEq(w[i], v[i+10]);
+
+ // copyWithin
+ for ( var i=0 ; i < v.length ; i++ )
+ v[i] = i;
+ v.copyWithin(10, 20, 30);
+ for ( var i=0 ; i < 10 ; i++ )
+ assertEq(v[i], i);
+ for ( var i=10 ; i < 20 ; i++ )
+ assertEq(v[i], v[i+10]);
+
+ // set
+ for ( var i=0 ; i < v.length ; i++ )
+ v[i] = i;
+ v.set([-1,-2,-3,-4,-5,-6,-7,-8,-9,-10], 5);
+ for ( var i=5 ; i < 15 ; i++ )
+ assertEq(v[i], -i+4);
+
+ // In the following two cases the two arrays will reference the same buffer,
+ // so there will be an overlapping copy.
+ //
+ // Case 1: Read from lower indices than are written
+ v.set(v.subarray(0, 7), 1);
+ assertEq(v[0], 0);
+ assertEq(v[1], 0);
+ assertEq(v[2], 1);
+ assertEq(v[3], 2);
+ assertEq(v[4], 3);
+ assertEq(v[5], 4);
+ assertEq(v[6], -1);
+ assertEq(v[7], -2);
+ assertEq(v[8], -4);
+ assertEq(v[9], -5);
+
+ // Case 2: Read from higher indices than are written
+ v.set(v.subarray(1, 5), 0);
+ assertEq(v[0], 0);
+ assertEq(v[1], 1);
+ assertEq(v[2], 2);
+ assertEq(v[3], 3);
+ assertEq(v[4], 3);
+ assertEq(v[5], 4);
+ assertEq(v[6], -1);
+ assertEq(v[7], -2);
+ assertEq(v[8], -4);
+ assertEq(v[9], -5);
+}
+
+function testClone1() {
+ var sab1 = b;
+ var blob = serialize(sab1, []);
+ var sab2 = deserialize(blob);
+ if (typeof sharedAddress != "undefined")
+ assertEq(sharedAddress(sab1), sharedAddress(sab2));
+}
+
+function testClone2() {
+ var sab = b;
+ var ia1 = new Int32Array(sab);
+ var blob = serialize(ia1, []);
+ var ia2 = deserialize(blob);
+ assertEq(ia1.length, ia2.length);
+ assertEq(ia1.buffer instanceof SharedArrayBuffer, true);
+ if (typeof sharedAddress != "undefined")
+ assertEq(sharedAddress(ia1.buffer), sharedAddress(ia2.buffer));
+ ia1[10] = 37;
+ assertEq(ia2[10], 37);
+}
+
+// Serializing a SharedArrayBuffer should fail if we've set its flag to 'deny' or if
+// the flag is bogus.
+
+function testNoClone() {
+ // This just tests the API in serialize()
+ assertThrowsInstanceOf(() => serialize(b, [], {SharedArrayBuffer: false}), Error);
+
+ // This tests the actual cloning functionality - should fail
+ assertThrowsInstanceOf(() => serialize(b, [], {SharedArrayBuffer: 'deny'}), TypeError);
+
+ // Ditto - should succeed
+ assertEq(typeof serialize(b, [], {SharedArrayBuffer: 'allow'}), "object");
+}
+
+// Eventually, this will be prohibited, but for now, allow the SAB to
+// appear in the transfer list. See bug 1302036 and bug 1302037.
+
+function testRedundantTransfer() {
+ var sab1 = b;
+ var blob = serialize(sab1, [sab1]);
+ var sab2 = deserialize(blob);
+ if (typeof sharedAddress != "undefined")
+ assertEq(sharedAddress(sab1), sharedAddress(sab2));
+}
+
+function testApplicable() {
+ var sab = b;
+ var x;
+
+ // Just make sure we can create all the view types on shared memory.
+
+ x = new Int32Array(sab);
+ assertEq(x.length, sab.byteLength / Int32Array.BYTES_PER_ELEMENT);
+ x = new Uint32Array(sab);
+ assertEq(x.length, sab.byteLength / Uint32Array.BYTES_PER_ELEMENT);
+
+ x = new Int16Array(sab);
+ assertEq(x.length, sab.byteLength / Int16Array.BYTES_PER_ELEMENT);
+ x = new Uint16Array(sab);
+ assertEq(x.length, sab.byteLength / Uint16Array.BYTES_PER_ELEMENT);
+
+ x = new Int8Array(sab);
+ assertEq(x.length, sab.byteLength / Int8Array.BYTES_PER_ELEMENT);
+ x = new Uint8Array(sab);
+ assertEq(x.length, sab.byteLength / Uint8Array.BYTES_PER_ELEMENT);
+
+ // Though the atomic operations are illegal on Uint8ClampedArray and the
+ // float arrays, they can still be used to create views on shared memory.
+
+ x = new Uint8ClampedArray(sab);
+ assertEq(x.length, sab.byteLength / Uint8ClampedArray.BYTES_PER_ELEMENT);
+
+ x = new Float32Array(sab);
+ assertEq(x.length, sab.byteLength / Float32Array.BYTES_PER_ELEMENT);
+ x = new Float64Array(sab);
+ assertEq(x.length, sab.byteLength / Float64Array.BYTES_PER_ELEMENT);
+}
+
+testSharedArrayBuffer();
+testSharedTypedArray();
+testSharedTypedArrayMethods();
+testClone1();
+testClone2();
+testNoClone();
+testRedundantTransfer();
+testApplicable();
+
+reportCompare(0, 0, 'ok');
diff --git a/js/src/tests/js1_8_5/extensions/shell.js b/js/src/tests/js1_8_5/extensions/shell.js
new file mode 100644
index 000000000..41bf0af07
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/shell.js
@@ -0,0 +1,115 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 4 -*- */
+/*
+ * Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/licenses/publicdomain/
+ */
+
+
+// The Worker constructor can take a relative URL, but different test runners
+// run in different enough environments that it doesn't all just automatically
+// work. For the shell, we use just a filename; for the browser, see browser.js.
+var workerDir = '';
+
+// explicitly turn on js185
+// XXX: The browser currently only supports up to version 1.8
+if (typeof version != 'undefined')
+{
+ version(185);
+}
+
+// Assert that cloning b does the right thing as far as we can tell.
+// Caveat: getters in b must produce the same value each time they're
+// called. We may call them several times.
+//
+// If desc is provided, then the very first thing we do to b is clone it.
+// (The self-modifying object test counts on this.)
+//
+function clone_object_check(b, desc) {
+ function classOf(obj) {
+ return Object.prototype.toString.call(obj);
+ }
+
+ function ownProperties(obj) {
+ return Object.getOwnPropertyNames(obj).
+ map(function (p) { return [p, Object.getOwnPropertyDescriptor(obj, p)]; });
+ }
+
+ function isCloneable(pair) {
+ return typeof pair[0] === 'string' && pair[1].enumerable;
+ }
+
+ function notIndex(p) {
+ var u = p >>> 0;
+ return !("" + u == p && u != 0xffffffff);
+ }
+
+ function assertIsCloneOf(a, b, path) {
+ assertEq(a === b, false);
+
+ var ca = classOf(a);
+ assertEq(ca, classOf(b), path);
+
+ assertEq(Object.getPrototypeOf(a),
+ ca == "[object Object]" ? Object.prototype : Array.prototype,
+ path);
+
+ // 'b', the original object, may have non-enumerable or XMLName
+ // properties; ignore them. 'a', the clone, should not have any
+ // non-enumerable properties (except .length, if it's an Array) or
+ // XMLName properties.
+ var pb = ownProperties(b).filter(isCloneable);
+ var pa = ownProperties(a);
+ for (var i = 0; i < pa.length; i++) {
+ assertEq(typeof pa[i][0], "string", "clone should not have E4X properties " + path);
+ if (!pa[i][1].enumerable) {
+ if (Array.isArray(a) && pa[i][0] == "length") {
+ // remove it so that the comparisons below will work
+ pa.splice(i, 1);
+ i--;
+ } else {
+ throw new Error("non-enumerable clone property " + uneval(pa[i][0]) + " " + path);
+ }
+ }
+ }
+
+ // Check that, apart from properties whose names are array indexes,
+ // the enumerable properties appear in the same order.
+ var aNames = pa.map(function (pair) { return pair[1]; }).filter(notIndex);
+ var bNames = pa.map(function (pair) { return pair[1]; }).filter(notIndex);
+ assertEq(aNames.join(","), bNames.join(","), path);
+
+ // Check that the lists are the same when including array indexes.
+ function byName(a, b) { a = a[0]; b = b[0]; return a < b ? -1 : a === b ? 0 : 1; }
+ pa.sort(byName);
+ pb.sort(byName);
+ assertEq(pa.length, pb.length, "should see the same number of properties " + path);
+ for (var i = 0; i < pa.length; i++) {
+ var aName = pa[i][0];
+ var bName = pb[i][0];
+ assertEq(aName, bName, path);
+
+ var path2 = path + "." + aName;
+ var da = pa[i][1];
+ var db = pb[i][1];
+ assertEq(da.configurable, true, path2);
+ assertEq(da.writable, true, path2);
+ assertEq("value" in da, true, path2);
+ var va = da.value;
+ var vb = b[pb[i][0]];
+ if (typeof va === "object" && va !== null)
+ queue.push([va, vb, path2]);
+ else
+ assertEq(va, vb, path2);
+ }
+ }
+
+ var banner = "while testing clone of " + (desc || uneval(b));
+ var a = deserialize(serialize(b));
+ var queue = [[a, b, banner]];
+ while (queue.length) {
+ var triple = queue.shift();
+ assertIsCloneOf(triple[0], triple[1], triple[2]);
+ }
+
+ return a; // for further testing
+}
diff --git a/js/src/tests/js1_8_5/extensions/sps-generators.js b/js/src/tests/js1_8_5/extensions/sps-generators.js
new file mode 100644
index 000000000..d99e93c5b
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/sps-generators.js
@@ -0,0 +1,39 @@
+// |reftest| skip-if(!xulRuntime.shell)
+
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 822041;
+var summary = "Live generators should not cache SPS state";
+
+print(BUGNUMBER + ": " + summary);
+
+function gen() {
+ var x = yield turnoff();
+ yield x;
+ yield 'bye';
+}
+
+function turnoff() {
+ print("Turning off profiler\n");
+ disableSPSProfiling();
+ return 'hi';
+}
+
+for (var slowAsserts of [ true, false ]) {
+ // The slowAssertions setting is not expected to matter
+ if (slowAsserts)
+ enableSPSProfilingWithSlowAssertions();
+ else
+ enableSPSProfiling();
+
+ g = gen();
+ assertEq(g.next(), 'hi');
+ assertEq(g.send('gurgitating...'), 'gurgitating...');
+ for (var x in g)
+ assertEq(x, 'bye');
+}
+
+// This is really a crashtest
+reportCompare(0, 0, 'ok');
diff --git a/js/src/tests/js1_8_5/extensions/symbol-uneval.js b/js/src/tests/js1_8_5/extensions/symbol-uneval.js
new file mode 100644
index 000000000..a1c2a9097
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/symbol-uneval.js
@@ -0,0 +1,13 @@
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+assertEq(uneval(Symbol.iterator), "Symbol.iterator");
+assertEq(uneval(Symbol()), "Symbol()");
+assertEq(uneval(Symbol("")), 'Symbol("")');
+assertEq(uneval(Symbol("ponies")), 'Symbol("ponies")');
+assertEq(uneval(Symbol.for("ponies")), 'Symbol.for("ponies")');
+
+assertEq({glyph: Symbol(undefined)}.toSource(), "({glyph:Symbol()})");
+
+if (typeof reportCompare === "function")
+ reportCompare(0, 0);
diff --git a/js/src/tests/js1_8_5/extensions/toSource-0.js b/js/src/tests/js1_8_5/extensions/toSource-0.js
new file mode 100644
index 000000000..cdec97be4
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/toSource-0.js
@@ -0,0 +1,14 @@
+/*
+ * Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/licenses/publicdomain/
+ */
+
+assertEq(eval(uneval('\x001')), '\x001');
+
+f = eval('(' + (function () { return '\x001'; }).toString() + ')');
+assertEq(f(), '\x001');
+
+assertEq(eval('\x001'.toSource()) == '\x001', true);
+
+if (typeof reportCompare === 'function')
+ reportCompare(true, true);
diff --git a/js/src/tests/js1_8_5/extensions/typedarray-copyWithin-arguments-detaching.js b/js/src/tests/js1_8_5/extensions/typedarray-copyWithin-arguments-detaching.js
new file mode 100644
index 000000000..eb1cda6d1
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/typedarray-copyWithin-arguments-detaching.js
@@ -0,0 +1,112 @@
+// |reftest| skip-if(!xulRuntime.shell) -- needs detachArrayBuffer()
+/*
+ * Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/licenses/publicdomain/
+ */
+
+var gTestfile = "typedarray-copyWithin-arguments-detaching.js";
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 991981;
+var summary =
+ "%TypedArray.prototype.copyWithin shouldn't misbehave horribly if " +
+ "index-argument conversion detaches the underlying ArrayBuffer";
+
+print(BUGNUMBER + ": " + summary);
+
+/**************
+ * BEGIN TEST *
+ **************/
+
+function testBegin()
+{
+ var ab = new ArrayBuffer(0x1000);
+
+ var begin =
+ {
+ valueOf: function()
+ {
+ detachArrayBuffer(ab);
+ return 0x800;
+ }
+ };
+
+ var ta = new Uint8Array(ab);
+
+ var ok = false;
+ try
+ {
+ ta.copyWithin(0, begin, 0x1000);
+ }
+ catch (e)
+ {
+ ok = true;
+ }
+ assertEq(ok, true, "start weirdness should have thrown");
+ assertEq(ab.byteLength, 0, "detaching should work for start weirdness");
+}
+testBegin();
+
+function testEnd()
+{
+ var ab = new ArrayBuffer(0x1000);
+
+ var end =
+ {
+ valueOf: function()
+ {
+ detachArrayBuffer(ab);
+ return 0x1000;
+ }
+ };
+
+ var ta = new Uint8Array(ab);
+
+ var ok = false;
+ try
+ {
+ ta.copyWithin(0, 0x800, end);
+ }
+ catch (e)
+ {
+ ok = true;
+ }
+ assertEq(ok, true, "start weirdness should have thrown");
+ assertEq(ab.byteLength, 0, "detaching should work for start weirdness");
+}
+testEnd();
+
+function testDest()
+{
+ var ab = new ArrayBuffer(0x1000);
+
+ var dest =
+ {
+ valueOf: function()
+ {
+ detachArrayBuffer(ab);
+ return 0;
+ }
+ };
+
+ var ta = new Uint8Array(ab);
+
+ var ok = false;
+ try
+ {
+ ta.copyWithin(dest, 0x800, 0x1000);
+ }
+ catch (e)
+ {
+ ok = true;
+ }
+ assertEq(ok, true, "start weirdness should have thrown");
+ assertEq(ab.byteLength, 0, "detaching should work for start weirdness");
+}
+testDest();
+
+/******************************************************************************/
+
+if (typeof reportCompare === "function")
+ reportCompare(true, true);
+
+print("Tests complete");
diff --git a/js/src/tests/js1_8_5/extensions/typedarray-set-neutering.js b/js/src/tests/js1_8_5/extensions/typedarray-set-neutering.js
new file mode 100644
index 000000000..cd902eb04
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/typedarray-set-neutering.js
@@ -0,0 +1,49 @@
+// |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 ab = new ArrayBuffer(200);
+var a = new Uint8Array(ab);
+var a_2 = new Uint8Array(10);
+
+var src = [ 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(src, 4, {
+ get: function () {
+ detachArrayBuffer(ab);
+ gc();
+ return 200;
+ }
+});
+
+a.set(src);
+
+// Not really needed
+Array.reverse(a_2);
+
+/******************************************************************************/
+
+if (typeof reportCompare === "function")
+ reportCompare(true, true);
+
+print("Tests complete");
diff --git a/js/src/tests/js1_8_5/extensions/typedarray-subarray-of-subarray.js b/js/src/tests/js1_8_5/extensions/typedarray-subarray-of-subarray.js
new file mode 100644
index 000000000..fcfb031cb
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/typedarray-subarray-of-subarray.js
@@ -0,0 +1,33 @@
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 637643;
+var summary =
+ "new Int8Array([1, 2, 3]).subarray(1).subarray(1)[0] === 3";
+
+print(BUGNUMBER + ": " + summary);
+
+/**************
+ * BEGIN TEST *
+ **************/
+
+var ta = new Int8Array([1, 2, 3]);
+assertEq(ta.length, 3);
+assertEq(ta[0], 1);
+assertEq(ta[1], 2);
+assertEq(ta[2], 3);
+
+var sa1 = ta.subarray(1);
+assertEq(sa1.length, 2);
+assertEq(sa1[0], 2);
+assertEq(sa1[1], 3);
+
+var sa2 = sa1.subarray(1);
+assertEq(sa2.length, 1);
+assertEq(sa2[0], 3);
+
+if (typeof reportCompare === "function")
+ reportCompare(true, true);
+
+print("All tests passed!");
diff --git a/js/src/tests/js1_8_5/extensions/typedarray.js b/js/src/tests/js1_8_5/extensions/typedarray.js
new file mode 100644
index 000000000..885f94551
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/typedarray.js
@@ -0,0 +1,648 @@
+// |reftest| skip-if(!xulRuntime.shell)
+/* -*- Mode: js2; tab-width: 40; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/*
+ * Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/licenses/publicdomain/
+ * Contributor:
+ * Vladimir Vukicevic <vladimir@pobox.com>
+ */
+
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 532774;
+var summary = 'js typed arrays (webgl arrays)';
+var actual = '';
+var expect = '';
+
+//-----------------------------------------------------------------------------
+test();
+//-----------------------------------------------------------------------------
+
+function test()
+{
+ enterFunc ('test');
+ printBugNumber(BUGNUMBER);
+ printStatus(summary);
+
+ var TestPassCount = 0;
+ var TestFailCount = 0;
+ var TestTodoCount = 0;
+
+ var TODO = 1;
+
+ function check(fun, msg, todo) {
+ var thrown = null;
+ var success = false;
+ try {
+ success = fun();
+ } catch (x) {
+ thrown = x;
+ }
+
+ if (thrown)
+ success = false;
+
+ if (todo) {
+ TestTodoCount++;
+
+ if (success) {
+ var ex = new Error;
+ print ("=== TODO but PASSED? ===");
+ print (ex.stack);
+ print ("========================");
+ }
+
+ return;
+ }
+
+ if (success) {
+ TestPassCount++;
+ } else {
+ TestFailCount++;
+
+ var ex = new Error;
+ print ("=== FAILED ===");
+ if (msg)
+ print (msg);
+ print (ex.stack);
+ if (thrown) {
+ print (" threw exception:");
+ print (thrown);
+ }
+ print ("==============");
+ }
+ }
+
+ function checkThrows(fun, type, todo) {
+ var thrown = false;
+ try {
+ fun();
+ } catch (x) {
+ thrown = x;
+ }
+
+ if (typeof(type) !== 'undefined')
+ if (thrown) {
+ check(() => thrown instanceof type,
+ "expected " + type.name + " but saw " + thrown,
+ todo);
+ } else {
+ check(() => thrown, "expected " + type.name + " but no exception thrown", todo);
+ }
+ else
+ check(() => thrown, undefined, todo);
+ }
+
+ function checkThrowsTODO(fun, type) {
+ checkThrows(fun, type, true);
+ }
+
+ function testBufferManagement() {
+ // Single buffer
+ var buffer = new ArrayBuffer(128);
+ buffer = null;
+ gc();
+
+ // Buffer with single view, kill the view first
+ buffer = new ArrayBuffer(128);
+ var v1 = new Uint8Array(buffer);
+ gc();
+ v1 = null;
+ gc();
+ buffer = null;
+ gc();
+
+ // Buffer with single view, kill the buffer first
+ buffer = new ArrayBuffer(128);
+ v1 = new Uint8Array(buffer);
+ gc();
+ buffer = null;
+ gc();
+ v1 = null;
+ gc();
+
+ // Buffer with multiple views, kill first view first
+ buffer = new ArrayBuffer(128);
+ v1 = new Uint8Array(buffer);
+ v2 = new Uint8Array(buffer);
+ gc();
+ v1 = null;
+ gc();
+ v2 = null;
+ gc();
+
+ // Buffer with multiple views, kill second view first
+ buffer = new ArrayBuffer(128);
+ v1 = new Uint8Array(buffer);
+ v2 = new Uint8Array(buffer);
+ gc();
+ v2 = null;
+ gc();
+ v1 = null;
+ gc();
+
+ // Buffer with multiple views, kill all possible subsets of views
+ buffer = new ArrayBuffer(128);
+ for (let order = 0; order < 16; order++) {
+ var views = [ new Uint8Array(buffer),
+ new Uint8Array(buffer),
+ new Uint8Array(buffer),
+ new Uint8Array(buffer) ];
+ gc();
+
+ // Kill views according to the bits set in 'order'
+ for (let i = 0; i < 4; i++) {
+ if (order & (1 << i))
+ views[i] = null;
+ }
+
+ gc();
+
+ views = null;
+ gc();
+ }
+
+ // Similar: multiple views, kill them one at a time in every possible order
+ buffer = new ArrayBuffer(128);
+ for (let order = 0; order < 4*3*2*1; order++) {
+ var views = [ new Uint8Array(buffer),
+ new Uint8Array(buffer),
+ new Uint8Array(buffer),
+ new Uint8Array(buffer) ];
+ gc();
+
+ var sequence = [ 0, 1, 2, 3 ];
+ let groupsize = 4*3*2*1;
+ let o = order;
+ for (let i = 4; i > 0; i--) {
+ groupsize = groupsize / i;
+ let which = Math.floor(o/groupsize);
+ [ sequence[i-1], sequence[which] ] = [ sequence[which], sequence[i-1] ];
+ o = o % groupsize;
+ }
+
+ for (let i = 0; i < 4; i++) {
+ views[i] = null;
+ gc();
+ }
+ }
+
+ // Multiple buffers with multiple views
+ var views = [];
+ for (let numViews of [ 1, 2, 0, 3, 2, 1 ]) {
+ buffer = new ArrayBuffer(128);
+ for (let viewNum = 0; viewNum < numViews; viewNum++) {
+ views.push(new Int8Array(buffer));
+ }
+ }
+
+ gcparam('markStackLimit', 200);
+ var forceOverflow = [ buffer ];
+ for (let i = 0; i < 1000; i++) {
+ forceOverflow = [ forceOverflow ];
+ }
+ gc();
+ buffer = null;
+ views = null;
+ gcslice(3); gcslice(3); gcslice(3); gcslice(3); gcslice(3); gcslice(3); gc();
+ }
+
+ var buf, buf2;
+
+ buf = new ArrayBuffer(100);
+ check(() => buf);
+ check(() => buf.byteLength == 100);
+
+ buf.byteLength = 50;
+ check(() => buf.byteLength == 100);
+
+ var zerobuf = new ArrayBuffer(0);
+ check(() => zerobuf);
+ check(() => zerobuf.byteLength == 0);
+
+ check(() => (new Int32Array(zerobuf)).length == 0);
+ checkThrows(() => new Int32Array(zerobuf, 1));
+
+ var zerobuf2 = new ArrayBuffer();
+ check(() => zerobuf2.byteLength == 0);
+
+ checkThrows(() => new ArrayBuffer(-100), RangeError);
+ // this is using js_ValueToECMAUInt32, which is giving 0 for "abc"
+ checkThrowsTODO(() => new ArrayBuffer("abc"), TypeError);
+
+ var zeroarray = new Int32Array(0);
+ check(() => zeroarray.length == 0);
+ check(() => zeroarray.byteLength == 0);
+ check(() => zeroarray.buffer);
+ check(() => zeroarray.buffer.byteLength == 0);
+
+ var zeroarray2 = new Int32Array();
+ check(() => zeroarray2.length == 0);
+ check(() => zeroarray2.byteLength == 0);
+ check(() => zeroarray2.buffer);
+ check(() => zeroarray2.buffer.byteLength == 0);
+
+ var a = new Int32Array(20);
+ check(() => a);
+ check(() => a.length == 20);
+ check(() => a.byteLength == 80);
+ check(() => a.byteOffset == 0);
+ check(() => a.buffer);
+ check(() => a.buffer.byteLength == 80);
+
+ var b = new Uint8Array(a.buffer, 4, 4);
+ check(() => b);
+ check(() => b.length == 4);
+ check(() => b.byteLength == 4);
+ check(() => a.buffer == b.buffer);
+
+ b[0] = 0xaa;
+ b[1] = 0xbb;
+ b[2] = 0xcc;
+ b[3] = 0xdd;
+
+ check(() => a[0] == 0);
+ check(() => a[1] != 0);
+ check(() => a[2] == 0);
+
+ buf = new ArrayBuffer(4);
+ check(() => (new Int8Array(buf)).length == 4);
+ check(() => (new Uint8Array(buf)).length == 4);
+ check(() => (new Int16Array(buf)).length == 2);
+ check(() => (new Uint16Array(buf)).length == 2);
+ check(() => (new Int32Array(buf)).length == 1);
+ check(() => (new Uint32Array(buf)).length == 1);
+ check(() => (new Float32Array(buf)).length == 1);
+ checkThrows(() => (new Float64Array(buf)));
+ buf2 = new ArrayBuffer(8);
+ check(() => (new Float64Array(buf2)).length == 1);
+
+ buf = new ArrayBuffer(5);
+ check(() => buf);
+ check(() => buf.byteLength == 5);
+
+ check(() => new Int32Array(buf, 0, 1));
+ checkThrows(() => new Int32Array(buf, 0));
+ check(() => new Int8Array(buf, 0));
+
+ check(() => (new Int8Array(buf, 3)).byteLength == 2);
+ checkThrows(() => new Int8Array(buf, 500));
+ checkThrows(() => new Int8Array(buf, 0, 50));
+ checkThrows(() => new Float32Array(buf, 500));
+ checkThrows(() => new Float32Array(buf, 0, 50));
+
+ var sl = a.subarray(5,10);
+ check(() => sl.length == 5);
+ check(() => sl.buffer == a.buffer);
+ check(() => sl.byteLength == 20);
+ check(() => sl.byteOffset == 20);
+
+ check(() => a.subarray(5,5).length == 0);
+ check(() => a.subarray(-5).length == 5);
+ check(() => a.subarray(-100).length == 20);
+ check(() => a.subarray(0, 2).length == 2);
+ check(() => a.subarray().length == a.length);
+ check(() => a.subarray(-7,-5).length == 2);
+ check(() => a.subarray(-5,-7).length == 0);
+ check(() => a.subarray(15).length == 5);
+
+ a = new Uint8Array([0xaa, 0xbb, 0xcc]);
+ check(() => a.length == 3);
+ check(() => a.byteLength == 3);
+ check(() => a[1] == 0xbb);
+
+ // not sure if this is supposed to throw or to treat "foo"" as 0.
+ checkThrowsTODO(() => new Int32Array([0xaa, "foo", 0xbb]), Error);
+
+ checkThrows(() => new Int32Array(-100));
+
+ a = new Uint8Array(3);
+ // XXX these are ignored now and return undefined
+ //checkThrows(() => a[5000] = 0, RangeError);
+ //checkThrows(() => a["hello"] = 0, TypeError);
+ //checkThrows(() => a[-10] = 0, RangeError);
+ check(() => (a[0] = "10") && (a[0] == 10));
+
+ // check Uint8ClampedArray, which is an extension to this extension
+ a = new Uint8ClampedArray(4);
+ a[0] = 128;
+ a[1] = 512;
+ a[2] = -123.723;
+ a[3] = "foopy";
+
+ check(() => a[0] == 128);
+ check(() => a[1] == 255);
+ check(() => a[2] == 0);
+ check(() => a[3] == 0);
+
+ // check handling of holes and non-numeric values
+ var x = Array(5);
+ x[0] = "hello";
+ x[1] = { };
+ //x[2] is a hole
+ x[3] = undefined;
+ x[4] = true;
+
+ a = new Uint8Array(x);
+ check(() => a[0] == 0);
+ check(() => a[1] == 0);
+ check(() => a[2] == 0);
+ check(() => a[3] == 0);
+ check(() => a[4] == 1);
+
+ a = new Float32Array(x);
+ check(() => !(a[0] == a[0]));
+ check(() => !(a[1] == a[1]));
+ check(() => !(a[2] == a[2]));
+ check(() => !(a[3] == a[3]));
+ check(() => a[4] == 1);
+
+ // test set()
+ var empty = new Int32Array(0);
+ a = new Int32Array(9);
+
+ empty.set([]);
+ empty.set([], 0);
+ empty.set(empty);
+
+ checkThrows(() => empty.set([1]));
+ checkThrows(() => empty.set([1], 0));
+ checkThrows(() => empty.set([1], 1));
+
+ a.set([]);
+ a.set([], 3);
+ a.set([], 9);
+ a.set(a);
+
+ a.set(empty);
+ a.set(empty, 3);
+ a.set(empty, 9);
+ a.set(Array.prototype);
+ checkThrows(() => a.set(empty, 100));
+
+ checkThrows(() => a.set([1,2,3,4,5,6,7,8,9,10]));
+ checkThrows(() => a.set([1,2,3,4,5,6,7,8,9,10], 0));
+ checkThrows(() => a.set([1,2,3,4,5,6,7,8,9,10], 0x7fffffff));
+ checkThrows(() => a.set([1,2,3,4,5,6,7,8,9,10], 0xffffffff));
+ checkThrows(() => a.set([1,2,3,4,5,6], 6));
+
+ checkThrows(() => a.set(new Array(0x7fffffff)));
+ checkThrows(() => a.set([1,2,3], 2147483647));
+
+ a.set(ArrayBuffer.prototype);
+ checkThrows(() => a.set(Int16Array.prototype), TypeError);
+ checkThrows(() => a.set(Int32Array.prototype), TypeError);
+
+ a.set([1,2,3]);
+ a.set([4,5,6], 3);
+ check(() =>
+ a[0] == 1 && a[1] == 2 && a[2] == 3 &&
+ a[3] == 4 && a[4] == 5 && a[5] == 6 &&
+ a[6] == 0 && a[7] == 0 && a[8] == 0);
+
+ b = new Float32Array([7,8,9]);
+ a.set(b, 0);
+ a.set(b, 3);
+ check(() =>
+ a[0] == 7 && a[1] == 8 && a[2] == 9 &&
+ a[3] == 7 && a[4] == 8 && a[5] == 9 &&
+ a[6] == 0 && a[7] == 0 && a[8] == 0);
+ a.set(a.subarray(0,3), 6);
+ check(() =>
+ a[0] == 7 && a[1] == 8 && a[2] == 9 &&
+ a[3] == 7 && a[4] == 8 && a[5] == 9 &&
+ a[6] == 7 && a[7] == 8 && a[8] == 9);
+
+ a.set([1,2,3,4,5,6,7,8,9]);
+ a.set(a.subarray(0,6), 3);
+ check(() =>
+ a[0] == 1 && a[1] == 2 && a[2] == 3 &&
+ a[3] == 1 && a[4] == 2 && a[5] == 3 &&
+ a[6] == 4 && a[7] == 5 && a[8] == 6);
+
+ a.set(a.subarray(3,9), 0);
+ check(() =>
+ a[0] == 1 && a[1] == 2 && a[2] == 3 &&
+ a[3] == 4 && a[4] == 5 && a[5] == 6 &&
+ a[6] == 4 && a[7] == 5 && a[8] == 6);
+
+ // verify that subarray() returns a new view that
+ // references the same buffer
+ a.subarray(0,3).set(a.subarray(3,6), 0);
+ check(() =>
+ a[0] == 4 && a[1] == 5 && a[2] == 6 &&
+ a[3] == 4 && a[4] == 5 && a[5] == 6 &&
+ a[6] == 4 && a[7] == 5 && a[8] == 6);
+
+ a = new ArrayBuffer(0x10);
+ checkThrows(() => new Uint32Array(buffer, 4, 0x3FFFFFFF));
+
+ checkThrows(() => new Float32Array(null));
+
+ a = new Uint8Array(0x100);
+ b = Uint32Array.prototype.subarray.apply(a, [0, 0x100]);
+ check(() => Object.prototype.toString.call(b) === "[object Uint8Array]");
+ check(() => b.buffer === a.buffer);
+ check(() => b.length === a.length);
+ check(() => b.byteLength === a.byteLength);
+ check(() => b.byteOffset === a.byteOffset);
+ check(() => b.BYTES_PER_ELEMENT === a.BYTES_PER_ELEMENT);
+
+ // webidl section 4.4.6, getter bullet point 2.2: prototypes are not
+ // platform objects, and calling the getter of any attribute defined on the
+ // interface should throw a TypeError according to
+ checkThrows(() => ArrayBuffer.prototype.byteLength, TypeError);
+ checkThrows(() => Int32Array.prototype.length, TypeError);
+ checkThrows(() => Int32Array.prototype.byteLength, TypeError);
+ checkThrows(() => Int32Array.prototype.byteOffset, TypeError);
+ checkThrows(() => Float64Array.prototype.length, TypeError);
+ checkThrows(() => Float64Array.prototype.byteLength, TypeError);
+ checkThrows(() => Float64Array.prototype.byteOffset, TypeError);
+
+ // webidl 4.4.6: a readonly attribute's setter is undefined. From
+ // observation, that seems to mean it silently does nothing, and returns
+ // the value that you tried to set it to.
+ check(() => Int32Array.prototype.length = true);
+ check(() => Float64Array.prototype.length = true);
+ check(() => Int32Array.prototype.byteLength = true);
+ check(() => Float64Array.prototype.byteLength = true);
+ check(() => Int32Array.prototype.byteOffset = true);
+ check(() => Float64Array.prototype.byteOffset = true);
+
+ // ArrayBuffer, Int32Array and Float64Array are native functions and have a
+ // .length, so none of these should throw:
+ check(() => (new Int32Array(ArrayBuffer)).length >= 0);
+ check(() => (new Int32Array(Int32Array)).length >= 0);
+ check(() => (new Int32Array(Float64Array)).length >= 0);
+
+ // webidl 4.4.6, under getters: "The value of the Function object’s
+ // 'length' property is the Number value 0"
+ //
+ // Except this fails in getOwnPropertyDescriptor, I think because
+ // Int32Array.prototype does not provide a lookup hook, and the fallback
+ // case ends up calling the getter. Which seems odd to me, but much of this
+ // stuff baffles me. It does seem strange that there's no way to do
+ // getOwnPropertyDescriptor on any of these attributes.
+ //
+ //check(Object.getOwnPropertyDescriptor(Int32Array.prototype, 'byteOffset')['get'].length == 0);
+
+ check(() => Int32Array.BYTES_PER_ELEMENT == 4);
+ check(() => (new Int32Array(4)).BYTES_PER_ELEMENT == 4);
+ check(() => (new Int32Array()).BYTES_PER_ELEMENT == 4);
+ check(() => (new Int32Array(0)).BYTES_PER_ELEMENT == 4);
+ check(() => Int16Array.BYTES_PER_ELEMENT == Uint16Array.BYTES_PER_ELEMENT);
+
+ // test various types of args; Math.sqrt(4) is used to ensure that the
+ // function gets a double, and not a demoted int
+ check(() => (new Float32Array(Math.sqrt(4))).length == 2);
+ check(() => (new Float32Array({ length: 10 })).length == 10);
+ check(() => (new Float32Array({})).length == 0);
+ checkThrows(() => new Float32Array("3"));
+ checkThrows(() => new Float32Array(null));
+ checkThrows(() => new Float32Array(undefined));
+
+ // check that NaN conversions happen correctly with array conversions
+ check(() => (new Int32Array([NaN])[0]) == 0);
+ check(() => { var q = new Float32Array([NaN])[0]; return q != q; });
+
+ // check that setting and reading arbitrary properties works
+ // this is not something that will be done in real world
+ // situations, but it should work when done just like in
+ // regular objects
+ buf = new ArrayBuffer(128);
+ a = new Uint32Array(buf, 0, 4);
+ check(() => a[0] == 0 && a[1] == 0 && a[2] == 0 && a[3] == 0);
+ buf.a = 42;
+ buf.b = "abcdefgh";
+ buf.c = {a:'literal'};
+ check(() => a[0] == 0 && a[1] == 0 && a[2] == 0 && a[3] == 0);
+
+ check(() => buf.a == 42);
+ delete buf.a;
+ check(() => !buf.a);
+
+ // check edge cases for small arrays
+ // 16 reserved slots
+ a = new Uint8Array(120);
+ check(() => a.byteLength == 120);
+ check(() => a.length == 120);
+ for (var i = 0; i < a.length; i++)
+ check(() => a[i] == 0)
+
+ a = new Uint8Array(121);
+ check(() => a.byteLength == 121);
+ check(() => a.length == 121);
+ for (var i = 0; i < a.length; i++)
+ check(() => a[i] == 0)
+
+ // check that TM generated byte offset is right (requires run with -j)
+ a = new Uint8Array(100);
+ a[99] = 5;
+ b = new Uint8Array(a.buffer, 9); // force a offset
+ // use a loop to invoke the TM
+ for (var i = 0; i < b.length; i++)
+ check(() => b[90] == 5)
+
+ // Protos and proxies, oh my!
+ var alien = newGlobal();
+
+ var alien_view = alien.eval('view = new Uint8Array(7)');
+ var alien_buffer = alien.eval('buffer = view.buffer');
+
+ // when creating a view of a buffer in a different compartment, the view
+ // itself should be created in the other compartment and wrapped for use in
+ // this compartment. (There should never be a compartment boundary between
+ // an ArrayBufferView and its ArrayBuffer.)
+ var view = new Int8Array(alien_buffer);
+
+ // First make sure they're looking at the same data
+ alien_view[3] = 77;
+ check(() => view[3] == 77);
+
+ // Now check that the proxy setup is as expected
+ check(() => isProxy(alien_view));
+ check(() => isProxy(alien_buffer));
+ check(() => isProxy(view)); // the real test
+
+ // cross-compartment property access
+ check(() => alien_buffer.byteLength == 7);
+ check(() => alien_view.byteLength == 7);
+ check(() => view.byteLength == 7);
+
+ // typed array protos should be equal
+ simple = new Int8Array(12);
+ check(() => Object.getPrototypeOf(view) == Object.getPrototypeOf(simple));
+ check(() => Object.getPrototypeOf(view) == Int8Array.prototype);
+
+ // Most named properties are defined on %TypedArray%.prototype.
+ check(() => !simple.hasOwnProperty('byteLength'));
+ check(() => !Int8Array.prototype.hasOwnProperty('byteLength'));
+ check(() => Object.getPrototypeOf(Int8Array.prototype).hasOwnProperty('byteLength'));
+
+ check(() => !simple.hasOwnProperty("BYTES_PER_ELEMENT"));
+ check(() => Int8Array.prototype.hasOwnProperty("BYTES_PER_ELEMENT"));
+ check(() => !Object.getPrototypeOf(Int8Array.prototype).hasOwnProperty("BYTES_PER_ELEMENT"));
+
+ // crazy as it sounds, the named properties are configurable per WebIDL.
+ // But we are currently discussing the situation, and typed arrays may be
+ // pulled into the ES spec, so for now this is disallowed.
+ if (false) {
+ check(() => simple.byteLength == 12);
+ getter = Object.getOwnPropertyDescriptor(Int8Array.prototype, 'byteLength').get;
+ Object.defineProperty(Int8Array.prototype, 'byteLength', { get: function () { return 1 + getter.apply(this) } });
+ check(() => simple.byteLength == 13);
+ }
+
+ // test copyWithin()
+ var numbers = [ 0, 1, 2, 3, 4, 5, 6, 7, 8 ];
+
+ function tastring(tarray) {
+ return [...tarray].toString();
+ }
+
+ function checkCopyWithin(offset, start, end, dest, want) {
+ var numbers_buffer = new Uint8Array(numbers).buffer;
+ var view = new Int8Array(numbers_buffer, offset);
+ view.copyWithin(dest, start, end);
+ check(() => tastring(view) == want.toString());
+ if (tastring(view) != want.toString()) {
+ print("Wanted: " + want.toString());
+ print("Got : " + tastring(view));
+ }
+ }
+
+ // basic copyWithin [2,5) -> 4
+ checkCopyWithin(0, 2, 5, 4, [ 0, 1, 2, 3, 2, 3, 4, 7, 8 ]);
+
+ // negative values should count from end
+ checkCopyWithin(0, -7, 5, 4, [ 0, 1, 2, 3, 2, 3, 4, 7, 8 ]);
+ checkCopyWithin(0, 2, -4, 4, [ 0, 1, 2, 3, 2, 3, 4, 7, 8 ]);
+ checkCopyWithin(0, 2, 5, -5, [ 0, 1, 2, 3, 2, 3, 4, 7, 8 ]);
+ checkCopyWithin(0, -7, -4, -5, [ 0, 1, 2, 3, 2, 3, 4, 7, 8 ]);
+
+ // offset
+ checkCopyWithin(2, 0, 3, 4, [ 2, 3, 4, 5, 2, 3, 4 ]);
+
+ // clipping
+ checkCopyWithin(0, 5000, 6000, 0, [ 0, 1, 2, 3, 4, 5, 6, 7, 8 ]);
+ checkCopyWithin(0, -5000, -6000, 0, [ 0, 1, 2, 3, 4, 5, 6, 7, 8 ]);
+ checkCopyWithin(0, -5000, 6000, 0, [ 0, 1, 2, 3, 4, 5, 6, 7, 8 ]);
+ checkCopyWithin(0, 5000, 6000, 1, [ 0, 1, 2, 3, 4, 5, 6, 7, 8 ]);
+ checkCopyWithin(0, -5000, -6000, 1, [ 0, 1, 2, 3, 4, 5, 6, 7, 8 ]);
+ checkCopyWithin(0, 5000, 6000, 0, [ 0, 1, 2, 3, 4, 5, 6, 7, 8 ]);
+ checkCopyWithin(2, -5000, -6000, 0, [ 2, 3, 4, 5, 6, 7, 8 ]);
+ checkCopyWithin(2, -5000, 6000, 0, [ 2, 3, 4, 5, 6, 7, 8 ]);
+ checkCopyWithin(2, 5000, 6000, 1, [ 2, 3, 4, 5, 6, 7, 8 ]);
+ checkCopyWithin(2, -5000, -6000, 1, [ 2, 3, 4, 5, 6, 7, 8 ]);
+
+ checkCopyWithin(2, -5000, 3, 1, [ 2, 2, 3, 4, 6, 7, 8 ]);
+ checkCopyWithin(2, 1, 6000, 0, [ 3, 4, 5, 6, 7, 8, 8 ]);
+ checkCopyWithin(2, 1, 6000, -4000, [ 3, 4, 5, 6, 7, 8, 8 ]);
+
+ testBufferManagement();
+
+ print ("done");
+
+ reportCompare(0, TestFailCount, "typed array tests");
+
+ exitFunc ('test');
+}
diff --git a/js/src/tests/js1_8_5/extensions/watch-undefined-setter.js b/js/src/tests/js1_8_5/extensions/watch-undefined-setter.js
new file mode 100644
index 000000000..92608de0e
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/watch-undefined-setter.js
@@ -0,0 +1,19 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/*
+ * Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/licenses/publicdomain/
+ * Contributor:
+ * Gary Kwong
+ */
+
+var gTestfile = 'watch-undefined-setter.js';
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 560277;
+var summary =
+ 'Crash [@ JSObject::getParent] or [@ js_WrapWatchedSetter] or ' +
+ '[@ js_GetClassPrototype]';
+
+this.watch("x", function() { });
+Object.defineProperty(this, "x", { set: undefined, configurable: true });
+
+reportCompare(true, true);
diff --git a/js/src/tests/js1_8_5/extensions/weakmap.js b/js/src/tests/js1_8_5/extensions/weakmap.js
new file mode 100644
index 000000000..cad3d23e1
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/weakmap.js
@@ -0,0 +1,124 @@
+/*
+ * Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/licenses/publicdomain/
+ * Contributor:
+ * Andreas Gal <gal@mozilla.com>
+ */
+
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 547941;
+var summary = 'js weak maps';
+var actual = '';
+var expect = '';
+
+//-----------------------------------------------------------------------------
+test();
+//-----------------------------------------------------------------------------
+
+function test()
+{
+ enterFunc ('test');
+ printBugNumber(BUGNUMBER);
+ printStatus(summary);
+
+ var TestPassCount = 0;
+ var TestFailCount = 0;
+ var TestTodoCount = 0;
+
+ var TODO = 1;
+
+ function check(fun, todo) {
+ var thrown = null;
+ var success = false;
+ try {
+ success = fun();
+ } catch (x) {
+ thrown = x;
+ }
+
+ if (thrown)
+ success = false;
+
+ if (todo) {
+ TestTodoCount++;
+
+ if (success) {
+ var ex = new Error;
+ print ("=== TODO but PASSED? ===");
+ print (ex.stack);
+ print ("========================");
+ }
+
+ return;
+ }
+
+ if (success) {
+ TestPassCount++;
+ } else {
+ TestFailCount++;
+
+ var ex = new Error;
+ print ("=== FAILED ===");
+ print (ex.stack);
+ if (thrown) {
+ print (" threw exception:");
+ print (thrown);
+ }
+ print ("==============");
+ }
+ }
+
+ function checkThrows(fun, todo) {
+ let thrown = false;
+ try {
+ fun();
+ } catch (x) {
+ thrown = true;
+ }
+
+ check(() => thrown, todo);
+ }
+
+ var key = {};
+ var map = new WeakMap();
+
+ check(() => !map.has(key));
+ check(() => map.delete(key) == false);
+ check(() => map.set(key, 42) === map);
+ check(() => map.get(key) == 42);
+ check(() => typeof map.get({}) == "undefined");
+ check(() => map.get({}, "foo") == undefined);
+
+ gc(); gc(); gc();
+
+ check(() => map.get(key) == 42);
+ check(() => map.delete(key) == true);
+ check(() => map.delete(key) == false);
+ check(() => map.delete({}) == false);
+
+ check(() => typeof map.get(key) == "undefined");
+ check(() => !map.has(key));
+ check(() => map.delete(key) == false);
+
+ var value = { };
+ check(() => map.set(new Object(), value) === map);
+ gc(); gc(); gc();
+
+ check(() => map.has("non-object key") == false);
+ check(() => map.has() == false);
+ check(() => map.get("non-object key") == undefined);
+ check(() => map.get() == undefined);
+ check(() => map.delete("non-object key") == false);
+ check(() => map.delete() == false);
+
+ check(() => map.set(key) === map);
+ check(() => map.get(key) == undefined);
+
+ checkThrows(() => map.set("non-object key", value));
+
+ print ("done");
+
+ reportCompare(0, TestFailCount, "weak map tests");
+
+ exitFunc ('test');
+}