diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /js/src/tests/non262/extensions | |
parent | Initial commit. (diff) | |
download | thunderbird-upstream.tar.xz thunderbird-upstream.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
339 files changed, 21405 insertions, 0 deletions
diff --git a/js/src/tests/non262/extensions/15.9.4.2.js b/js/src/tests/non262/extensions/15.9.4.2.js new file mode 100644 index 0000000000..91e794d259 --- /dev/null +++ b/js/src/tests/non262/extensions/15.9.4.2.js @@ -0,0 +1,56 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 682754; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function iso(d) +{ + return new Date(d).toISOString(); +} + +function check(s, millis){ + description = "Date.parse('"+s+"') == '"+iso(millis)+"'"; + expected = millis; + actual = Date.parse(s); + reportCompare(expected, actual, description); +} + +function checkInvalid(s) +{ + description = "Date.parse('"+s+"') produces invalid date"; + expected = NaN; + actual = Date.parse(s); + reportCompare(expected, actual, description); +} + +function dd(year, month, day, hour, minute, second, millis){ + return Date.UTC(year, month-1, day, hour, minute, second, millis); +} + +function TZAtDate(d){ + return d.getTimezoneOffset() * 60000; +} + +function TZInMonth(month){ + return TZAtDate(new Date(dd(2009,month,1,0,0,0,0))); +} + +function test() +{ + printBugNumber(BUGNUMBER); + + JanTZ = TZInMonth(1); + JulTZ = TZInMonth(7); + CurrTZ = TZAtDate(new Date()); + + // Allow non-standard "-0700" as timezone, not just "-07:00" + check("2009-07-23T00:53:21.001-0700", dd(2009,7,23,7,53,21,1)); +} diff --git a/js/src/tests/non262/extensions/8.12.5-01.js b/js/src/tests/non262/extensions/8.12.5-01.js new file mode 100644 index 0000000000..b7563a8edb --- /dev/null +++ b/js/src/tests/non262/extensions/8.12.5-01.js @@ -0,0 +1,70 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + * Contributor: + * Jason Orendorff + * Jeff Walden <jwalden+code@mit.edu> + */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 523846; +var summary = + "Assignments to a property that has a getter but not a setter should not " + + "throw a TypeError per ES5 (at least not until strict mode is supported)"; +var actual = "Early failure"; +var expect = "No errors"; + + +printBugNumber(BUGNUMBER); +printStatus(summary); + +var o = { get p() { return "a"; } }; + +function test1() +{ + o.p = "b"; // strict-mode violation here + assertEq(o.p, "a"); +} + +function test2() +{ + function T() {} + T.prototype = o; + y = new T(); + y.p = "b"; // strict-mode violation here + assertEq(y.p, "a"); +} + + +var errors = []; +try +{ + try + { + test1(); + } + catch (e) + { + errors.push(e); + } + + try + { + test2(); + } + catch (e) + { + errors.push(e); + } +} +catch (e) +{ + errors.push("Unexpected error: " + e); +} +finally +{ + actual = errors.length > 0 ? errors.join(", ") : "No errors"; +} + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/non262/extensions/ArrayBuffer-slice-arguments-detaching.js b/js/src/tests/non262/extensions/ArrayBuffer-slice-arguments-detaching.js new file mode 100644 index 0000000000..07cec18aa9 --- /dev/null +++ b/js/src/tests/non262/extensions/ArrayBuffer-slice-arguments-detaching.js @@ -0,0 +1,80 @@ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +var gTestfile = "ArrayBuffer-slice-arguments-detaching.js"; +//----------------------------------------------------------------------------- +var BUGNUMBER = 991981; +var summary = + "ArrayBuffer.prototype.slice shouldn't misbehave horribly if " + + "index-argument conversion detaches the ArrayBuffer being sliced"; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +function testStart() +{ + var ab = new ArrayBuffer(0x1000); + + var start = + { + valueOf: function() + { + detachArrayBuffer(ab); + gc(); + return 0x800; + } + }; + + var ok = false; + try + { + ab.slice(start); + } + catch (e) + { + ok = true; + } + assertEq(ok, true, "start weirdness should have thrown"); + assertEq(ab.byteLength, 0, "detaching should work for start weirdness"); +} +testStart(); + +function testEnd() +{ + var ab = new ArrayBuffer(0x1000); + + var end = + { + valueOf: function() + { + detachArrayBuffer(ab); + gc(); + return 0x1000; + } + }; + + var ok = false; + try + { + ab.slice(0x800, end); + } + catch (e) + { + ok = true; + } + assertEq(ok, true, "byteLength weirdness should have thrown"); + assertEq(ab.byteLength, 0, "detaching should work for byteLength weirdness"); +} +testEnd(); + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete"); diff --git a/js/src/tests/non262/extensions/Boolean-toSource.js b/js/src/tests/non262/extensions/Boolean-toSource.js new file mode 100644 index 0000000000..b73b21ae5d --- /dev/null +++ b/js/src/tests/non262/extensions/Boolean-toSource.js @@ -0,0 +1,19 @@ +// |reftest| skip-if(!Boolean.prototype.toSource) + +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +assertEq(raisesException(TypeError)('Boolean.prototype.toSource.call(42)'), true); +assertEq(raisesException(TypeError)('Boolean.prototype.toSource.call("")'), true); +assertEq(raisesException(TypeError)('Boolean.prototype.toSource.call({})'), true); +assertEq(raisesException(TypeError)('Boolean.prototype.toSource.call(null)'), true); +assertEq(raisesException(TypeError)('Boolean.prototype.toSource.call([])'), true); +assertEq(raisesException(TypeError)('Boolean.prototype.toSource.call(undefined)'), true); +assertEq(raisesException(TypeError)('Boolean.prototype.toSource.call(new String())'), true); + +assertEq(completesNormally('Boolean.prototype.toSource.call(true)'), true); +assertEq(completesNormally('Boolean.prototype.toSource.call(new Boolean(true))'), true); + +reportCompare(true, true); diff --git a/js/src/tests/non262/extensions/DataView-construct-arguments-detaching.js b/js/src/tests/non262/extensions/DataView-construct-arguments-detaching.js new file mode 100644 index 0000000000..b542816ee8 --- /dev/null +++ b/js/src/tests/non262/extensions/DataView-construct-arguments-detaching.js @@ -0,0 +1,80 @@ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +var gTestfile = "DataView-construct-arguments-detaching.js"; +//----------------------------------------------------------------------------- +var BUGNUMBER = 991981; +var summary = + "new DataView(...) shouldn't misbehave horribly if index-argument " + + "conversion detaches the ArrayBuffer to be viewed"; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +function testByteOffset() +{ + var ab = new ArrayBuffer(0x1000); + + var start = + { + valueOf: function() + { + detachArrayBuffer(ab); + gc(); + return 0x800; + } + }; + + var ok = false; + try + { + new DataView(ab, start); + } + catch (e) + { + ok = true; + } + assertEq(ok, true, "byteOffset weirdness should have thrown"); + assertEq(ab.byteLength, 0, "detaching should work for byteOffset weirdness"); +} +testByteOffset(); + +function testByteLength() +{ + var ab = new ArrayBuffer(0x1000); + + var len = + { + valueOf: function() + { + detachArrayBuffer(ab); + gc(); + return 0x800; + } + }; + + var ok = false; + try + { + new DataView(ab, 0x800, len); + } + catch (e) + { + ok = true; + } + assertEq(ok, true, "byteLength weirdness should have thrown"); + assertEq(ab.byteLength, 0, "detaching should work for byteLength weirdness"); +} +testByteLength(); + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete"); diff --git a/js/src/tests/non262/extensions/DataView-set-arguments-detaching.js b/js/src/tests/non262/extensions/DataView-set-arguments-detaching.js new file mode 100644 index 0000000000..0f1df608f4 --- /dev/null +++ b/js/src/tests/non262/extensions/DataView-set-arguments-detaching.js @@ -0,0 +1,84 @@ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +var gTestfile = "DataView-set-arguments-detaching.js"; +//----------------------------------------------------------------------------- +var BUGNUMBER = 991981; +var summary = + "DataView.prototype.set* methods shouldn't misbehave horribly if " + + "index-argument conversion detaches the ArrayBuffer being modified"; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +function testIndex() +{ + var ab = new ArrayBuffer(0x1000); + + var dv = new DataView(ab); + + var start = + { + valueOf: function() + { + detachArrayBuffer(ab); + gc(); + return 0xFFF; + } + }; + + var ok = false; + try + { + dv.setUint8(start, 0x42); + } + catch (e) + { + ok = true; + } + assertEq(ok, true, "should have thrown"); + assertEq(ab.byteLength, 0, "should have been detached correctly"); +} +testIndex(); + +function testValue() +{ + var ab = new ArrayBuffer(0x100000); + + var dv = new DataView(ab); + + var value = + { + valueOf: function() + { + detachArrayBuffer(ab); + gc(); + return 0x42; + } + }; + + var ok = false; + try + { + dv.setUint8(0xFFFFF, value); + } + catch (e) + { + ok = true; + } + assertEq(ok, true, "should have thrown"); + assertEq(ab.byteLength, 0, "should have been detached correctly"); +} +testValue(); + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete"); diff --git a/js/src/tests/non262/extensions/Number-toSource.js b/js/src/tests/non262/extensions/Number-toSource.js new file mode 100644 index 0000000000..e52a92828c --- /dev/null +++ b/js/src/tests/non262/extensions/Number-toSource.js @@ -0,0 +1,19 @@ +// |reftest| skip-if(!Number.prototype.toSource) + +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +assertEq(raisesException(TypeError)('Number.prototype.toSource.call("")'), true); +assertEq(raisesException(TypeError)('Number.prototype.toSource.call(true)'), true); +assertEq(raisesException(TypeError)('Number.prototype.toSource.call({})'), true); +assertEq(raisesException(TypeError)('Number.prototype.toSource.call(null)'), true); +assertEq(raisesException(TypeError)('Number.prototype.toSource.call([])'), true); +assertEq(raisesException(TypeError)('Number.prototype.toSource.call(undefined)'), true); +assertEq(raisesException(TypeError)('Number.prototype.toSource.call(new Boolean(true))'), true); + +assertEq(completesNormally('Number.prototype.toSource.call(42)'), true); +assertEq(completesNormally('Number.prototype.toSource.call(new Number(42))'), true); + +reportCompare(true, true); diff --git a/js/src/tests/non262/extensions/RegExp-error-message-skip-selfhosted-frames.js b/js/src/tests/non262/extensions/RegExp-error-message-skip-selfhosted-frames.js new file mode 100644 index 0000000000..fd45717476 --- /dev/null +++ b/js/src/tests/non262/extensions/RegExp-error-message-skip-selfhosted-frames.js @@ -0,0 +1,11 @@ +for (let name of ["test", Symbol.match, Symbol.replace, Symbol.search]) { + try { + RegExp.prototype[name].call({}); + } catch (e) { + let methodName = typeof name === "symbol" ? `[${name.description}]` : name; + assertEq(e.message, `${methodName} method called on incompatible Object`); + } +} + +if (typeof reportCompare === "function") + reportCompare(true, true); diff --git a/js/src/tests/non262/extensions/String-match-flags.js b/js/src/tests/non262/extensions/String-match-flags.js new file mode 100644 index 0000000000..b1a382fdfe --- /dev/null +++ b/js/src/tests/non262/extensions/String-match-flags.js @@ -0,0 +1,27 @@ +var BUGNUMBER = 1263139; +var summary = "String.prototype.match with non-string non-standard flags argument."; + +print(BUGNUMBER + ": " + summary); + +var called; +var flags = { + toString() { + called = true; + return ""; + } +}; + +called = false; +"a".match("a", flags); +assertEq(called, false); + +called = false; +"a".search("a", flags); +assertEq(called, false); + +called = false; +"a".replace("a", "b", flags); +assertEq(called, false); + +if (typeof reportCompare === "function") + reportCompare(true, true); diff --git a/js/src/tests/non262/extensions/String-methods-infinite-recursion.js b/js/src/tests/non262/extensions/String-methods-infinite-recursion.js new file mode 100644 index 0000000000..a5972d8c38 --- /dev/null +++ b/js/src/tests/non262/extensions/String-methods-infinite-recursion.js @@ -0,0 +1,36 @@ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 657585; +var summary = + 'Guard against infinite recursion when converting |this| to string for the ' + + 'String.prototype.* methods'; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +try +{ + var obj = {}; + obj.toString = String.prototype.charAt; + "" + obj; + throw new Error("should have thrown"); +} +catch (e) +{ + assertEq(e instanceof InternalError, true, + "should have thrown InternalError for over-recursion, got: " + e); +} + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("All tests passed!"); diff --git a/js/src/tests/non262/extensions/String-toSource.js b/js/src/tests/non262/extensions/String-toSource.js new file mode 100644 index 0000000000..ef872a96f3 --- /dev/null +++ b/js/src/tests/non262/extensions/String-toSource.js @@ -0,0 +1,16 @@ +// |reftest| skip-if(!String.prototype.toSource) + +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +assertEq(raisesException(TypeError)('String.prototype.toSource.call(42)'), true); +assertEq(raisesException(TypeError)('String.prototype.toSource.call(true)'), true); +assertEq(raisesException(TypeError)('String.prototype.toSource.call({})'), true); +assertEq(raisesException(TypeError)('String.prototype.toSource.call(null)'), true); +assertEq(raisesException(TypeError)('String.prototype.toSource.call([])'), true); +assertEq(raisesException(TypeError)('String.prototype.toSource.call(undefined)'), true); +assertEq(completesNormally('String.prototype.toSource.call("")'), true); + +reportCompare(true, true); diff --git a/js/src/tests/non262/extensions/TypedArray-set-object-funky-length-detaches.js b/js/src/tests/non262/extensions/TypedArray-set-object-funky-length-detaches.js new file mode 100644 index 0000000000..66e539b99d --- /dev/null +++ b/js/src/tests/non262/extensions/TypedArray-set-object-funky-length-detaches.js @@ -0,0 +1,55 @@ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +var gTestfile = "set-object-funky-length-detaches.js"; +//----------------------------------------------------------------------------- +var BUGNUMBER = 991981; +var summary = + "%TypedArray%.prototype.set(object w/funky length property, offset) " + + "shouldn't misbehave if the funky length property detaches this typed " + + "array's buffer"; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +var ctors = [Int8Array, Uint8Array, Uint8ClampedArray, + Int16Array, Uint16Array, + Int32Array, Uint32Array, + Float32Array, Float64Array]; +ctors.forEach(function(TypedArray) { + var buf = new ArrayBuffer(512 * 1024); + var ta = new TypedArray(buf); + + var arraylike = + { + 0: 17, + 1: 42, + 2: 3, + 3: 99, + 4: 37, + 5: 9, + 6: 72, + 7: 31, + 8: 22, + 9: 0, + get length() + { + detachArrayBuffer(buf); + return 10; + } + }; + + ta.set(arraylike, 0x1234); +}); + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete"); diff --git a/js/src/tests/non262/extensions/TypedArray-subarray-arguments-detaching.js b/js/src/tests/non262/extensions/TypedArray-subarray-arguments-detaching.js new file mode 100644 index 0000000000..04c12c6423 --- /dev/null +++ b/js/src/tests/non262/extensions/TypedArray-subarray-arguments-detaching.js @@ -0,0 +1,111 @@ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +var gTestfile = "TypedArray-subarray-arguments-detaching.js"; +//----------------------------------------------------------------------------- +var BUGNUMBER = 991981; +var summary = + "%TypedArray.prototype.subarray 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.subarray(begin); + } + catch (e) + { + ok = true; + } + assertEq(ok, true, "start weirdness should have thrown"); + assertEq(ab.byteLength, 0, "detaching should work for start weirdness"); +} +testBegin(); + +function testBeginWithEnd() +{ + var ab = new ArrayBuffer(0x1000); + + var begin = + { + valueOf: function() + { + detachArrayBuffer(ab); + return 0x800; + } + }; + + var ta = new Uint8Array(ab); + + var ok = false; + try + { + ta.subarray(begin, 0x1000); + } + catch (e) + { + ok = true; + } + assertEq(ok, true, "start weirdness should have thrown"); + assertEq(ab.byteLength, 0, "detaching should work for start weirdness"); +} +testBeginWithEnd(); + +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.subarray(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(); + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete"); diff --git a/js/src/tests/non262/extensions/__proto__.js b/js/src/tests/non262/extensions/__proto__.js new file mode 100644 index 0000000000..aa6d608766 --- /dev/null +++ b/js/src/tests/non262/extensions/__proto__.js @@ -0,0 +1,53 @@ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +var gTestfile = '__proto__.js'; +var BUGNUMBER = 770344; +var summary = "__proto__ as accessor"; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +var protoDesc = Object.getOwnPropertyDescriptor(Object.prototype, "__proto__"); +assertEq(protoDesc !== null, true); +assertEq(typeof protoDesc, "object"); +assertEq(protoDesc.hasOwnProperty("get"), true); +assertEq(protoDesc.hasOwnProperty("set"), true); +assertEq(protoDesc.hasOwnProperty("enumerable"), true); +assertEq(protoDesc.hasOwnProperty("configurable"), true); +assertEq(protoDesc.hasOwnProperty("value"), false); +assertEq(protoDesc.hasOwnProperty("writable"), false); + +assertEq(protoDesc.configurable, true); +assertEq(protoDesc.enumerable, false); +assertEq(typeof protoDesc.get, "function", protoDesc.get + ""); +assertEq(typeof protoDesc.set, "function", protoDesc.set + ""); + +assertEq(delete Object.prototype.__proto__, true); +assertEq(Object.getOwnPropertyDescriptor(Object.prototype, "__proto__"), + undefined); + +var obj = {}; +obj.__proto__ = 5; +assertEq(Object.getPrototypeOf(obj), Object.prototype); +assertEq(obj.hasOwnProperty("__proto__"), true); + +var desc = Object.getOwnPropertyDescriptor(obj, "__proto__"); +assertEq(desc !== null, true); +assertEq(typeof desc, "object"); +assertEq(desc.value, 5); +assertEq(desc.writable, true); +assertEq(desc.enumerable, true); +assertEq(desc.configurable, true); + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete"); diff --git a/js/src/tests/non262/extensions/arguments-property-access-in-function.js b/js/src/tests/non262/extensions/arguments-property-access-in-function.js new file mode 100644 index 0000000000..f8c7e97f16 --- /dev/null +++ b/js/src/tests/non262/extensions/arguments-property-access-in-function.js @@ -0,0 +1,58 @@ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + * Contributor: + * Jeff Walden <jwalden+code@mit.edu> + */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 721322; +var summary = + 'f.arguments must trigger an arguments object in non-strict mode functions'; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +var obj = + { + test: function() + { + var args = obj.test.arguments; + assertEq(args !== null, true); + assertEq(args[0], 5); + assertEq(args[1], undefined); + assertEq(args.length, 2); + } + }; +obj.test(5, undefined); + +var sobj = + { + test: function() + { + "use strict"; + + try + { + var args = sobj.test.arguments; + throw new Error("access to arguments property of strict mode " + + "function didn't throw"); + } + catch (e) + { + assertEq(e instanceof TypeError, true, + "should have thrown TypeError, instead got: " + e); + } + } + }; +sobj.test(5, undefined); + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete"); diff --git a/js/src/tests/non262/extensions/array-inherited-__proto__.js b/js/src/tests/non262/extensions/array-inherited-__proto__.js new file mode 100644 index 0000000000..0409d47575 --- /dev/null +++ b/js/src/tests/non262/extensions/array-inherited-__proto__.js @@ -0,0 +1,32 @@ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +var gTestfile = 'array-inherited-__proto__.js'; +var BUGNUMBER = 769041; +var summary = + "The [[Prototype]] of an object whose prototype chain contains an array " + + "isn't that array's [[Prototype]]"; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +var arr = []; +assertEq(Array.isArray(arr), true); +var objWithArrPrototype = Object.create(arr); +assertEq(!Array.isArray(objWithArrPrototype), true); +assertEq(objWithArrPrototype.__proto__, arr); +var objWithArrGrandPrototype = Object.create(objWithArrPrototype); +assertEq(!Array.isArray(objWithArrGrandPrototype), true); +assertEq(objWithArrGrandPrototype.__proto__, objWithArrPrototype); + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete"); diff --git a/js/src/tests/non262/extensions/array-isArray-proxy-recursion.js b/js/src/tests/non262/extensions/array-isArray-proxy-recursion.js new file mode 100644 index 0000000000..ca2907a99a --- /dev/null +++ b/js/src/tests/non262/extensions/array-isArray-proxy-recursion.js @@ -0,0 +1,41 @@ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 1282047; +var summary = 'Infinite recursion via Array.isArray on a proxy'; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +var proxy = Proxy.revocable([], {}).proxy; + +// A depth of 100000 ought to be enough for any platform to consume its entire +// stack, hopefully without making any recalcitrant platforms time out. If no +// timeout happens, the assertEq checks for the proper expected value. +for (var i = 0; i < 1e5; i++) + proxy = new Proxy(proxy, {}); + +try +{ + assertEq(Array.isArray(proxy), true); + + // If we reach here, it's cool, we just didn't consume the entire stack. +} +catch (e) +{ + assertEq(e instanceof InternalError, true, + "should have thrown for over-recursion"); +} + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete"); diff --git a/js/src/tests/non262/extensions/array-length-protochange.js b/js/src/tests/non262/extensions/array-length-protochange.js new file mode 100644 index 0000000000..aeec8e9a22 --- /dev/null +++ b/js/src/tests/non262/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/non262/extensions/array-pop-proxy.js b/js/src/tests/non262/extensions/array-pop-proxy.js new file mode 100644 index 0000000000..15c230977a --- /dev/null +++ b/js/src/tests/non262/extensions/array-pop-proxy.js @@ -0,0 +1,24 @@ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +var gTestfile = 'array-pop-proxy.js'; +var BUGNUMBER = 858381; +var summary = "Behavior of [].pop on proxies"; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +var p = new Proxy([0, 1, 2], {}); +Array.prototype.pop.call(p); + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete"); diff --git a/js/src/tests/non262/extensions/array-toString-recursion.js b/js/src/tests/non262/extensions/array-toString-recursion.js new file mode 100644 index 0000000000..aa5d856c3b --- /dev/null +++ b/js/src/tests/non262/extensions/array-toString-recursion.js @@ -0,0 +1,46 @@ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 635389; +var summary = 'Infinite recursion via [].{toString,toLocaleString,join}'; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +try +{ + var x = []; + x.join = Array.prototype.toString; + "" + x; + throw new Error("should have thrown"); +} +catch (e) +{ + assertEq(e instanceof InternalError, true, + "should have thrown for over-recursion"); +} + +try +{ + var x = { toString: Array.prototype.toString, join: Array.prototype.toString }; + "" + x; + throw new Error("should have thrown"); +} +catch (e) +{ + assertEq(e instanceof InternalError, true, + "should have thrown for over-recursion"); +} + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("All tests passed!"); diff --git a/js/src/tests/non262/extensions/arraybuffer-prototype.js b/js/src/tests/non262/extensions/arraybuffer-prototype.js new file mode 100644 index 0000000000..c61b317762 --- /dev/null +++ b/js/src/tests/non262/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/non262/extensions/bad-regexp-data-clone.js b/js/src/tests/non262/extensions/bad-regexp-data-clone.js new file mode 100644 index 0000000000..70ed427a6a --- /dev/null +++ b/js/src/tests/non262/extensions/bad-regexp-data-clone.js @@ -0,0 +1,20 @@ +// |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/ + +let data = new Uint8Array([ + 104,97,108,101,6,0,255,255,95,98, + 0,0,0,0,0,104,97,108,101,9,0,255, + 255,95,98,115,0,0,0,0,0,0,65,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0 +]); +let cloneBuffer = serialize(null); +cloneBuffer.clonebuffer = data.buffer; + +// One of the bytes above encodes a JS::RegExpFlags, but that byte contains bits +// outside of JS::RegExpFlag::AllFlags and so will trigger an error. +assertThrowsInstanceOf(() => deserialize(cloneBuffer), InternalError); + +if (typeof reportCompare === "function") + reportCompare(0, 0, 'ok'); diff --git a/js/src/tests/non262/extensions/basic-for-each.js b/js/src/tests/non262/extensions/basic-for-each.js new file mode 100644 index 0000000000..851faf4193 --- /dev/null +++ b/js/src/tests/non262/extensions/basic-for-each.js @@ -0,0 +1,58 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = "346582"; +var summary = "Basic support for iterable objects and for-each"; +var actual, expect; + +printBugNumber(BUGNUMBER); +printStatus(summary); + +/************** + * BEGIN TEST * + **************/ + +var failed = false; + +var iterable = { persistedProp: 17 }; + +function Array_equals(a, b) +{ + if (!(a instanceof Array) || !(b instanceof Array)) + throw new Error("Arguments not both of type Array"); + if (a.length != b.length) + return false; + for (var i = 0, sz = a.length; i < sz; i++) + if (a[i] !== b[i]) + return false; + return true; +} + +try +{ + // nothing unusual so far -- verify basic properties + for (var i in iterable) + { + if (i != "persistedProp") + throw "no persistedProp!"; + if (iterable[i] != 17) + throw "iterable[\"persistedProp\"] == 17"; + } + + if (iterable.persistedProp != 17) + throw "iterable.persistedProp not persisted!"; +} +catch (e) +{ + failed = e; +} + + + +expect = false; +actual = failed; + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/non262/extensions/basic-for-in.js b/js/src/tests/non262/extensions/basic-for-in.js new file mode 100644 index 0000000000..f1476c65c5 --- /dev/null +++ b/js/src/tests/non262/extensions/basic-for-in.js @@ -0,0 +1,46 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = "346582"; +var summary = "Basic support for iterable objects and for-in"; +var actual, expect; + +printBugNumber(BUGNUMBER); +printStatus(summary); + +/************** + * BEGIN TEST * + **************/ + +var failed = false; + +var iterable = { persistedProp: 17 }; + +try +{ + // nothing unusual so far -- verify basic properties + for (var i in iterable) + { + if (i != "persistedProp") + throw "no persistedProp!"; + if (iterable[i] != 17) + throw "iterable[\"persistedProp\"] == 17"; + } + + if (iterable.persistedProp != 17) + throw "iterable.persistedProp not persisted!"; +} +catch (e) +{ + failed = e; +} + + + +expect = false; +actual = failed; + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/non262/extensions/browser.js b/js/src/tests/non262/extensions/browser.js new file mode 100644 index 0000000000..6cd01ab6f8 --- /dev/null +++ b/js/src/tests/non262/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(/\/[^/?]*(\?.*)?$/, '/') + + 'non262/extensions/'); + diff --git a/js/src/tests/non262/extensions/bug472534.js b/js/src/tests/non262/extensions/bug472534.js new file mode 100644 index 0000000000..0c7d5f3ecb --- /dev/null +++ b/js/src/tests/non262/extensions/bug472534.js @@ -0,0 +1,30 @@ +function monthNames () { + return [ + /jan(uar(y)?)?/, 0, + /feb(ruar(y)?)?/, 1, + /m\u00e4r|mar|m\u00e4rz|maerz|march/, 2, + /apr(il)?/, 3, + /ma(i|y)/, 4, + /jun(i|o|e)?/, 5, + /jul(i|y)?/, 6, + /aug(ust)?/, 7, + /sep((t)?(ember))?/, 8, + /o(c|k)t(ober)?/, 9, + /nov(ember)?/, 10, + /de(c|z)(ember)?/, 11 + ]; +}; + +var actual = ''; +var expected = '(jan(uar(y)?)?)|(feb(ruar(y)?)?)|(m\\u00e4r|mar|m\\u00e4rz|maerz|march)|(apr(il)?)|(ma(i|y))|(jun(i|o|e)?)|(jul(i|y)?)|(aug(ust)?)|(sep((t)?(ember))?)|(o(c|k)t(ober)?)|(nov(ember)?)|(de(c|z)(ember)?)'; +var mn = monthNames(); +for (var i = 0; i < mn.length; ++i) { + if (actual) + actual += '|'; + actual += '(' + mn[i++].source + ')'; +} + +assertEq(actual, expected); + +if (typeof reportCompare === "function") + reportCompare(true, true); diff --git a/js/src/tests/non262/extensions/builtin-function-arguments-caller.js b/js/src/tests/non262/extensions/builtin-function-arguments-caller.js new file mode 100644 index 0000000000..2acf5f452f --- /dev/null +++ b/js/src/tests/non262/extensions/builtin-function-arguments-caller.js @@ -0,0 +1,60 @@ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +var gTestfile = 'builtin-function-arguments-caller.js'; +var BUGNUMBER = 929642; +var summary = + "Built-in functions defined in ECMAScript pick up arguments/caller " + + "properties from Function.prototype"; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +function expectNoProperty(obj, prop) +{ + var desc = Object.getOwnPropertyDescriptor(obj, prop); + assertEq(desc, undefined, + "should be no '" + prop + "' property on " + obj); +} + +// Test a builtin that's native. +expectNoProperty(Object, "arguments"); +expectNoProperty(Object, "caller"); + +// Also test a builtin that's self-hosted. +expectNoProperty(Array.prototype.indexOf, "arguments"); +expectNoProperty(Array.prototype.indexOf, "caller"); + +// Test the Function construct for good measure, because it's so intricately +// invovled in bootstrapping. +expectNoProperty(Function, "arguments"); +expectNoProperty(Function, "caller"); + +var argsDesc = Object.getOwnPropertyDescriptor(Function.prototype, "arguments"); +var callerDesc = Object.getOwnPropertyDescriptor(Function.prototype, "caller"); + +var argsGet = argsDesc.get, argsSet = argsDesc.set; + +expectNoProperty(argsGet, "arguments"); +expectNoProperty(argsGet, "caller"); +expectNoProperty(argsSet, "arguments"); +expectNoProperty(argsSet, "caller"); + +var callerGet = callerDesc.get, callerSet = callerDesc.set; + +expectNoProperty(callerGet, "arguments"); +expectNoProperty(callerGet, "caller"); +expectNoProperty(callerSet, "arguments"); +expectNoProperty(callerSet, "caller"); + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete"); diff --git a/js/src/tests/non262/extensions/censor-strict-caller.js b/js/src/tests/non262/extensions/censor-strict-caller.js new file mode 100644 index 0000000000..b23469953d --- /dev/null +++ b/js/src/tests/non262/extensions/censor-strict-caller.js @@ -0,0 +1,15 @@ +// Any copyright is dedicated to the Public Domain. +// http://creativecommons.org/licenses/publicdomain/ + + +function nonstrict() { return nonstrict.caller; } +function strict() { "use strict"; return nonstrict(); } + +assertEq(strict(), null); + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("All tests passed!"); diff --git a/js/src/tests/non262/extensions/clone-bigint.js b/js/src/tests/non262/extensions/clone-bigint.js new file mode 100644 index 0000000000..a40bbed8f4 --- /dev/null +++ b/js/src/tests/non262/extensions/clone-bigint.js @@ -0,0 +1,20 @@ +// |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 testBigInt(b) { + var a = deserialize(serialize(b)); + assertEq(typeof b, "bigint"); + assertEq(typeof a, "bigint"); + assertEq(a, b); +} + +testBigInt(0n); +testBigInt(-1n); +testBigInt(1n); + +testBigInt(0xffffFFFFffffFFFFffffFFFFffffFFFFn); +testBigInt(-0xffffFFFFffffFFFFffffFFFFffffFFFFn); + +reportCompare(0, 0, 'ok'); diff --git a/js/src/tests/non262/extensions/clone-complex-object.js b/js/src/tests/non262/extensions/clone-complex-object.js new file mode 100644 index 0000000000..869a7d805f --- /dev/null +++ b/js/src/tests/non262/extensions/clone-complex-object.js @@ -0,0 +1,313 @@ +// |reftest| slow 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 " + propname + " " + 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 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/non262/extensions/clone-errors.js b/js/src/tests/non262/extensions/clone-errors.js new file mode 100644 index 0000000000..38e0e78a6f --- /dev/null +++ b/js/src/tests/non262/extensions/clone-errors.js @@ -0,0 +1,110 @@ +// |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 " + JSON.stringify(v) + " should have failed with an exception"); +} + +// Unsupported object types. +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 [['SameProcess', 'DifferentProcessForIndexedDB'], + ['SameProcess', '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}`); +} + +// Extra data. This is not checked in #define FUZZING builds. +const fuzzing = getBuildConfiguration()['fuzzing-defined']; +const shouldThrow = fuzzing === false; + +var clone = serialize({foo: 7}, undefined, {scope: 'DifferentProcess'}); +deserialize(clone); +clone.clonebuffer = clone.clonebuffer + "\0\0\0\0\0\0\0\0"; +var exc = {message: 'no error'}; +try { + deserialize(clone); +} catch (e) { + exc = e; +} +if (shouldThrow) { + assertEq(exc.message.includes("bad serialized structured data"), true); + assertEq(exc.message.includes("extra data"), true); +} + +// Extra data between the main body and "tail" of the clone data. +function dumpData(data) { + data.forEach((x, i) => print(`[${i}] 0x${(i*8).toString(16)} : 0x${x.toString(16)}`)); +} + +function testInnerExtraData() { + const ab = new ArrayBuffer(8); + (new BigUint64Array(ab))[0] = 0xdeadbeefn; + const clone = serialize({ABC: 7, CBA: ab}, [ab], {scope: 'DifferentProcess'}); + + const data = [...new BigUint64Array(clone.arraybuffer)]; + dumpData(data); + + const fake = new ArrayBuffer(clone.arraybuffer.byteLength + 24); + const view = new BigUint64Array(fake); + view.set(new BigUint64Array(clone.arraybuffer), 0); + view[1] = view[1] & ~1n; // SCTAG_TRANSFER_MAP_HEADER with SCTAG_TM_UNREAD + view[5] += 24n; // Make space for another ArrayBuffer clone at the end + view[9] = 0xffff00030000000dn; // Change the constant 7 to 13 + view[16] = 0xfeeddeadbeef2dadn; // Change stored ArrayBuffer contents + view[17] = view[14]; // SCTAG_ARRAY_BUFFER_OBJECT_V2 + view[18] = view[15]; // 8 bytes long + view[19] = 0x1cedc0ffeen; // Content + + dumpData(view); + clone.arraybuffer = fake; + + let d; + let exc; + try { + d = deserialize(clone); + print(JSON.stringify(d)); + print(new BigUint64Array(d.CBA)[0].toString(16)); + } catch (e) { + exc = e; + } + + const fuzzing = getBuildConfiguration()['fuzzing-defined']; + const shouldThrow = fuzzing === false; + + if (shouldThrow) { + assertEq(Boolean(exc), true); + assertEq(exc.message.includes("extra data"), true); + print(`PASS with FUZZING: Found expected exception "${exc.message}"`); + } else { + assertEq(new BigUint64Array(d.CBA)[0].toString(16), "1cedc0ffee"); + assertEq(d.ABC, 13); + print("PASS without FUZZING"); + } +} + +testInnerExtraData(); + +reportCompare(0, 0, "ok"); diff --git a/js/src/tests/non262/extensions/clone-forge.js b/js/src/tests/non262/extensions/clone-forge.js new file mode 100644 index 0000000000..3cdb0ea0df --- /dev/null +++ b/js/src/tests/non262/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/non262/extensions/clone-invalid-property-key.js b/js/src/tests/non262/extensions/clone-invalid-property-key.js new file mode 100644 index 0000000000..9b0347586c --- /dev/null +++ b/js/src/tests/non262/extensions/clone-invalid-property-key.js @@ -0,0 +1,22 @@ +// Don't allow serialized data to use objects as property keys. + +if (typeof serialize === "function") { + let data = new Uint8Array([ + 104,97,108,101,7,0,255,255,95,98,0,0,0,0,0,104,97,108,101,9,0,255,255,95,98, + 115,10,109,97,120,95,108,101,110,0,0,0,0,109,97,120,95,108,101,110,0,0,0,0,0, + 0,0,0,0,246,0,0,0,42,4,0,0,0,0,0,0,0,0,0,0,0,0,65,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,253,0,0,0,0,0,0,0,0,0,0,0,0, + 191,190,190,184,65,65,65,65,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,104,97,108,101,9,0, + 255,255,95,98,115,10,109,97,120,95,110,100,108,213,95,175,175,175,175,175,0, + 0,0,0,0,2,0,0,0,0,0,13,0,255,255,96,125,115,135,109,97,120,110,0,0,32,0,8,0, + 0,0 + ]); + let cloneBuffer = serialize(null); + cloneBuffer.clonebuffer = data.buffer; + try { + let obj = deserialize(cloneBuffer); + } catch(exc1) {} +} + +reportCompare(0, 0); diff --git a/js/src/tests/non262/extensions/clone-leaf-object.js b/js/src/tests/non262/extensions/clone-leaf-object.js new file mode 100644 index 0000000000..081a9b666e --- /dev/null +++ b/js/src/tests/non262/extensions/clone-leaf-object.js @@ -0,0 +1,68 @@ +// |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]; + if (x.toSource) { + 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)); + if (x.toSource) { + 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/non262/extensions/clone-many-transferables.js b/js/src/tests/non262/extensions/clone-many-transferables.js new file mode 100644 index 0000000000..463dc74ee7 --- /dev/null +++ b/js/src/tests/non262/extensions/clone-many-transferables.js @@ -0,0 +1,25 @@ +// |reftest| slow 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/non262/extensions/clone-object-deep.js b/js/src/tests/non262/extensions/clone-object-deep.js new file mode 100644 index 0000000000..685577b924 --- /dev/null +++ b/js/src/tests/non262/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/non262/extensions/clone-object.js b/js/src/tests/non262/extensions/clone-object.js new file mode 100644 index 0000000000..56a2166bec --- /dev/null +++ b/js/src/tests/non262/extensions/clone-object.js @@ -0,0 +1,143 @@ +// |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); + + // Check that array's .length property is cloned. + b = Array(5); + assertEq(b.length, 5); + a = check(b); + assertEq(a.length, 5); + + b = Array(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); + + // Check that trailing holes in an array are preserved. + b = [1,2,3,,]; + assertEq(b.length, 4); + a = check(b); + assertEq(a.length, 4); + assertEq(a.toString(), "1,2,3,"); + + b = [1,2,3,,,]; + assertEq(b.length, 5); + a = check(b); + assertEq(a.length, 5); + assertEq(a.toString(), "1,2,3,,"); + + // 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/non262/extensions/clone-regexp.js b/js/src/tests/non262/extensions/clone-regexp.js new file mode 100644 index 0000000000..8541dae98c --- /dev/null +++ b/js/src/tests/non262/extensions/clone-regexp.js @@ -0,0 +1,36 @@ +// |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); + +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/non262/extensions/clone-sab-failure.js b/js/src/tests/non262/extensions/clone-sab-failure.js new file mode 100644 index 0000000000..ff24dcb9e5 --- /dev/null +++ b/js/src/tests/non262/extensions/clone-sab-failure.js @@ -0,0 +1,39 @@ +// |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/ + */ + +// Failure to serialize an object containing a SAB should not leave the SAB's +// rawbuffer's reference count incremented. + +if (!this.SharedArrayBuffer || !this.sharedArrayRawBufferRefcount) { + reportCompare(true,true); + quit(0); +} + +let x = new SharedArrayBuffer(1); + +// Initially the reference count is 1. +assertEq(sharedArrayRawBufferRefcount(x), 1); + +let y = serialize(x, [], {SharedArrayBuffer: 'allow'}); + +// Serializing it successfully increments the reference count. +assertEq(sharedArrayRawBufferRefcount(x), 2); + +// Serializing something containing a function should throw. +var failed = false; +try { + serialize([x, function () {}]); +} +catch (e) { + failed = true; +} +assertEq(failed, true); + +// Serializing the SAB unsuccessfully does not increment the reference count. +assertEq(sharedArrayRawBufferRefcount(x), 2); + +reportCompare(true, true); diff --git a/js/src/tests/non262/extensions/clone-sab.js b/js/src/tests/non262/extensions/clone-sab.js new file mode 100644 index 0000000000..3b35f90abc --- /dev/null +++ b/js/src/tests/non262/extensions/clone-sab.js @@ -0,0 +1,31 @@ +// |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/ + */ + +// Deserialize a serialization buffer containing a reference to a +// SharedArrayBuffer buffer object enough times and we will crash because of a +// reference counting bug. + +if (!this.SharedArrayBuffer) { + reportCompare(true,true); + quit(0); +} + +let x = new SharedArrayBuffer(1); +let y = serialize(x, [], {SharedArrayBuffer: 'allow'}); +x = null; + +// If the bug is present this loop usually crashes quickly during +// deserialization because the memory has become unmapped. + +for (let i=0 ; i < 50 ; i++ ) { + let obj = deserialize(y, {SharedArrayBuffer: 'allow'}); + let z = new Int8Array(obj); + z[0] = 0; +} + +reportCompare(true, true); + diff --git a/js/src/tests/non262/extensions/clone-simple.js b/js/src/tests/non262/extensions/clone-simple.js new file mode 100644 index 0000000000..b7684dd02a --- /dev/null +++ b/js/src/tests/non262/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/non262/extensions/clone-transferables.js b/js/src/tests/non262/extensions/clone-transferables.js new file mode 100644 index 0000000000..6b3ff99079 --- /dev/null +++ b/js/src/tests/non262/extensions/clone-transferables.js @@ -0,0 +1,129 @@ +// |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 ["SameProcess", + "DifferentProcess", + "DifferentProcessForIndexedDB"]) + { + 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"); + if (!dataview) { + assertEq(old_arr.byteLength, 0, + "donor typed array should be detached"); + assertEq(old_arr.length, 0, + "donor typed array should be 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) { + const b1 = new ArrayBuffer(size); + let mutator = { + get foo() { + serialize(b1, [b1], { scope }); + } + }; + + assertThrowsInstanceOf( + () => serialize([ b1, mutator ], [b1]), + TypeError, + "detaching (due to Transferring) while serializing should throw" + ); + + const b2 = new ArrayBuffer(size); + mutator = { + get foo() { + detachArrayBuffer(b2); + } + }; + + assertThrowsInstanceOf( + () => serialize([ b2, mutator ], [b2]), + TypeError, + "detaching (due to detachArrayBuffer) while serializing should throw" + ); + } + } +} + +test(); +reportCompare(0, 0, 'ok'); diff --git a/js/src/tests/non262/extensions/clone-typed-array.js b/js/src/tests/non262/extensions/clone-typed-array.js new file mode 100644 index 0000000000..77f0376e91 --- /dev/null +++ b/js/src/tests/non262/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/non262/extensions/clone-v1-typed-array-data.dat b/js/src/tests/non262/extensions/clone-v1-typed-array-data.dat new file mode 100644 index 0000000000..9ced341009 --- /dev/null +++ b/js/src/tests/non262/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/non262/extensions/clone-v1-typed-array.js b/js/src/tests/non262/extensions/clone-v1-typed-array.js new file mode 100644 index 0000000000..ae81075e83 --- /dev/null +++ b/js/src/tests/non262/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].toString() + ";"); + } 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/non262/extensions/collect-gray.js b/js/src/tests/non262/extensions/collect-gray.js new file mode 100644 index 0000000000..4beb9f094f --- /dev/null +++ b/js/src/tests/non262/extensions/collect-gray.js @@ -0,0 +1,153 @@ +// |reftest| skip-if(!xulRuntime.shell) +// Any copyright is dedicated to the Public Domain. +// http://creativecommons.org/licenses/publicdomain/ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 1337209; +var summary = + "Test gray marking"; + +print(BUGNUMBER + ": " + summary); + +if (typeof gczeal !== 'undefined') + gczeal(0); + +grayRoot().x = Object.create(null); +addMarkObservers([grayRoot(), grayRoot().x, this, Object.create(null)]); +gc(); +let marks = getMarks(); +assertEq(marks[0], 'gray', 'gray root'); +assertEq(marks[1], 'gray', 'object reachable from gray root'); +assertEq(marks[2], 'black', 'global'); +assertEq(marks[3], 'dead', 'dead object should have been collected'); + +grayRoot().x = 7; // Overwrite the object +gc(); +marks = getMarks(); +assertEq(marks[0], 'gray', 'gray root'); +assertEq(marks[1], 'dead', 'object no longer reachable from gray root'); +assertEq(marks[2], 'black', 'global'); +assertEq(marks[3], 'dead', 'dead object should have been collected'); + +var wm = new WeakMap(); +var global = newGlobal({newCompartment: true}); + +var wrapper1 = global.eval("Object.create(null)"); +wrapper1.name = "wrapper1"; +var value1 = Object.create(null); +wm.set(wrapper1, value1); + +var wrapper2 = global.eval("Object.create(null)"); +wrapper2.name = "wrapper2"; +var value2 = global.eval("Object.create(null)"); +wm.set(wrapper2, value2); + +grayRoot().root1 = wrapper1; +grayRoot().root2 = wrapper2; +clearMarkObservers(); +addMarkObservers([wrapper1, value1, wrapper2, value2]); +wrapper1 = wrapper2 = null; +value1 = value2 = null; +gc(); +marks = getMarks(); +assertEq(marks[0], 'gray', 'gray key 1'); +assertEq(marks[1], 'gray', 'black map, gray key => gray value'); +assertEq(marks[2], 'gray', 'gray key 2'); +assertEq(marks[3], 'gray', 'black map, gray key => gray value'); + +// Blacken one of the keys +wrapper1 = grayRoot().root1; +gc(); +marks = getMarks(); +assertEq(marks[0], 'black', 'black key 1'); +assertEq(marks[1], 'black', 'black map, black key => black value'); +assertEq(marks[2], 'gray', 'gray key 2'); +assertEq(marks[3], 'gray', 'black map, gray key => gray value'); + +// Test edges from map&delegate => key and map&key => value. +// +// In general, when a&b => x, then if both a and b are black, then x must be +// black. If either is gray and the other is marked (gray or black), then x +// must be gray (unless otherwise reachable from black.) If neither a nor b is +// marked at all, then they will not keep x alive. + +clearMarkObservers(); + +// Black map, gray delegate => gray key + +// wm is in a variable, so is black. +wm = new WeakMap(); + +let key = Object.create(null); +// delegate unwraps key in the 'global' compartment +global.grayRoot().delegate = key; + +// Create a value and map to it from a gray key, then make the value a gray +// root. +let value = Object.create(null); +wm.set(key, value); +grayRoot().value = value; + +// We are interested in the mark bits of the map, key, and value, as well as +// the mark bits of the wrapped versions in the other compartment. Note that +// the other-compartment key is the known as the key's delegate with respect to +// the weakmap. +global.addMarkObservers([wm, key, value]); +addMarkObservers([wm, key, value]); + +// Key is otherwise dead in main compartment. +key = null; +// Don't want value to be marked black. +value = null; + +gc(); // Update mark bits. +let [ + other_map_mark, other_key_mark, other_value_mark, + map_mark, key_mark, value_mark +] = getMarks(); +assertEq(other_map_mark, 'dead', 'nothing points to wm in other compartment'); +assertEq(other_key_mark, 'gray', 'delegate should be gray'); +assertEq(other_value_mark, 'dead', 'nothing points to value wrapper in other compartment'); +assertEq(map_mark, 'black', 'map in var => black'); +assertEq(key_mark, 'gray', 'black map, gray delegate => gray key'); +assertEq(value_mark, 'gray', 'black map, gray delegate/key => gray value'); + +// Black map, black delegate => black key + +// Blacken the delegate by pointing to it from the other global. +global.delegate = global.grayRoot().delegate; + +gc(); +[ + other_map_mark, other_key_mark, other_value_mark, + map_mark, key_mark, value_mark +] = getMarks(); +assertEq(other_map_mark, 'dead', 'nothing points to wm in other compartment'); +assertEq(other_key_mark, 'black', 'delegate held in global.delegate'); +assertEq(other_value_mark, 'dead', 'nothing points to value wrapper in other compartment'); +assertEq(map_mark, 'black', 'map in var => black'); +assertEq(key_mark, 'black', 'black map, black delegate => black key'); +assertEq(value_mark, 'black', 'black map, black key => black value'); + +// Gray map, black delegate => gray key. Unfortunately, there's no way to test +// this, because a WeakMap key's delegate is its wrapper, and there is a strong +// edge from wrappers to wrappees. The jsapi-test in testGCGrayMarking, inside +// TestWeakMaps, *does* test this case. + +grayRoot().map = wm; +wm = null; + +gc(); +[ + other_map_mark, other_key_mark, other_value_mark, + map_mark, key_mark, value_mark +] = getMarks(); +assertEq(other_map_mark, 'dead', 'nothing points to wm in other compartment'); +assertEq(other_key_mark, 'black', 'delegate held in global.delegate'); +assertEq(other_value_mark, 'dead', 'nothing points to value wrapper in other compartment'); +assertEq(map_mark, 'gray', 'map is a gray root'); +assertEq(key_mark, 'black', 'black delegate marks its key black'); +assertEq(value_mark, 'gray', 'gray map, black key => gray value'); + +if (typeof reportCompare === "function") + reportCompare(true, true); diff --git a/js/src/tests/non262/extensions/column-numbers.js b/js/src/tests/non262/extensions/column-numbers.js new file mode 100644 index 0000000000..721b05e9f2 --- /dev/null +++ b/js/src/tests/non262/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/non262/extensions/cross-global-eval-is-indirect.js b/js/src/tests/non262/extensions/cross-global-eval-is-indirect.js new file mode 100644 index 0000000000..6cd35846b5 --- /dev/null +++ b/js/src/tests/non262/extensions/cross-global-eval-is-indirect.js @@ -0,0 +1,60 @@ +// |reftest| skip-if(!xulRuntime.shell) -- needs newGlobal() +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 608473; +var summary = + '|var eval = otherWindow.eval; eval(...)| should behave like indirectly ' + + 'calling that eval from a script in that other window'; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +var originalEval = eval; +var res; + +function f() +{ + return [this, eval("this")]; +} + +var otherGlobalSameCompartment = newGlobal("same-compartment"); + +eval = otherGlobalSameCompartment.eval; +res = new f(); +assertEq(res[0] !== res[1], true); +assertEq(res[0] !== this, true); +assertEq(res[0] instanceof f, true); +assertEq(res[1], otherGlobalSameCompartment); + +res = f(); +assertEq(res[0] !== res[1], true); +assertEq(res[0], this); +assertEq(res[1], otherGlobalSameCompartment); + +var otherGlobalDifferentCompartment = newGlobal(); + +eval = otherGlobalDifferentCompartment.eval; +res = new f(); +assertEq(res[0] !== res[1], true); +assertEq(res[0] !== this, true); +assertEq(res[0] instanceof f, true); +assertEq(res[1], otherGlobalDifferentCompartment); + +res = f(); +assertEq(res[0] !== res[1], true); +assertEq(res[0], this); +assertEq(res[1], otherGlobalDifferentCompartment); + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("All tests passed!"); diff --git a/js/src/tests/non262/extensions/cross-global-getPrototypeOf.js b/js/src/tests/non262/extensions/cross-global-getPrototypeOf.js new file mode 100644 index 0000000000..1480a8ea15 --- /dev/null +++ b/js/src/tests/non262/extensions/cross-global-getPrototypeOf.js @@ -0,0 +1,55 @@ +// |reftest| skip-if(!xulRuntime.shell) -- needs newGlobal() +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 770344; +var summary = "Object.getPrototypeOf behavior across compartments"; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +var other = newGlobal(); + +var getProto = Object.getPrototypeOf; +var otherGetProto = other.Object.getPrototypeOf; + +var proto = {}; +var obj = Object.create(proto); +assertEq(getProto(obj), proto); +assertEq(otherGetProto(obj), proto); + +other.proto = proto; +var otherObj = other.evaluate("Object.create(proto)"); +assertEq(getProto(otherObj), proto); +assertEq(otherGetProto(otherObj), proto); + +var p = other.evaluate("({})"); +var objOtherProto = Object.create(p); +assertEq(getProto(objOtherProto), p); +assertEq(otherGetProto(objOtherProto), p); + +other.evaluate("var otherProto = { otherProto: 1 }; " + + "var otherObj = Object.create(otherProto);"); +assertEq(getProto(other.otherObj), other.otherProto); +assertEq(otherGetProto(other.otherObj), other.otherProto); + +other.evaluate("var newOtherProto = { newOtherProto: 1 }; " + + "otherObj.__proto__ = newOtherProto;"); +assertEq(otherGetProto(other.otherObj), other.newOtherProto); + +// TODO This assertion fails due to bug 764307 +//assertEq(getProto(other.otherObj), other.newOtherProto); + + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete"); diff --git a/js/src/tests/non262/extensions/dataview.js b/js/src/tests/non262/extensions/dataview.js new file mode 100644 index 0000000000..b6514df26a --- /dev/null +++ b/js/src/tests/non262/extensions/dataview.js @@ -0,0 +1,1647 @@ +// |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(sharedMem) { + 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'); + } + } + + function bufferize(u8array) { + if (!sharedMem) + return u8array.buffer; + + let v = new Uint8Array(new SharedArrayBuffer(u8array.buffer.byteLength)); + v.set(u8array); + + // Sanity checking + assertEq(v.buffer instanceof SharedArrayBuffer, true); + assertEq(v.buffer.byteLength, u8array.buffer.byteLength); + assertEq(u8array[0], v[0]); + + return v.buffer; + } + + printBugNumber(BUGNUMBER); + printStatus(summary); + + // testConstructor + buffer = bufferize(new Uint8Array([1, 2])); + 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 = bufferize(new Uint8Array(data1)); + 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 = bufferize(new Uint8Array(data2)); + view = new DataView(buffer2, 0, 4); + assertEq(view.getFloat32(0, true), 10); + var buffer2_pad3 = bufferize(new Uint8Array(Array(3).concat(data2))); + view = new DataView(buffer2_pad3, 0, 7); + assertEq(view.getFloat32(3, true), 10); + var buffer2_pad7 = bufferize(new Uint8Array(Array(7).concat(data2))); + view = new DataView(buffer2_pad7, 0, 11); + assertEq(view.getFloat32(7, true), 10); + var buffer2_pad10 = bufferize(new Uint8Array(Array(10).concat(data2))); + view = new DataView(buffer2_pad10, 0, 14); + assertEq(view.getFloat32(10, true), 10); + // Big endian. + var buffer2_r = bufferize(new Uint8Array(data2_r)); + view = new DataView(buffer2_r, 0, 4); + assertEq(view.getFloat32(0, false), 10); + var buffer2_r_pad3 = bufferize(new Uint8Array(Array(3).concat(data2_r))); + view = new DataView(buffer2_r_pad3, 0, 7); + assertEq(view.getFloat32(3, false), 10); + var buffer2_r_pad7 = bufferize(new Uint8Array(Array(7).concat(data2_r))); + view = new DataView(buffer2_r_pad7, 0, 11); + assertEq(view.getFloat32(7, false), 10); + var buffer2_r_pad10 = bufferize(new Uint8Array(Array(10).concat(data2_r))); + 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 = bufferize(new Uint8Array(data3)); + view = new DataView(buffer3, 0, 4); + assertEq(view.getFloat32(0, true), 1.2300000190734863); + var buffer3_pad3 = bufferize(new Uint8Array(Array(3).concat(data3))); + view = new DataView(buffer3_pad3, 0, 7); + assertEq(view.getFloat32(3, true), 1.2300000190734863); + var buffer3_pad7 = bufferize(new Uint8Array(Array(7).concat(data3))); + view = new DataView(buffer3_pad7, 0, 11); + assertEq(view.getFloat32(7, true), 1.2300000190734863); + var buffer3_pad10 = bufferize(new Uint8Array(Array(10).concat(data3))); + view = new DataView(buffer3_pad10, 0, 14); + assertEq(view.getFloat32(10, true), 1.2300000190734863); + // Big endian. + var buffer3_r = bufferize(new Uint8Array(data3_r)); + view = new DataView(buffer3_r, 0, 4); + assertEq(view.getFloat32(0, false), 1.2300000190734863); + var buffer3_r_pad3 = bufferize(new Uint8Array(Array(3).concat(data3_r))); + view = new DataView(buffer3_r_pad3, 0, 7); + assertEq(view.getFloat32(3, false), 1.2300000190734863); + var buffer3_r_pad7 = bufferize(new Uint8Array(Array(7).concat(data3_r))); + view = new DataView(buffer3_r_pad7, 0, 11); + assertEq(view.getFloat32(7, false), 1.2300000190734863); + var buffer3_r_pad10 = bufferize(new Uint8Array(Array(10).concat(data3_r))); + 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 = bufferize(new Uint8Array(data4)); + view = new DataView(buffer4, 0, 4); + assertEq(view.getFloat32(0, true), -45621.37109375); + var buffer4_pad3 = bufferize(new Uint8Array(Array(3).concat(data4))); + view = new DataView(buffer4_pad3, 0, 7); + assertEq(view.getFloat32(3, true), -45621.37109375); + var buffer4_pad7 = bufferize(new Uint8Array(Array(7).concat(data4))); + view = new DataView(buffer4_pad7, 0, 11); + assertEq(view.getFloat32(7, true), -45621.37109375); + var buffer4_pad10 = bufferize(new Uint8Array(Array(10).concat(data4))); + view = new DataView(buffer4_pad10, 0, 14); + assertEq(view.getFloat32(10, true), -45621.37109375); + // Big endian. + var buffer4_r = bufferize(new Uint8Array(data4_r)); + view = new DataView(buffer4_r, 0, 4); + assertEq(view.getFloat32(0, false), -45621.37109375); + var buffer4_r_pad3 = bufferize(new Uint8Array(Array(3).concat(data4_r))); + view = new DataView(buffer4_r_pad3, 0, 7); + assertEq(view.getFloat32(3, false), -45621.37109375); + var buffer4_r_pad7 = bufferize(new Uint8Array(Array(7).concat(data4_r))); + view = new DataView(buffer4_r_pad7, 0, 11); + assertEq(view.getFloat32(7, false), -45621.37109375); + var buffer4_r_pad10 = bufferize(new Uint8Array(Array(10).concat(data4_r))); + 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 = bufferize(new Uint8Array(data5)); + view = new DataView(buffer5, 0, 4); + assertEq(view.getFloat32(0, true), NaN); + var buffer5_pad3 = bufferize(new Uint8Array(Array(3).concat(data5))); + view = new DataView(buffer5_pad3, 0, 7); + assertEq(view.getFloat32(3, true), NaN); + var buffer5_pad7 = bufferize(new Uint8Array(Array(7).concat(data5))); + view = new DataView(buffer5_pad7, 0, 11); + assertEq(view.getFloat32(7, true), NaN); + var buffer5_pad10 = bufferize(new Uint8Array(Array(10).concat(data5))); + view = new DataView(buffer5_pad10, 0, 14); + assertEq(view.getFloat32(10, true), NaN); + // Big endian. + var buffer5_r = bufferize(new Uint8Array(data5_r)); + view = new DataView(buffer5_r, 0, 4); + assertEq(view.getFloat32(0, false), NaN); + var buffer5_r_pad3 = bufferize(new Uint8Array(Array(3).concat(data5_r))); + view = new DataView(buffer5_r_pad3, 0, 7); + assertEq(view.getFloat32(3, false), NaN); + var buffer5_r_pad7 = bufferize(new Uint8Array(Array(7).concat(data5_r))); + view = new DataView(buffer5_r_pad7, 0, 11); + assertEq(view.getFloat32(7, false), NaN); + var buffer5_r_pad10 = bufferize(new Uint8Array(Array(10).concat(data5_r))); + 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 = bufferize(new Uint8Array(data6)); + view = new DataView(buffer6, 0, 4); + assertEq(view.getFloat32(0, true), NaN); + var buffer6_pad3 = bufferize(new Uint8Array(Array(3).concat(data6))); + view = new DataView(buffer6_pad3, 0, 7); + assertEq(view.getFloat32(3, true), NaN); + var buffer6_pad7 = bufferize(new Uint8Array(Array(7).concat(data6))); + view = new DataView(buffer6_pad7, 0, 11); + assertEq(view.getFloat32(7, true), NaN); + var buffer6_pad10 = bufferize(new Uint8Array(Array(10).concat(data6))); + view = new DataView(buffer6_pad10, 0, 14); + assertEq(view.getFloat32(10, true), NaN); + // Big endian. + var buffer6_r = bufferize(new Uint8Array(data6_r)); + view = new DataView(buffer6_r, 0, 4); + assertEq(view.getFloat32(0, false), NaN); + var buffer6_r_pad3 = bufferize(new Uint8Array(Array(3).concat(data6_r))); + view = new DataView(buffer6_r_pad3, 0, 7); + assertEq(view.getFloat32(3, false), NaN); + var buffer6_r_pad7 = bufferize(new Uint8Array(Array(7).concat(data6_r))); + view = new DataView(buffer6_r_pad7, 0, 11); + assertEq(view.getFloat32(7, false), NaN); + var buffer6_r_pad10 = bufferize(new Uint8Array(Array(10).concat(data6_r))); + 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 = bufferize(new Uint8Array(data7)); + view = new DataView(buffer7, 0, 8); + assertEq(view.getFloat64(0, true), 10); + var buffer7_pad3 = bufferize(new Uint8Array(Array(3).concat(data7))); + view = new DataView(buffer7_pad3, 0, 11); + assertEq(view.getFloat64(3, true), 10); + var buffer7_pad7 = bufferize(new Uint8Array(Array(7).concat(data7))); + view = new DataView(buffer7_pad7, 0, 15); + assertEq(view.getFloat64(7, true), 10); + var buffer7_pad10 = bufferize(new Uint8Array(Array(10).concat(data7))); + view = new DataView(buffer7_pad10, 0, 18); + assertEq(view.getFloat64(10, true), 10); + // Big endian. + var buffer7_r = bufferize(new Uint8Array(data7_r)); + view = new DataView(buffer7_r, 0, 8); + assertEq(view.getFloat64(0, false), 10); + var buffer7_r_pad3 = bufferize(new Uint8Array(Array(3).concat(data7_r))); + view = new DataView(buffer7_r_pad3, 0, 11); + assertEq(view.getFloat64(3, false), 10); + var buffer7_r_pad7 = bufferize(new Uint8Array(Array(7).concat(data7_r))); + view = new DataView(buffer7_r_pad7, 0, 15); + assertEq(view.getFloat64(7, false), 10); + var buffer7_r_pad10 = bufferize(new Uint8Array(Array(10).concat(data7_r))); + 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 = bufferize(new Uint8Array(data8)); + view = new DataView(buffer8, 0, 8); + assertEq(view.getFloat64(0, true), 1.23); + var buffer8_pad3 = bufferize(new Uint8Array(Array(3).concat(data8))); + view = new DataView(buffer8_pad3, 0, 11); + assertEq(view.getFloat64(3, true), 1.23); + var buffer8_pad7 = bufferize(new Uint8Array(Array(7).concat(data8))); + view = new DataView(buffer8_pad7, 0, 15); + assertEq(view.getFloat64(7, true), 1.23); + var buffer8_pad10 = bufferize(new Uint8Array(Array(10).concat(data8))); + view = new DataView(buffer8_pad10, 0, 18); + assertEq(view.getFloat64(10, true), 1.23); + // Big endian. + var buffer8_r = bufferize(new Uint8Array(data8_r)); + view = new DataView(buffer8_r, 0, 8); + assertEq(view.getFloat64(0, false), 1.23); + var buffer8_r_pad3 = bufferize(new Uint8Array(Array(3).concat(data8_r))); + view = new DataView(buffer8_r_pad3, 0, 11); + assertEq(view.getFloat64(3, false), 1.23); + var buffer8_r_pad7 = bufferize(new Uint8Array(Array(7).concat(data8_r))); + view = new DataView(buffer8_r_pad7, 0, 15); + assertEq(view.getFloat64(7, false), 1.23); + var buffer8_r_pad10 = bufferize(new Uint8Array(Array(10).concat(data8_r))); + 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 = bufferize(new Uint8Array(data9)); + view = new DataView(buffer9, 0, 8); + assertEq(view.getFloat64(0, true), -6213576.4839); + var buffer9_pad3 = bufferize(new Uint8Array(Array(3).concat(data9))); + view = new DataView(buffer9_pad3, 0, 11); + assertEq(view.getFloat64(3, true), -6213576.4839); + var buffer9_pad7 = bufferize(new Uint8Array(Array(7).concat(data9))); + view = new DataView(buffer9_pad7, 0, 15); + assertEq(view.getFloat64(7, true), -6213576.4839); + var buffer9_pad10 = bufferize(new Uint8Array(Array(10).concat(data9))); + view = new DataView(buffer9_pad10, 0, 18); + assertEq(view.getFloat64(10, true), -6213576.4839); + // Big endian. + var buffer9_r = bufferize(new Uint8Array(data9_r)); + view = new DataView(buffer9_r, 0, 8); + assertEq(view.getFloat64(0, false), -6213576.4839); + var buffer9_r_pad3 = bufferize(new Uint8Array(Array(3).concat(data9_r))); + view = new DataView(buffer9_r_pad3, 0, 11); + assertEq(view.getFloat64(3, false), -6213576.4839); + var buffer9_r_pad7 = bufferize(new Uint8Array(Array(7).concat(data9_r))); + view = new DataView(buffer9_r_pad7, 0, 15); + assertEq(view.getFloat64(7, false), -6213576.4839); + var buffer9_r_pad10 = bufferize(new Uint8Array(Array(10).concat(data9_r))); + 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 = bufferize(new Uint8Array(data10)); + view = new DataView(buffer10, 0, 8); + assertEq(view.getFloat64(0, true), NaN); + var buffer10_pad3 = bufferize(new Uint8Array(Array(3).concat(data10))); + view = new DataView(buffer10_pad3, 0, 11); + assertEq(view.getFloat64(3, true), NaN); + var buffer10_pad7 = bufferize(new Uint8Array(Array(7).concat(data10))); + view = new DataView(buffer10_pad7, 0, 15); + assertEq(view.getFloat64(7, true), NaN); + var buffer10_pad10 = bufferize(new Uint8Array(Array(10).concat(data10))); + view = new DataView(buffer10_pad10, 0, 18); + assertEq(view.getFloat64(10, true), NaN); + // Big endian. + var buffer10_r = bufferize(new Uint8Array(data10_r)); + view = new DataView(buffer10_r, 0, 8); + assertEq(view.getFloat64(0, false), NaN); + var buffer10_r_pad3 = bufferize(new Uint8Array(Array(3).concat(data10_r))); + view = new DataView(buffer10_r_pad3, 0, 11); + assertEq(view.getFloat64(3, false), NaN); + var buffer10_r_pad7 = bufferize(new Uint8Array(Array(7).concat(data10_r))); + view = new DataView(buffer10_r_pad7, 0, 15); + assertEq(view.getFloat64(7, false), NaN); + var buffer10_r_pad10 = bufferize(new Uint8Array(Array(10).concat(data10_r))); + 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 = bufferize(new Uint8Array(data11)); + view = new DataView(buffer11, 0, 8); + assertEq(view.getFloat64(0, true), NaN); + var buffer11_pad3 = bufferize(new Uint8Array(Array(3).concat(data11))); + view = new DataView(buffer11_pad3, 0, 11); + assertEq(view.getFloat64(3, true), NaN); + var buffer11_pad7 = bufferize(new Uint8Array(Array(7).concat(data11))); + view = new DataView(buffer11_pad7, 0, 15); + assertEq(view.getFloat64(7, true), NaN); + var buffer11_pad10 = bufferize(new Uint8Array(Array(10).concat(data11))); + view = new DataView(buffer11_pad10, 0, 18); + assertEq(view.getFloat64(10, true), NaN); + // Big endian. + var buffer11_r = bufferize(new Uint8Array(data11_r)); + view = new DataView(buffer11_r, 0, 8); + assertEq(view.getFloat64(0, false), NaN); + var buffer11_r_pad3 = bufferize(new Uint8Array(Array(3).concat(data11_r))); + view = new DataView(buffer11_r_pad3, 0, 11); + assertEq(view.getFloat64(3, false), NaN); + var buffer11_r_pad7 = bufferize(new Uint8Array(Array(7).concat(data11_r))); + view = new DataView(buffer11_r_pad7, 0, 15); + assertEq(view.getFloat64(7, false), NaN); + var buffer11_r_pad10 = bufferize(new Uint8Array(Array(10).concat(data11_r))); + 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 = bufferize(new Uint8Array(data12)); + 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 = bufferize(new Uint8Array(data13)); + 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 = bufferize(new Uint8Array(Array(3).concat(data13))); + view = new DataView(buffer13_pad3, 0, 19); + view.setFloat32(3, 10, true); + assertEq(view.getFloat32(3, true), 10); + var buffer13_pad7 = bufferize(new Uint8Array(Array(7).concat(data13))); + view = new DataView(buffer13_pad7, 0, 23); + view.setFloat32(7, 10, true); + assertEq(view.getFloat32(7, true), 10); + var buffer13_pad10 = bufferize(new Uint8Array(Array(10).concat(data13))); + view = new DataView(buffer13_pad10, 0, 26); + view.setFloat32(10, 10, true); + assertEq(view.getFloat32(10, true), 10); + // Big endian. + var buffer13_r = bufferize(new Uint8Array(data13_r)); + view = new DataView(buffer13_r, 0, 16); + view.setFloat32(0, 10, false); + assertEq(view.getFloat32(0, false), 10); + var buffer13_r_pad3 = bufferize(new Uint8Array(Array(3).concat(data13_r))); + view = new DataView(buffer13_r_pad3, 0, 19); + view.setFloat32(3, 10, false); + assertEq(view.getFloat32(3, false), 10); + var buffer13_r_pad7 = bufferize(new Uint8Array(Array(7).concat(data13_r))); + view = new DataView(buffer13_r_pad7, 0, 23); + view.setFloat32(7, 10, false); + assertEq(view.getFloat32(7, false), 10); + var buffer13_r_pad10 = bufferize(new Uint8Array(Array(10).concat(data13_r))); + 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(bufferize(new Uint8Array(intArray1)), 0); + assertEq(view.getUint32(0, false), 0x00010203); + view = new DataView(bufferize(new Uint8Array(intArray1)), 1); + assertEq(view.getUint32(0, false), 0x01020364); + view = new DataView(bufferize(new Uint8Array(intArray1)), 2); + assertEq(view.getUint32(0, false), 0x02036465); + view = new DataView(bufferize(new Uint8Array(intArray1)), 3); + assertEq(view.getUint32(0, false), 0x03646566); + view = new DataView(bufferize(new Uint8Array(intArray1)), 4); + assertEq(view.getUint32(0, false), 0x64656667); + view = new DataView(bufferize(new Uint8Array(intArray1)), 5); + assertEq(view.getUint32(0, false), 0x65666780); + view = new DataView(bufferize(new Uint8Array(intArray1)), 6); + assertEq(view.getUint32(0, false), 0x66678081); + view = new DataView(bufferize(new Uint8Array(intArray1)), 7); + assertEq(view.getUint32(0, false), 0x67808182); + + // Test for indexing into a DataView, which should not use the ArrayBuffer storage + view = new DataView(bufferize(new Uint8Array([1, 2]))); + 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]"); + + // get %TypedArray%.prototype[@@toStringTag] returns undefined thus + // Object.prototype.toString falls back to [object Object] + assertEq(Object.prototype.toString.apply(Uint8Array.prototype), "[object Object]"); + assertEq(Object.prototype.toString.apply(Float32Array.prototype), "[object Object]"); + var typedArrayPrototype = Object.getPrototypeOf(Float32Array.prototype); + assertEq(Object.prototype.toString.apply(typedArrayPrototype), "[object Object]"); + + // 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 = ' + JSON.stringify(data1)); + var alien_buffer = alien.eval(`buffer = new ${sharedMem ? 'Shared' : ''}ArrayBuffer(data.length)`); + alien.eval('new Uint8Array(buffer).set(data)'); + 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(); + + // Bug 1438569. + dv = new DataView(new ArrayBuffer(20 * 1024 * 1024)); + dv.setInt8(dv.byteLength - 10, 99); + assertEq(dv.getInt8(dv.byteLength - 10), 99); + + reportCompare(0, 0, 'done.'); +} + +test(false); + +if (this.SharedArrayBuffer) + test(true); diff --git a/js/src/tests/non262/extensions/decompile-for-of.js b/js/src/tests/non262/extensions/decompile-for-of.js new file mode 100644 index 0000000000..b99e20a40b --- /dev/null +++ b/js/src/tests/non262/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/non262/extensions/destructure-accessor.js b/js/src/tests/non262/extensions/destructure-accessor.js new file mode 100644 index 0000000000..e8c57bb93c --- /dev/null +++ b/js/src/tests/non262/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/non262/extensions/destructuring-__proto__-shorthand-assignment-before-var.js b/js/src/tests/non262/extensions/destructuring-__proto__-shorthand-assignment-before-var.js new file mode 100644 index 0000000000..da0da55c8a --- /dev/null +++ b/js/src/tests/non262/extensions/destructuring-__proto__-shorthand-assignment-before-var.js @@ -0,0 +1,49 @@ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +var gTestfile = 'destructuring-__proto__-shorthand-assignment-before-var.js'; +var BUGNUMBER = 963641; +var summary = "{ __proto__ } should work as a destructuring assignment pattern"; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +function objectWithProtoProperty(v) +{ + var obj = {}; + return Object.defineProperty(obj, "__proto__", + { + enumerable: true, + configurable: true, + writable: true, + value: v + }); +} + +({ __proto__ } = objectWithProtoProperty(17)); +assertEq(__proto__, 17); + +var { __proto__ } = objectWithProtoProperty(42); +assertEq(__proto__, 42); + +function nested() +{ + ({ __proto__ } = objectWithProtoProperty(undefined)); + assertEq(__proto__, undefined); + + var { __proto__ } = objectWithProtoProperty("fnord"); + assertEq(__proto__, "fnord"); +} +nested(); + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete"); diff --git a/js/src/tests/non262/extensions/destructuring-__proto__-shorthand-assignment.js b/js/src/tests/non262/extensions/destructuring-__proto__-shorthand-assignment.js new file mode 100644 index 0000000000..0ab26465f5 --- /dev/null +++ b/js/src/tests/non262/extensions/destructuring-__proto__-shorthand-assignment.js @@ -0,0 +1,49 @@ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +var gTestfile = 'destructuring-__proto__-shorthand-assignment.js'; +var BUGNUMBER = 963641; +var summary = "{ __proto__ } should work as a destructuring assignment pattern"; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +function objectWithProtoProperty(v) +{ + var obj = {}; + return Object.defineProperty(obj, "__proto__", + { + enumerable: true, + configurable: true, + writable: true, + value: v + }); +} + +var { __proto__ } = objectWithProtoProperty(42); +assertEq(__proto__, 42); + +({ __proto__ } = objectWithProtoProperty(17)); +assertEq(__proto__, 17); + +function nested() +{ + var { __proto__ } = objectWithProtoProperty("fnord"); + assertEq(__proto__, "fnord"); + + ({ __proto__ } = objectWithProtoProperty(undefined)); + assertEq(__proto__, undefined); +} +nested(); + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete"); diff --git a/js/src/tests/non262/extensions/destructuring-__proto__-target-assignment.js b/js/src/tests/non262/extensions/destructuring-__proto__-target-assignment.js new file mode 100644 index 0000000000..9e8ec72179 --- /dev/null +++ b/js/src/tests/non262/extensions/destructuring-__proto__-target-assignment.js @@ -0,0 +1,50 @@ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +var gTestfile = 'destructuring-__proto__-target--assignment.js'; +var BUGNUMBER = 963641; +var summary = + "{ __proto__: target } should work as a destructuring assignment pattern"; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +function objectWithProtoProperty(v) +{ + var obj = {}; + return Object.defineProperty(obj, "__proto__", + { + enumerable: true, + configurable: true, + writable: true, + value: v + }); +} + +var { __proto__: target } = objectWithProtoProperty(null); +assertEq(target, null); + +({ __proto__: target } = objectWithProtoProperty("aacchhorrt")); +assertEq(target, "aacchhorrt"); + +function nested() +{ + var { __proto__: target } = objectWithProtoProperty(3.141592654); + assertEq(target, 3.141592654); + + ({ __proto__: target } = objectWithProtoProperty(-0)); + assertEq(target, -0); +} +nested(); + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete"); diff --git a/js/src/tests/non262/extensions/destructuring-for-inof-__proto__.js b/js/src/tests/non262/extensions/destructuring-for-inof-__proto__.js new file mode 100644 index 0000000000..283dee3147 --- /dev/null +++ b/js/src/tests/non262/extensions/destructuring-for-inof-__proto__.js @@ -0,0 +1,85 @@ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +var gTestfile = 'destructuring-for-inof-__proto__.js'; +var BUGNUMBER = 963641; +var summary = + "__proto__ should work in destructuring patterns as the targets of " + + "for-in/for-of loops"; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +function objectWithProtoProperty(v) +{ + var obj = {}; + return Object.defineProperty(obj, "__proto__", + { + enumerable: true, + configurable: true, + writable: true, + value: v + }); +} + +function* objectWithProtoGenerator(v) +{ + yield objectWithProtoProperty(v); +} + +function* identityGenerator(v) +{ + yield v; +} + +for (var { __proto__: target } of objectWithProtoGenerator(null)) + assertEq(target, null); + +for ({ __proto__: target } of objectWithProtoGenerator("aacchhorrt")) + assertEq(target, "aacchhorrt"); + +for ({ __proto__: target } of identityGenerator(42)) + assertEq(target, Number.prototype); + +for (var { __proto__: target } in { prop: "kneedle" }) + assertEq(target, String.prototype); + +for ({ __proto__: target } in { prop: "snork" }) + assertEq(target, String.prototype); + +for ({ __proto__: target } in { prop: "ohia" }) + assertEq(target, String.prototype); + +function nested() +{ + for (var { __proto__: target } of objectWithProtoGenerator(null)) + assertEq(target, null); + + for ({ __proto__: target } of objectWithProtoGenerator("aacchhorrt")) + assertEq(target, "aacchhorrt"); + + for ({ __proto__: target } of identityGenerator(42)) + assertEq(target, Number.prototype); + + for (var { __proto__: target } in { prop: "kneedle" }) + assertEq(target, String.prototype); + + for ({ __proto__: target } in { prop: "snork" }) + assertEq(target, String.prototype); + + for ({ __proto__: target } in { prop: "ohia" }) + assertEq(target, String.prototype); +} +nested(); + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete"); diff --git a/js/src/tests/non262/extensions/destructuring-order.js b/js/src/tests/non262/extensions/destructuring-order.js new file mode 100644 index 0000000000..b1567e6a07 --- /dev/null +++ b/js/src/tests/non262/extensions/destructuring-order.js @@ -0,0 +1,150 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var summary = "Order of destructuring, destructuring in the presence of " + + "exceptions"; +var actual, expect; + +printStatus(summary); + +/************** + * BEGIN TEST * + **************/ + +var failed = false; + + +var a = "FAILED", b = "PASSED"; + +function exceptObj() +{ + return { get b() { throw "PASSED"; }, a: "PASSED" }; +} + +function partialEvalObj() +{ + try + { + ({a:a, b:b} = exceptObj()); + throw "FAILED"; + } + catch (ex) + { + if (ex !== "PASSED") + throw "bad exception thrown: " + ex; + } +} + + +var c = "FAILED", d = "FAILED", e = "PASSED", f = "PASSED"; + +function exceptArr() +{ + return ["PASSED", {e: "PASSED", get f() { throw "PASSED"; }}, "FAILED"]; +} + +function partialEvalArr() +{ + try + { + [c, {e: d, f: e}, f] = exceptArr(); + throw "FAILED"; + } + catch (ex) + { + if (ex !== "PASSED") + throw "bad exception thrown: " + ex; + } +} + + +var g = "FAILED", h = "FAILED", i = "FAILED", j = "FAILED", k = "FAILED"; +var _g = "PASSED", _h = "FAILED", _i = "FAILED", _j = "FAILED", _k = "FAILED"; +var order = []; + +function objWithGetters() +{ + return { + get j() + { + var rv = _j; + _g = _h = _i = _j = "FAILED"; + _k = "PASSED"; + order.push("j"); + return rv; + }, + get g() + { + var rv = _g; + _g = _i = _j = _k = "FAILED"; + _h = "PASSED"; + order.push("g"); + return rv; + }, + get i() + { + var rv = _i; + _g = _h = _i = _k = "FAILED"; + _j = "PASSED"; + order.push("i"); + return rv; + }, + get k() + { + var rv = _k; + _g = _h = _i = _j = _k = "FAILED"; + order.push("k"); + return rv; + }, + get h() + { + var rv = _h; + _g = _h = _j = _k = "FAILED"; + _i = "PASSED"; + order.push("h"); + return rv; + } + }; +} + +function partialEvalObj2() +{ + ({g: g, h: h, i: i, j: j, k: k} = objWithGetters()); +} + +try +{ + partialEvalObj(); + if (a !== "PASSED" || b !== "PASSED") + throw "FAILED: lhs not mutated correctly during destructuring!\n" + + "a == " + a + ", b == " + b; + + partialEvalObj2(); + if (g !== "PASSED" || + h !== "PASSED" || + i !== "PASSED" || + j !== "PASSED" || + k !== "PASSED") + throw "FAILED: order of property accesses wrong!\n" + + "order == " + order; + + partialEvalArr(); + if (c !== "PASSED" || d !== "PASSED" || e !== "PASSED") + throw "FAILED: lhs not mutated correctly during destructuring!\n" + + "c == " + c + + ", d == " + d + + ", e == " + e + + ", f == " + f ; +} +catch (ex) +{ + failed = ex; +} + +expect = false; +actual = failed; + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/non262/extensions/element-setting-ToNumber-detaches.js b/js/src/tests/non262/extensions/element-setting-ToNumber-detaches.js new file mode 100644 index 0000000000..0d4b6f9c33 --- /dev/null +++ b/js/src/tests/non262/extensions/element-setting-ToNumber-detaches.js @@ -0,0 +1,35 @@ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ +"use strict"; // make test fail when limitation below is fixed + +var gTestfile = 'element-setting-ToNumber-detaches.js'; +//----------------------------------------------------------------------------- +var BUGNUMBER = 1001547; +var summary = + "Don't assert assigning into memory detached while converting the value to " + + "assign into a number"; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +// Technically per current spec the element-sets should throw in strict mode, +// but we just silently do nothing for now, somewhat due to limitations of our +// internal MOP (which can't easily say "try this special behavior, else fall +// back on normal logic"), somewhat because it's consistent with current +// behavior (as of this test's addition) for out-of-bounds sets. + +var ab = new ArrayBuffer(64); +var ta = new Uint32Array(ab); +ta[4] = { valueOf() { detachArrayBuffer(ab); return 5; } }; + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete"); diff --git a/js/src/tests/non262/extensions/empty.txt b/js/src/tests/non262/extensions/empty.txt new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/non262/extensions/empty.txt diff --git a/js/src/tests/non262/extensions/error-tostring-function.js b/js/src/tests/non262/extensions/error-tostring-function.js new file mode 100644 index 0000000000..86751c39d8 --- /dev/null +++ b/js/src/tests/non262/extensions/error-tostring-function.js @@ -0,0 +1,45 @@ +// Any copyright is dedicated to the Public Domain. +// http://creativecommons.org/licenses/publicdomain/ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 894653; +var summary = + "Error.prototype.toString called on function objects should work as on any " + + "object"; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +function ErrorToString(v) +{ + return Error.prototype.toString.call(v); +} + +// The name property of function objects isn't standardized, so this must be an +// extension-land test. + +assertEq(ErrorToString(function f(){}), "f"); +assertEq(ErrorToString(function g(){}), "g"); +assertEq(ErrorToString(function(){}), ""); + +var fn1 = function() {}; +fn1.message = "ohai"; +assertEq(ErrorToString(fn1), "fn1: ohai"); + +var fn2 = function blerch() {}; +fn2.message = "fnord"; +assertEq(ErrorToString(fn2), "blerch: fnord"); + +var fn3 = function() {}; +fn3.message = ""; +assertEq(ErrorToString(fn3), "fn3"); + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete!"); diff --git a/js/src/tests/non262/extensions/errorcolumnblame.js b/js/src/tests/non262/extensions/errorcolumnblame.js new file mode 100644 index 0000000000..80c776520c --- /dev/null +++ b/js/src/tests/non262/extensions/errorcolumnblame.js @@ -0,0 +1,79 @@ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +var BUGNUMBER = 568142; +var summary = 'error reporting blames column as well as line'; + +function test(f, col) { + var caught = false; + try { + f(); + } catch (e) { + caught = true; + assertEq(e.columnNumber, col); + } + assertEq(caught, true); +} + +/* Note single hard tab before return! */ +function foo(o) { + return o.p; +} +test(foo, 2); + +//345678901234567890 +test(function(f) { return f.bar; }, 20); +// 1 2 +//3456789012345678901234567 +test(function(f) { return f(); }, 27); +/* Cover negative colspan case using for(;;) loop with error in update part. */ +test(function(){ + // 1 2 3 4 + //123456789012345678901234567890123456789012 + eval("function baz() { for (var i = 0; i < 10; i += a.b); assertEq(i !== i, true); }"); + baz(); +}, 42); + +// 1 2 3 +//3456789012345678901234567890123456 +test(function() { var tmp = null; tmp(); }, 35) +test(function() { var tmp = null; tmp.foo; }, 36) + +/* Just a generic 'throw'. */ +test(function() { +// 1 2 +//345678901234567890 + foo({}); throw new Error('a'); +}, 20); + +/* Be sure to report the right statement */ +test(function() { + function f() { return true; } + function g() { return false; } +// 1 2 +//345678901234567890123456789 + f(); g(); f(); if (f()) a += e; +}, 29); + +// 1 2 +//345678901234567890 +test(function() { e++; }, 19); +test(function() {print += e; }, 18); +test(function(){e += 1 }, 17); +test(function() { print[e]; }, 20); +test(function() { e[1]; }, 19); +test(function() { e(); }, 19); +test(function() { 1(); }, 20); +test(function() { Object.defineProperty() }, 26); + +test(function() { +// 1 2 +//34567890123456789012 + function foo() { asdf; } foo() +}, 22); + +reportCompare(0, 0, "ok"); + +printStatus("All tests passed!"); diff --git a/js/src/tests/non262/extensions/es5ish-defineGetter-defineSetter.js b/js/src/tests/non262/extensions/es5ish-defineGetter-defineSetter.js new file mode 100644 index 0000000000..681a157a8b --- /dev/null +++ b/js/src/tests/non262/extensions/es5ish-defineGetter-defineSetter.js @@ -0,0 +1,281 @@ +// Any copyright is dedicated to the Public Domain. +// http://creativecommons.org/licenses/publicdomain/ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 715821; +var summary = "Implement __define[GS]etter__ using Object.defineProperty"; + +print(BUGNUMBER + ": " + summary); + +/************* + * UTILITIES * + *************/ + +function s(desc) +{ + if (typeof desc === "undefined") + return "<undefined>"; + assertEq(typeof desc, "object"); + assertEq(desc !== null, true); + + var str = "<enumerable: <" + desc.enumerable + ">, " + + " configurable: <" + desc.configurable + ">,"; + + if (desc.hasOwnProperty("value")) + { + return str + + " value: <" + desc.value + ">," + + " writable: <" + desc.writable + ">>"; + } + + return str + + " get: <" + desc.get + ">," + + " set: <" + desc.set + ">>"; +} + +function checkField(field, desc, expected) +{ + var present = desc.hasOwnProperty(field); + assertEq(present, expected.hasOwnProperty(field), + field + " presence mismatch (got " + s(desc) + ", expected " + s(expected) + ")"); + if (present) + { + assertEq(desc[field], expected[field], + field + " value mismatch (got " + s(desc) + ", expected " + s(expected) + ")"); + } +} + +function check(obj, prop, expected) +{ + var desc = Object.getOwnPropertyDescriptor(obj, prop); + assertEq(typeof desc, typeof expected, + "type mismatch (got " + s(desc) + ", expected " + s(expected) + ")"); + + assertEq(desc.hasOwnProperty("get"), desc.hasOwnProperty("set"), + "bad descriptor: " + s(desc)); + assertEq(desc.hasOwnProperty("value"), desc.hasOwnProperty("writable"), + "bad descriptor: " + s(desc)); + + assertEq(desc.hasOwnProperty("get"), !desc.hasOwnProperty("value"), + "bad descriptor: " + s(desc)); + + checkField("get", desc, expected); + checkField("set", desc, expected); + checkField("value", desc, expected); + checkField("writable", desc, expected); + checkField("enumerable", desc, expected); + checkField("configurable", desc, expected); +} + +function expectTypeError(f) +{ + try + { + f(); + throw new Error("no error thrown"); + } + catch (e) + { + assertEq(e instanceof TypeError, true, + "wrong error thrown: got " + e + ", not a TypeError"); + } +} + +/************** + * BEGIN TEST * + **************/ + +// Adding a new getter, overwriting an existing one + +function g1() { } +var gobj = {}; +gobj.__defineGetter__("foo", g1); +check(gobj, "foo", { get: g1, set: undefined, enumerable: true, configurable: true }); + +function g2() { } +gobj.__defineGetter__("foo", g2); +check(gobj, "foo", { get: g2, set: undefined, enumerable: true, configurable: true }); + +/******************************************************************************/ + +// Adding a new setter, overwriting an existing one + +function s1() { } +var sobj = {}; +sobj.__defineSetter__("bar", s1); +check(sobj, "bar", { get: undefined, set: s1, enumerable: true, configurable: true }); + +function s2() { } +sobj.__defineSetter__("bar", s2); +check(sobj, "bar", { get: undefined, set: s2, enumerable: true, configurable: true }); + +/******************************************************************************/ + +// Adding a new getter, then adding a setter +// Changing an existing accessor's enumerability, then "null"-changing the accessor +// Changing an accessor's configurability, then "null"-changing and real-changing the accessor + +function g3() { } +var gsobj = {}; +gsobj.__defineGetter__("baz", g3); +check(gsobj, "baz", { get: g3, set: undefined, enumerable: true, configurable: true }); + +function s3() { } +gsobj.__defineSetter__("baz", s3); +check(gsobj, "baz", { get: g3, set: s3, enumerable: true, configurable: true }); + +Object.defineProperty(gsobj, "baz", { enumerable: false }); +check(gsobj, "baz", { get: g3, set: s3, enumerable: false, configurable: true }); + +gsobj.__defineGetter__("baz", g3); +check(gsobj, "baz", { get: g3, set: s3, enumerable: true, configurable: true }); + +Object.defineProperty(gsobj, "baz", { enumerable: false }); +check(gsobj, "baz", { get: g3, set: s3, enumerable: false, configurable: true }); + +gsobj.__defineSetter__("baz", s3); +check(gsobj, "baz", { get: g3, set: s3, enumerable: true, configurable: true }); + +Object.defineProperty(gsobj, "baz", { configurable: false }); +expectTypeError(function() { gsobj.__defineSetter__("baz", s2); }); +expectTypeError(function() { gsobj.__defineSetter__("baz", s3); }); +check(gsobj, "baz", { get: g3, set: s3, enumerable: true, configurable: false }); + +/******************************************************************************/ + +// Adding a new setter, then adding a getter +// Changing an existing accessor's enumerability, then "null"-changing the accessor +// Changing an accessor's configurability, then "null"-changing and real-changing the accessor + +function s4() { } +var sgobj = {}; +sgobj.__defineSetter__("baz", s4); +check(sgobj, "baz", { get: undefined, set: s4, enumerable: true, configurable: true }); + +function g4() { } +sgobj.__defineGetter__("baz", g4); +check(sgobj, "baz", { get: g4, set: s4, enumerable: true, configurable: true }); + +Object.defineProperty(sgobj, "baz", { enumerable: false }); +check(sgobj, "baz", { get: g4, set: s4, enumerable: false, configurable: true }); + +sgobj.__defineSetter__("baz", s4); +check(sgobj, "baz", { get: g4, set: s4, enumerable: true, configurable: true }); + +Object.defineProperty(sgobj, "baz", { enumerable: false }); +check(sgobj, "baz", { get: g4, set: s4, enumerable: false, configurable: true }); + +sgobj.__defineSetter__("baz", s4); +check(sgobj, "baz", { get: g4, set: s4, enumerable: true, configurable: true }); + +Object.defineProperty(sgobj, "baz", { configurable: false }); +expectTypeError(function() { sgobj.__defineGetter__("baz", g3); }); +expectTypeError(function() { sgobj.__defineSetter__("baz", s4); }); +check(sgobj, "baz", { get: g4, set: s4, enumerable: true, configurable: false }); + +/******************************************************************************/ + +// Adding a getter over a writable data property + +function g5() { } +var gover = { quux: 17 }; +check(gover, "quux", { value: 17, writable: true, enumerable: true, configurable: true }); + +gover.__defineGetter__("quux", g5); +check(gover, "quux", { get: g5, set: undefined, enumerable: true, configurable: true }); + +/******************************************************************************/ + +// Adding a setter over a writable data property + +function s5() { } +var sover = { quux: 17 }; +check(sover, "quux", { value: 17, writable: true, enumerable: true, configurable: true }); + +sover.__defineSetter__("quux", s5); +check(sover, "quux", { get: undefined, set: s5, enumerable: true, configurable: true }); + +/******************************************************************************/ + +// Adding a getter over a non-writable data property + +function g6() { } +var gnover = { eit: 17 }; +check(gnover, "eit", { value: 17, writable: true, enumerable: true, configurable: true }); +Object.defineProperty(gnover, "eit", { writable: false }); +check(gnover, "eit", { value: 17, writable: false, enumerable: true, configurable: true }); + +gnover.__defineGetter__("eit", g6); +check(gnover, "eit", { get: g6, set: undefined, enumerable: true, configurable: true }); + +/******************************************************************************/ + +// Adding a setter over a non-writable data property + +function s6() { } +var snover = { eit: 17 }; +check(snover, "eit", { value: 17, writable: true, enumerable: true, configurable: true }); +Object.defineProperty(snover, "eit", { writable: false }); +check(snover, "eit", { value: 17, writable: false, enumerable: true, configurable: true }); + +snover.__defineSetter__("eit", s6); +check(snover, "eit", { get: undefined, set: s6, enumerable: true, configurable: true }); + +/******************************************************************************/ + +// Adding a getter over a non-configurable, writable data property + +function g7() { } +var gncover = { moo: 17 }; +check(gncover, "moo", { value: 17, writable: true, enumerable: true, configurable: true }); +Object.defineProperty(gncover, "moo", { configurable: false }); +check(gncover, "moo", { value: 17, writable: true, enumerable: true, configurable: false }); + +expectTypeError(function() { gncover.__defineGetter__("moo", g7); }); +check(gncover, "moo", { value: 17, writable: true, enumerable: true, configurable: false }); + +/******************************************************************************/ + +// Adding a setter over a non-configurable, writable data property + +function s7() { } +var sncover = { moo: 17 }; +check(sncover, "moo", { value: 17, writable: true, enumerable: true, configurable: true }); +Object.defineProperty(sncover, "moo", { configurable: false }); +check(sncover, "moo", { value: 17, writable: true, enumerable: true, configurable: false }); + +expectTypeError(function() { sncover.__defineSetter__("moo", s7); }); +check(sncover, "moo", { value: 17, writable: true, enumerable: true, configurable: false }); + +/******************************************************************************/ + +// Adding a getter over a non-configurable, non-writable data property + +function g8() { } +var gncwover = { fwoosh: 17 }; +check(gncwover, "fwoosh", { value: 17, writable: true, enumerable: true, configurable: true }); +Object.defineProperty(gncwover, "fwoosh", { writable: false, configurable: false }); +check(gncwover, "fwoosh", { value: 17, writable: false, enumerable: true, configurable: false }); + +expectTypeError(function() { gncwover.__defineGetter__("fwoosh", g7); }); +check(gncwover, "fwoosh", { value: 17, writable: false, enumerable: true, configurable: false }); + +/******************************************************************************/ + +// Adding a setter over a non-configurable, non-writable data property + +function s8() { } +var sncwover = { fwoosh: 17 }; +check(sncwover, "fwoosh", { value: 17, writable: true, enumerable: true, configurable: true }); +Object.defineProperty(sncwover, "fwoosh", { writable: false, configurable: false }); +check(sncwover, "fwoosh", { value: 17, writable: false, enumerable: true, configurable: false }); + +expectTypeError(function() { sncwover.__defineSetter__("fwoosh", s7); }); +check(sncwover, "fwoosh", { value: 17, writable: false, enumerable: true, configurable: false }); + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete"); diff --git a/js/src/tests/non262/extensions/eval-native-callback-is-indirect.js b/js/src/tests/non262/extensions/eval-native-callback-is-indirect.js new file mode 100644 index 0000000000..017ccf1c74 --- /dev/null +++ b/js/src/tests/non262/extensions/eval-native-callback-is-indirect.js @@ -0,0 +1,33 @@ +// Any copyright is dedicated to the Public Domain. +// http://creativecommons.org/licenses/publicdomain/ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 604504; +var summary = "eval called from a native function is indirect"; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +var originalEval = eval; + +var global = this; +var directCheckCode = "this === global"; + +function testArrayGeneric() +{ + var global = "psych!"; + var eval = Array.map; + + var mapped = eval([directCheckCode], originalEval); + assertEq(mapped[0], true); +} + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("All tests passed!"); diff --git a/js/src/tests/non262/extensions/expression-closure-syntax.js b/js/src/tests/non262/extensions/expression-closure-syntax.js new file mode 100644 index 0000000000..84b3cc8fe9 --- /dev/null +++ b/js/src/tests/non262/extensions/expression-closure-syntax.js @@ -0,0 +1,62 @@ +// Any copyright is dedicated to the Public Domain. +// http://creativecommons.org/licenses/publicdomain/ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 1416337; +var summary = + "Expression closure syntax is only permitted for functions that constitute " + + "entire AssignmentExpressions, not PrimaryExpressions that are themselves " + + "components of larger binary expressions"; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +{ + function assertThrowsSyntaxError(code) + { + function testOne(replacement) + { + var x, rv; + try + { + rv = eval(code.replace("@@@", replacement)); + } + catch (e) + { + assertEq(e instanceof SyntaxError, true, + "should have thrown a SyntaxError, instead got: " + e); + return; + } + + assertEq(true, false, "should have thrown, instead returned " + rv); + } + + testOne("function"); + testOne("async function"); + } + + assertThrowsSyntaxError("x = ++@@@() 1"); + assertThrowsSyntaxError("x = delete @@@() 1"); + assertThrowsSyntaxError("x = new @@@() 1"); + assertThrowsSyntaxError("x = void @@@() 1"); + assertThrowsSyntaxError("x = +@@@() 1"); + assertThrowsSyntaxError("x = 1 + @@@() 1"); + assertThrowsSyntaxError("x = null != @@@() 1"); + assertThrowsSyntaxError("x = null != @@@() 0 ? 1 : a => {}"); + assertThrowsSyntaxError("x = @@@() 0 ? 1 : a => {} !== null"); + assertThrowsSyntaxError("x = @@@() 0 ? 1 : a => {}.toString"); + assertThrowsSyntaxError("x = @@@() 0 ? 1 : a => {}['toString']"); + assertThrowsSyntaxError("x = @@@() 0 ? 1 : a => {}``"); + assertThrowsSyntaxError("x = @@@() 0 ? 1 : a => {}()"); + assertThrowsSyntaxError("x = @@@() 0 ? 1 : a => {}++"); + assertThrowsSyntaxError("x = @@@() 0 ? 1 : a => {} || 0"); + assertThrowsSyntaxError("x = 0 || @@@() 0 ? 1 : a => {}"); + assertThrowsSyntaxError("x = @@@() 0 ? 1 : a => {} && true"); + assertThrowsSyntaxError("x = true && @@@() 0 ? 1 : a => {}"); +} + +if (typeof reportCompare === "function") + reportCompare(true, true); diff --git a/js/src/tests/non262/extensions/extension-methods-reject-null-undefined-this.js b/js/src/tests/non262/extensions/extension-methods-reject-null-undefined-this.js new file mode 100644 index 0000000000..96689b0152 --- /dev/null +++ b/js/src/tests/non262/extensions/extension-methods-reject-null-undefined-this.js @@ -0,0 +1,105 @@ +// |reftest| skip-if(!Object.prototype.toSource) + +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 619283; +var summary = + "ECMAScript built-in methods that immediately throw when |this| is " + + "|undefined| or |null| (due to CheckObjectCoercible, ToObject, or ToString)"; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +// This test fills out for the non-standard methods which +// non262/misc/builtin-methods-reject-null-undefined-this.js declines to test. + +var ClassToMethodMap = + { + Object: ["toSource"], + Function: ["toSource"], + Array: ["toSource"], + String: ["toSource"], + Boolean: ["toSource"], + Number: ["toSource"], + Date: ["toSource"], + RegExp: ["toSource"], + Error: ["toSource"], + }; + +var badThisValues = [null, undefined]; + +function testMethod(Class, className, method) +{ + var expr; + + // Try out explicit this values + for (var i = 0, sz = badThisValues.length; i < sz; i++) + { + var badThis = badThisValues[i]; + + expr = className + ".prototype." + method + ".call(" + badThis + ")"; + try + { + Class.prototype[method].call(badThis); + throw new Error(expr + " didn't throw a TypeError"); + } + catch (e) + { + assertEq(e instanceof TypeError, true, + "wrong error for " + expr + ", instead threw " + e); + } + + expr = className + ".prototype." + method + ".apply(" + badThis + ")"; + try + { + Class.prototype[method].apply(badThis); + throw new Error(expr + " didn't throw a TypeError"); + } + catch (e) + { + assertEq(e instanceof TypeError, true, + "wrong error for " + expr + ", instead threw " + e); + } + } + + // ..and for good measure.. + + expr = "(0, " + className + ".prototype." + method + ")()" + try + { + // comma operator to call GetValue() on the method and de-Reference it + (0, Class.prototype[method])(); + throw new Error(expr + " didn't throw a TypeError"); + } + catch (e) + { + assertEq(e instanceof TypeError, true, + "wrong error for " + expr + ", instead threw " + e); + } +} + +for (var className in ClassToMethodMap) +{ + var Class = this[className]; + + var methodNames = ClassToMethodMap[className]; + for (var i = 0, sz = methodNames.length; i < sz; i++) + { + var method = methodNames[i]; + testMethod(Class, className, method); + } +} + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("All tests passed!"); diff --git a/js/src/tests/non262/extensions/file-mapped-arraybuffers.js b/js/src/tests/non262/extensions/file-mapped-arraybuffers.js new file mode 100644 index 0000000000..d69161554f --- /dev/null +++ b/js/src/tests/non262/extensions/file-mapped-arraybuffers.js @@ -0,0 +1,48 @@ +// |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 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"); + + // Test detaching during subarray creation. + var nasty = { + valueOf: function () { + print("detaching..."); + serialize(buffer3, [buffer3]); + print("detached"); + return 3000; + } + }; + + var a = new Uint8Array(buffer3); + assertThrowsInstanceOf(() => { + var aa = a.subarray(0, nasty); + for (i = 0; i < 3000; i++) + aa[i] = 17; + }, TypeError); + + // Check that invalid sizes and offsets are caught + assertThrowsInstanceOf(() => createMappedArrayBuffer("empty.txt", 8), RangeError); + assertThrowsInstanceOf(() => createMappedArrayBuffer("empty.txt", 0, 8), Error); +} + +if (getBuildConfiguration()["mapped-array-buffer"]) + test(); +reportCompare(0, 0, 'ok'); diff --git a/js/src/tests/non262/extensions/file-mapped-arraybuffers.txt b/js/src/tests/non262/extensions/file-mapped-arraybuffers.txt new file mode 100644 index 0000000000..4289a17b8f --- /dev/null +++ b/js/src/tests/non262/extensions/file-mapped-arraybuffers.txt @@ -0,0 +1 @@ +01234567abcdefghijkl
\ No newline at end of file diff --git a/js/src/tests/non262/extensions/for-loop-with-lexical-declaration-and-nested-function-statement.js b/js/src/tests/non262/extensions/for-loop-with-lexical-declaration-and-nested-function-statement.js new file mode 100644 index 0000000000..9f6fd6467c --- /dev/null +++ b/js/src/tests/non262/extensions/for-loop-with-lexical-declaration-and-nested-function-statement.js @@ -0,0 +1,130 @@ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +var gTestfile = + "for-loop-with-lexical-declaration-and-nested-function-statement.js"; +//----------------------------------------------------------------------------- +var BUGNUMBER = 1149797; +var summary = + "Don't assert when freshening the scope chain for a for-loop whose head " + + "contains a lexical declaration, where the loop body might add more " + + "bindings at runtime"; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +for (let x = 0; x < 9; ++x) { + function q1() {} +} + +{ + for (let x = 0; x < 9; ++x) { + function q2() {} + } +} + +function f1() +{ + for (let x = 0; x < 9; ++x) { + function q3() {} + } +} +f1(); + +function f2() +{ + { + for (let x = 0; x < 9; ++x) { + function q4() {} + } + } +} +f2(); + +for (let x = 0; x < 9; ++x) +{ + // deliberately inside a block statement + function q5() {} +} + +{ + for (let x = 0; x < 9; ++x) + { + // deliberately inside a block statement + function q6() {} + } +} + +function g1() +{ + for (let x = 0; x < 9; ++x) + { + // deliberately inside a block statement + function q7() {} + } +} +g1(); + +function g2() +{ + { + for (let x = 0; x < 9; ++x) + { + // deliberately inside a block statement + function q8() {} + } + } +} +g2(); + +for (let x = 0; x < 9; ++x) { + (function() { + eval("function q9() {}"); + })(); +} + +{ + for (let x = 0; x < 9; ++x) + { + // deliberately inside a block statement + (function() { + eval("function q10() {}"); + })(); + } +} + +function h1() +{ + for (let x = 0; x < 9; ++x) + { + // deliberately inside a block statement + (function() { + eval("function q11() {}"); + })(); + } +} +h1(); + +function h2() +{ + { + for (let x = 0; x < 9; ++x) + { + // deliberately inside a block statement + (function() { eval("function q12() {}"); })(); + } + } +} +h2(); + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete"); diff --git a/js/src/tests/non262/extensions/function-caller-skips-eval-frames.js b/js/src/tests/non262/extensions/function-caller-skips-eval-frames.js new file mode 100644 index 0000000000..77eb99108a --- /dev/null +++ b/js/src/tests/non262/extensions/function-caller-skips-eval-frames.js @@ -0,0 +1,34 @@ +// Any copyright is dedicated to the Public Domain. +// http://creativecommons.org/licenses/publicdomain/ + +function innermost() { return arguments.callee.caller; } +function nest() { return eval("innermost();"); } +function nest2() { return nest(); } + +assertEq(nest2(), nest); + +var innermost = function innermost() { return arguments.callee.caller.caller; }; + +assertEq(nest2(), nest2); + +function nestTwice() { return eval("eval('innermost();');"); } +var nest = nestTwice; + +assertEq(nest2(), nest2); + +function innermostEval() { return eval("arguments.callee.caller"); } +var innermost = innermostEval; + +assertEq(nest2(), nestTwice); + +function innermostEvalTwice() { return eval('eval("arguments.callee.caller");'); } +var innermost = innermostEvalTwice; + +assertEq(nest2(), nestTwice); + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete"); diff --git a/js/src/tests/non262/extensions/function-caller-strict-cross-global.js b/js/src/tests/non262/extensions/function-caller-strict-cross-global.js new file mode 100644 index 0000000000..d76bcccda5 --- /dev/null +++ b/js/src/tests/non262/extensions/function-caller-strict-cross-global.js @@ -0,0 +1,16 @@ +// |reftest| skip-if(!xulRuntime.shell) -- needs newGlobal() +// Any copyright is dedicated to the Public Domain. +// http://creativecommons.org/licenses/publicdomain/ + +var g1 = newGlobal(); +g1.evaluate("function f() { return f.caller; }"); + +var g2 = newGlobal(); +g2.f = g1.f; + +assertEq(g2.evaluate("function g() { 'use strict'; return f(); } g()"), null); + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete"); diff --git a/js/src/tests/non262/extensions/function-definition-with.js b/js/src/tests/non262/extensions/function-definition-with.js new file mode 100644 index 0000000000..2277ad45fc --- /dev/null +++ b/js/src/tests/non262/extensions/function-definition-with.js @@ -0,0 +1,56 @@ +// |reftest| skip-if(!xulRuntime.shell) -- needs evaluate() +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 577325; +var summary = 'Implement the ES5 algorithm for processing function statements'; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +var called, obj; + +function inFile1() { return "in file"; } +called = false; +obj = { set inFile1(v) { called = true; } }; +with (obj) { + function inFile1() { return "in file in with"; }; +} +assertEq(inFile1(), "in file in with"); +assertEq("set" in Object.getOwnPropertyDescriptor(obj, "inFile1"), true); +assertEq(called, false); + +evaluate("function notInFile1() { return 'not in file'; }"); +called = false; +obj = { set notInFile1(v) { called = true; return "not in file 2"; } }; +with (obj) { + function notInFile1() { return "not in file in with"; }; +} +assertEq(notInFile1(), "not in file in with"); +assertEq("set" in Object.getOwnPropertyDescriptor(obj, "notInFile1"), true); +assertEq(called, false); + +function inFile2() { return "in file 1"; } +called = false; +obj = + Object.defineProperty({}, "inFile2", + { value: 42, configurable: false, enumerable: false }); +with (obj) { + function inFile2() { return "in file 2"; }; +} +assertEq(inFile2(), "in file 2"); +assertEq(obj.inFile2, 42); + + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("All tests passed!"); diff --git a/js/src/tests/non262/extensions/function-properties.js b/js/src/tests/non262/extensions/function-properties.js new file mode 100644 index 0000000000..9585322ef0 --- /dev/null +++ b/js/src/tests/non262/extensions/function-properties.js @@ -0,0 +1,21 @@ +// Any copyright is dedicated to the Public Domain. +// http://creativecommons.org/licenses/publicdomain/ + +function foo() +{ + assertEq(foo.arguments.length, 0); + assertEq(foo.caller, null); +} + +assertEq(foo.arguments, null); +assertEq(foo.caller, null); +foo(); +assertEq(foo.arguments, null); +assertEq(foo.caller, null); + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete"); diff --git a/js/src/tests/non262/extensions/getOwnPropertyNames-__proto__.js b/js/src/tests/non262/extensions/getOwnPropertyNames-__proto__.js new file mode 100644 index 0000000000..91ee2d2033 --- /dev/null +++ b/js/src/tests/non262/extensions/getOwnPropertyNames-__proto__.js @@ -0,0 +1,26 @@ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 837630; +var summary ='__proto__ should show up with O.getOwnPropertyNames(O.prototype)'; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +var keys = Object.getOwnPropertyNames(Object.prototype); +assertEq(keys.indexOf("__proto__") >= 0, true, + "should have gotten __proto__ as a property of Object.prototype " + + "(got these properties: " + keys + ")"); + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete"); diff --git a/js/src/tests/non262/extensions/getset-001.js b/js/src/tests/non262/extensions/getset-001.js new file mode 100644 index 0000000000..928bfd0f03 --- /dev/null +++ b/js/src/tests/non262/extensions/getset-001.js @@ -0,0 +1,49 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 4 -*- + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +function TestObject () +{ + /* A warm, dry place for properties and methods to live */ +} + +TestObject.prototype._y = "<initial y>"; + +Object.defineProperty(TestObject.prototype, "y", +{ + enumerable: true, configurable: true, + get: function get_y () + { + var rv; + if (typeof this._y == "string") + rv = "got " + this._y; + else + rv = this._y; + return rv; + }, + set: function set_y (newVal) { this._y = newVal; } +}); + + +test(new TestObject()); + +function test(t) +{ + printStatus ("Basic Getter/ Setter test"); + reportCompare ("<initial y>", t._y, "y prototype check"); + + reportCompare ("got <initial y>", t.y, "y getter, before set"); + + t.y = "new y"; + reportCompare ("got new y", t.y, "y getter, after set"); + + t.y = 2; + reportCompare (2, t.y, "y getter, after numeric set"); + + var d = new Date(); + t.y = d; + reportCompare (d, t.y, "y getter, after date set"); + +} diff --git a/js/src/tests/non262/extensions/getset-003.js b/js/src/tests/non262/extensions/getset-003.js new file mode 100644 index 0000000000..55c9c99785 --- /dev/null +++ b/js/src/tests/non262/extensions/getset-003.js @@ -0,0 +1,186 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * Date: 14 April 2001 + * + * SUMMARY: Testing obj.prop getter/setter + * Note: this is a non-ECMA extension to the language. + */ +//----------------------------------------------------------------------------- +var UBound = 0; +var BUGNUMBER = '(none)'; +var summary = 'Testing obj.prop getter/setter'; +var statprefix = 'Status: '; +var status = ''; +var statusitems = [ ]; +var actual = ''; +var actualvalues = [ ]; +var expect= ''; +var expectedvalues = [ ]; +var cnDEFAULT = 'default name'; +var cnFRED = 'Fred'; +var obj = {}; +var obj2 = {}; +var s = ''; + + +// SECTION1: define getter/setter directly on an object (not its prototype) +obj = new Object(); +obj.nameSETS = 0; +obj.nameGETS = 0; +Object.defineProperty(obj, "name", +{ + enumerable: true, configurable: true, + set: function(newValue) {this._name=newValue; this.nameSETS++;}, + get: function() {this.nameGETS++; return this._name;} +}); + + status = 'In SECTION1 of test after 0 sets, 0 gets'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [0,0]; +addThis(); + +s = obj.name; +status = 'In SECTION1 of test after 0 sets, 1 get'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [0,1]; +addThis(); + +obj.name = cnFRED; +status = 'In SECTION1 of test after 1 set, 1 get'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [1,1]; +addThis(); + +obj.name = obj.name; +status = 'In SECTION1 of test after 2 sets, 2 gets'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [2,2]; +addThis(); + + +// SECTION2: define getter/setter in Object.prototype +Object.prototype.nameSETS = 0; +Object.prototype.nameGETS = 0; +Object.defineProperty(Object.prototype, "name", +{ + enumerable: true, configurable: true, + set: function(newValue) {this._name=newValue; this.nameSETS++;}, + get: function() {this.nameGETS++; return this._name;} +}); + + obj = new Object(); +status = 'In SECTION2 of test after 0 sets, 0 gets'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [0,0]; +addThis(); + +s = obj.name; +status = 'In SECTION2 of test after 0 sets, 1 get'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [0,1]; +addThis(); + +obj.name = cnFRED; +status = 'In SECTION2 of test after 1 set, 1 get'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [1,1]; +addThis(); + +obj.name = obj.name; +status = 'In SECTION2 of test after 2 sets, 2 gets'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [2,2]; +addThis(); + + +// SECTION 3: define getter/setter in prototype of user-defined constructor +function TestObject() +{ +} +TestObject.prototype.nameSETS = 0; +TestObject.prototype.nameGETS = 0; +Object.defineProperty(TestObject.prototype, "name", +{ + enumerable: true, configurable: true, + set: function(newValue) {this._name=newValue; this.nameSETS++;}, + get: function() {this.nameGETS++; return this._name;} +}); + TestObject.prototype.name = cnDEFAULT; + +obj = new TestObject(); +status = 'In SECTION3 of test after 1 set, 0 gets'; // (we set a default value in the prototype) +actual = [obj.nameSETS,obj.nameGETS]; +expect = [1,0]; +addThis(); + +s = obj.name; +status = 'In SECTION3 of test after 1 set, 1 get'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [1,1]; +addThis(); + +obj.name = cnFRED; +status = 'In SECTION3 of test after 2 sets, 1 get'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [2,1]; +addThis(); + +obj.name = obj.name; +status = 'In SECTION3 of test after 3 sets, 2 gets'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [3,2]; +addThis(); + +obj2 = new TestObject(); +status = 'obj2 = new TestObject() after 1 set, 0 gets'; +actual = [obj2.nameSETS,obj2.nameGETS]; +expect = [1,0]; // we set a default value in the prototype - +addThis(); + +// Use both obj and obj2 - +obj2.name = obj.name + obj2.name; +status = 'obj2 = new TestObject() after 2 sets, 1 get'; +actual = [obj2.nameSETS,obj2.nameGETS]; +expect = [2,1]; +addThis(); + +status = 'In SECTION3 of test after 3 sets, 3 gets'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [3,3]; // we left off at [3,2] above - +addThis(); + + +//--------------------------------------------------------------------------------- +test(); +//--------------------------------------------------------------------------------- + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual.toString(); + expectedvalues[UBound] = expect.toString(); + UBound++; +} + + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + for (var i = 0; i < UBound; i++) + { + reportCompare(expectedvalues[i], actualvalues[i], getStatus(i)); + } +} + + +function getStatus(i) +{ + return statprefix + statusitems[i]; +} diff --git a/js/src/tests/non262/extensions/getset-004.js b/js/src/tests/non262/extensions/getset-004.js new file mode 100644 index 0000000000..e76b9263f0 --- /dev/null +++ b/js/src/tests/non262/extensions/getset-004.js @@ -0,0 +1,174 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * Date: 14 April 2001 + * + * SUMMARY: Testing obj.__defineSetter__(), obj.__defineGetter__() + * Note: this is a non-ECMA language extension + */ +//----------------------------------------------------------------------------- +var UBound = 0; +var BUGNUMBER = '(none)'; +var summary = 'Testing obj.__defineSetter__(), obj.__defineGetter__()'; +var statprefix = 'Status: '; +var status = ''; +var statusitems = [ ]; +var actual = ''; +var actualvalues = [ ]; +var expect= ''; +var expectedvalues = [ ]; +var cnDEFAULT = 'default name'; +var cnFRED = 'Fred'; +var obj = {}; +var obj2 = {}; +var s = ''; + + +// SECTION1: define getter/setter directly on an object (not its prototype) +obj = new Object(); +obj.nameSETS = 0; +obj.nameGETS = 0; +obj.__defineSetter__('name', function(newValue) {this._name=newValue; this.nameSETS++;}); +obj.__defineGetter__('name', function() {this.nameGETS++; return this._name;}); + +status = 'In SECTION1 of test after 0 sets, 0 gets'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [0,0]; +addThis(); + +s = obj.name; +status = 'In SECTION1 of test after 0 sets, 1 get'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [0,1]; +addThis(); + +obj.name = cnFRED; +status = 'In SECTION1 of test after 1 set, 1 get'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [1,1]; +addThis(); + +obj.name = obj.name; +status = 'In SECTION1 of test after 2 sets, 2 gets'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [2,2]; +addThis(); + + +// SECTION2: define getter/setter in Object.prototype +Object.prototype.nameSETS = 0; +Object.prototype.nameGETS = 0; +Object.prototype.__defineSetter__('name', function(newValue) {this._name=newValue; this.nameSETS++;}); +Object.prototype.__defineGetter__('name', function() {this.nameGETS++; return this._name;}); + +obj = new Object(); +status = 'In SECTION2 of test after 0 sets, 0 gets'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [0,0]; +addThis(); + +s = obj.name; +status = 'In SECTION2 of test after 0 sets, 1 get'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [0,1]; +addThis(); + +obj.name = cnFRED; +status = 'In SECTION2 of test after 1 set, 1 get'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [1,1]; +addThis(); + +obj.name = obj.name; +status = 'In SECTION2 of test after 2 sets, 2 gets'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [2,2]; +addThis(); + + +// SECTION 3: define getter/setter in prototype of user-defined constructor +function TestObject() +{ +} +TestObject.prototype.nameSETS = 0; +TestObject.prototype.nameGETS = 0; +TestObject.prototype.__defineSetter__('name', function(newValue) {this._name=newValue; this.nameSETS++;}); +TestObject.prototype.__defineGetter__('name', function() {this.nameGETS++; return this._name;}); +TestObject.prototype.name = cnDEFAULT; + +obj = new TestObject(); +status = 'In SECTION3 of test after 1 set, 0 gets'; // (we set a default value in the prototype) +actual = [obj.nameSETS,obj.nameGETS]; +expect = [1,0]; +addThis(); + +s = obj.name; +status = 'In SECTION3 of test after 1 set, 1 get'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [1,1]; +addThis(); + +obj.name = cnFRED; +status = 'In SECTION3 of test after 2 sets, 1 get'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [2,1]; +addThis(); + +obj.name = obj.name; +status = 'In SECTION3 of test after 3 sets, 2 gets'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [3,2]; +addThis(); + +obj2 = new TestObject(); +status = 'obj2 = new TestObject() after 1 set, 0 gets'; +actual = [obj2.nameSETS,obj2.nameGETS]; +expect = [1,0]; // we set a default value in the prototype - +addThis(); + +// Use both obj and obj2 - +obj2.name = obj.name + obj2.name; +status = 'obj2 = new TestObject() after 2 sets, 1 get'; +actual = [obj2.nameSETS,obj2.nameGETS]; +expect = [2,1]; +addThis(); + +status = 'In SECTION3 of test after 3 sets, 3 gets'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [3,3]; // we left off at [3,2] above - +addThis(); + + +//--------------------------------------------------------------------------------- +test(); +//--------------------------------------------------------------------------------- + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual.toString(); + expectedvalues[UBound] = expect.toString(); + UBound++; +} + + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + for (var i = 0; i < UBound; i++) + { + reportCompare(expectedvalues[i], actualvalues[i], getStatus(i)); + } +} + + +function getStatus(i) +{ + return statprefix + statusitems[i]; +} diff --git a/js/src/tests/non262/extensions/getset-005.js b/js/src/tests/non262/extensions/getset-005.js new file mode 100644 index 0000000000..a0694a892f --- /dev/null +++ b/js/src/tests/non262/extensions/getset-005.js @@ -0,0 +1,183 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * Date: 14 April 2001 + * + * SUMMARY: Testing obj.__defineSetter__(), obj.__defineGetter__() + * Note: this is a non-ECMA language extension + * + * This test is the same as getset-004.js, except that here we + * store the getter/setter functions in global variables. + */ +//----------------------------------------------------------------------------- +var UBound = 0; +var BUGNUMBER = '(none)'; +var summary = 'Testing obj.__defineSetter__(), obj.__defineGetter__()'; +var statprefix = 'Status: '; +var status = ''; +var statusitems = [ ]; +var actual = ''; +var actualvalues = [ ]; +var expect= ''; +var expectedvalues = [ ]; +var cnName = 'name'; +var cnDEFAULT = 'default name'; +var cnFRED = 'Fred'; +var obj = {}; +var obj2 = {}; +var s = ''; + + +// The getter/setter functions we'll use in all three sections below - +var cnNameSetter = function(newValue) {this._name=newValue; this.nameSETS++;}; +var cnNameGetter = function() {this.nameGETS++; return this._name;}; + + +// SECTION1: define getter/setter directly on an object (not its prototype) +obj = new Object(); +obj.nameSETS = 0; +obj.nameGETS = 0; +obj.__defineSetter__(cnName, cnNameSetter); +obj.__defineGetter__(cnName, cnNameGetter); + +status = 'In SECTION1 of test after 0 sets, 0 gets'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [0,0]; +addThis(); + +s = obj.name; +status = 'In SECTION1 of test after 0 sets, 1 get'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [0,1]; +addThis(); + +obj.name = cnFRED; +status = 'In SECTION1 of test after 1 set, 1 get'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [1,1]; +addThis(); + +obj.name = obj.name; +status = 'In SECTION1 of test after 2 sets, 2 gets'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [2,2]; +addThis(); + + +// SECTION2: define getter/setter in Object.prototype +Object.prototype.nameSETS = 0; +Object.prototype.nameGETS = 0; +Object.prototype.__defineSetter__(cnName, cnNameSetter); +Object.prototype.__defineGetter__(cnName, cnNameGetter); + +obj = new Object(); +status = 'In SECTION2 of test after 0 sets, 0 gets'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [0,0]; +addThis(); + +s = obj.name; +status = 'In SECTION2 of test after 0 sets, 1 get'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [0,1]; +addThis(); + +obj.name = cnFRED; +status = 'In SECTION2 of test after 1 set, 1 get'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [1,1]; +addThis(); + +obj.name = obj.name; +status = 'In SECTION2 of test after 2 sets, 2 gets'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [2,2]; +addThis(); + + +// SECTION 3: define getter/setter in prototype of user-defined constructor +function TestObject() +{ +} +TestObject.prototype.nameSETS = 0; +TestObject.prototype.nameGETS = 0; +TestObject.prototype.__defineSetter__(cnName, cnNameSetter); +TestObject.prototype.__defineGetter__(cnName, cnNameGetter); +TestObject.prototype.name = cnDEFAULT; + +obj = new TestObject(); +status = 'In SECTION3 of test after 1 set, 0 gets'; // (we set a default value in the prototype) +actual = [obj.nameSETS,obj.nameGETS]; +expect = [1,0]; +addThis(); + +s = obj.name; +status = 'In SECTION3 of test after 1 set, 1 get'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [1,1]; +addThis(); + +obj.name = cnFRED; +status = 'In SECTION3 of test after 2 sets, 1 get'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [2,1]; +addThis(); + +obj.name = obj.name; +status = 'In SECTION3 of test after 3 sets, 2 gets'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [3,2]; +addThis(); + +obj2 = new TestObject(); +status = 'obj2 = new TestObject() after 1 set, 0 gets'; +actual = [obj2.nameSETS,obj2.nameGETS]; +expect = [1,0]; // we set a default value in the prototype - +addThis(); + +// Use both obj and obj2 - +obj2.name = obj.name + obj2.name; +status = 'obj2 = new TestObject() after 2 sets, 1 get'; +actual = [obj2.nameSETS,obj2.nameGETS]; +expect = [2,1]; +addThis(); + +status = 'In SECTION3 of test after 3 sets, 3 gets'; +actual = [obj.nameSETS,obj.nameGETS]; +expect = [3,3]; // we left off at [3,2] above - +addThis(); + + +//--------------------------------------------------------------------------------- +test(); +//--------------------------------------------------------------------------------- + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual.toString(); + expectedvalues[UBound] = expect.toString(); + UBound++; +} + + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + for (var i = 0; i < UBound; i++) + { + reportCompare(expectedvalues[i], actualvalues[i], getStatus(i)); + } +} + + +function getStatus(i) +{ + return statprefix + statusitems[i]; +} diff --git a/js/src/tests/non262/extensions/getset-006.js b/js/src/tests/non262/extensions/getset-006.js new file mode 100644 index 0000000000..e7fe8c4212 --- /dev/null +++ b/js/src/tests/non262/extensions/getset-006.js @@ -0,0 +1,157 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * Date: 14 April 2001 + * + * SUMMARY: Testing obj.__lookupGetter__(), obj.__lookupSetter__() + * See http://bugzilla.mozilla.org/show_bug.cgi?id=71992 + * + * Brendan: "I see no need to provide more than the minimum: + * o.__lookupGetter__('p') returns the getter function for o.p, + * or undefined if o.p has no getter. Users can wrap and layer." + */ +//----------------------------------------------------------------------------- +var UBound = 0; +var BUGNUMBER = 71992; +var summary = 'Testing obj.__lookupGetter__(), obj.__lookupSetter__()'; +var statprefix = 'Status: '; +var status = ''; +var statusitems = [ ]; +var actual = ''; +var actualvalues = [ ]; +var expect= ''; +var expectedvalues = [ ]; +var cnName = 'name'; +var cnColor = 'color'; +var cnNonExistingProp = 'ASDF_#_$%'; +var cnDEFAULT = 'default name'; +var cnFRED = 'Fred'; +var cnRED = 'red'; +var obj = {}; +var obj2 = {}; +var s; + + +// The only setter and getter functions we'll use in the three sections below - +var cnNameSetter = function(newValue) {this._name=newValue; this.nameSETS++;}; +var cnNameGetter = function() {this.nameGETS++; return this._name;}; + + + +// SECTION1: define getter/setter directly on an object (not its prototype) +obj = new Object(); +obj.nameSETS = 0; +obj.nameGETS = 0; +obj.__defineSetter__(cnName, cnNameSetter); +obj.__defineGetter__(cnName, cnNameGetter); +obj.name = cnFRED; +obj.color = cnRED; + +status ='In SECTION1 of test; looking up extant getter/setter'; +actual = [obj.__lookupSetter__(cnName), obj.__lookupGetter__(cnName)]; +expect = [cnNameSetter, cnNameGetter]; +addThis(); + +status = 'In SECTION1 of test; looking up nonexistent getter/setter'; +actual = [obj.__lookupSetter__(cnColor), obj.__lookupGetter__(cnColor)]; +expect = [undefined, undefined]; +addThis(); + +status = 'In SECTION1 of test; looking up getter/setter on nonexistent property'; +actual = [obj.__lookupSetter__(cnNonExistingProp), obj.__lookupGetter__(cnNonExistingProp)]; +expect = [undefined, undefined]; +addThis(); + + + +// SECTION2: define getter/setter in Object.prototype +Object.prototype.nameSETS = 0; +Object.prototype.nameGETS = 0; +Object.prototype.__defineSetter__(cnName, cnNameSetter); +Object.prototype.__defineGetter__(cnName, cnNameGetter); + +obj = new Object(); +obj.name = cnFRED; +obj.color = cnRED; + +status = 'In SECTION2 of test looking up extant getter/setter'; +actual = [obj.__lookupSetter__(cnName), obj.__lookupGetter__(cnName)]; +expect = [cnNameSetter, cnNameGetter]; +addThis(); + +status = 'In SECTION2 of test; looking up nonexistent getter/setter'; +actual = [obj.__lookupSetter__(cnColor), obj.__lookupGetter__(cnColor)]; +expect = [undefined, undefined]; +addThis(); + +status = 'In SECTION2 of test; looking up getter/setter on nonexistent property'; +actual = [obj.__lookupSetter__(cnNonExistingProp), obj.__lookupGetter__(cnNonExistingProp)]; +expect = [undefined, undefined]; +addThis(); + + + +// SECTION 3: define getter/setter in prototype of user-defined constructor +function TestObject() +{ +} +TestObject.prototype.nameSETS = 0; +TestObject.prototype.nameGETS = 0; +TestObject.prototype.__defineSetter__(cnName, cnNameSetter); +TestObject.prototype.__defineGetter__(cnName, cnNameGetter); +TestObject.prototype.name = cnDEFAULT; + +obj = new TestObject(); +obj.name = cnFRED; +obj.color = cnRED; + +status = 'In SECTION3 of test looking up extant getter/setter'; +actual = [obj.__lookupSetter__(cnName), obj.__lookupGetter__(cnName)]; +expect = [cnNameSetter, cnNameGetter]; +addThis(); + +status = 'In SECTION3 of test; looking up nonexistent getter/setter'; +actual = [obj.__lookupSetter__(cnColor), obj.__lookupGetter__(cnColor)]; +expect = [undefined, undefined]; +addThis(); + +status = 'In SECTION3 of test; looking up getter/setter on nonexistent property'; +actual = [obj.__lookupSetter__(cnNonExistingProp), obj.__lookupGetter__(cnNonExistingProp)]; +expect = [undefined, undefined]; +addThis(); + + + +//--------------------------------------------------------------------------------- +test(); +//--------------------------------------------------------------------------------- + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual.toString(); + expectedvalues[UBound] = expect.toString(); + UBound++; +} + + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + for (var i = 0; i < UBound; i++) + { + reportCompare(expectedvalues[i], actualvalues[i], getStatus(i)); + } +} + + +function getStatus(i) +{ + return statprefix + statusitems[i]; +} diff --git a/js/src/tests/non262/extensions/inc-dec-functioncall.js b/js/src/tests/non262/extensions/inc-dec-functioncall.js new file mode 100644 index 0000000000..b4de03c6c0 --- /dev/null +++ b/js/src/tests/non262/extensions/inc-dec-functioncall.js @@ -0,0 +1,90 @@ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 609756; +var summary = + "Perform ToNumber on the result of the |fun()| in |fun()++| before " + + "throwing"; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +var hadSideEffect; + +function f() +{ + return { valueOf: function() { hadSideEffect = true; return 0; } }; +} + +hadSideEffect = false; +assertThrowsInstanceOf(function() { f()++; }, ReferenceError); +assertEq(hadSideEffect, true); + +hadSideEffect = false; +assertThrowsInstanceOf(function() { + for (var i = 0; i < 20; i++) + { + if (i > 18) + f()++; + } +}, ReferenceError); +assertEq(hadSideEffect, true); + + +hadSideEffect = false; +assertThrowsInstanceOf(function() { f()--; }, ReferenceError); +assertEq(hadSideEffect, true); + +hadSideEffect = false; +assertThrowsInstanceOf(function() { + for (var i = 0; i < 20; i++) + { + if (i > 18) + f()--; + } +}, ReferenceError); +assertEq(hadSideEffect, true); + + +hadSideEffect = false; +assertThrowsInstanceOf(function() { ++f(); }, ReferenceError); +assertEq(hadSideEffect, true); + +hadSideEffect = false; +assertThrowsInstanceOf(function() { + for (var i = 0; i < 20; i++) + { + if (i > 18) + ++f(); + } +}, ReferenceError); +assertEq(hadSideEffect, true); + + +hadSideEffect = false; +assertThrowsInstanceOf(function() { --f(); }, ReferenceError); +assertEq(hadSideEffect, true); + +hadSideEffect = false; +assertThrowsInstanceOf(function() { + for (var i = 0; i < 20; i++) + { + if (i > 18) + --f(); + } +}, ReferenceError); +assertEq(hadSideEffect, true); + + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete"); diff --git a/js/src/tests/non262/extensions/keyword-unescaped-requirement-modules.js b/js/src/tests/non262/extensions/keyword-unescaped-requirement-modules.js new file mode 100644 index 0000000000..260948cfed --- /dev/null +++ b/js/src/tests/non262/extensions/keyword-unescaped-requirement-modules.js @@ -0,0 +1,99 @@ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 1204027; +var summary = + "Escape sequences aren't allowed in bolded grammar tokens (that is, in " + + "keywords, possibly contextual keywords)"; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +var badModules = + [ + "\\u0069mport f from 'g'", + "i\\u006dport g from 'h'", + "import * \\u0061s foo", + "import {} fro\\u006d 'bar'", + "import { x \\u0061s y } from 'baz'", + + "\\u0065xport function f() {}", + "e\\u0078port function g() {}", + "export * fro\\u006d 'fnord'", + "export d\\u0065fault var x = 3;", + "export { q } fro\\u006d 'qSupplier';", + + ]; + +if (typeof parseModule === "function") +{ + for (var module of badModules) + { + assertThrowsInstanceOf(() => parseModule(module), SyntaxError, + "bad behavior for: " + module); + } +} + +if (typeof Reflect.parse === "function") +{ + var twoStatementAST = + Reflect.parse(`let x = 0; + export { x } /* ASI should trigger here */ + fro\\u006D`, + { target: "module" }); + + var statements = twoStatementAST.body; + assertEq(statements.length, 3, + "should have two items in the module, not one ExportDeclaration"); + assertEq(statements[0].type, "VariableDeclaration"); + assertEq(statements[1].type, "ExportDeclaration"); + assertEq(statements[2].type, "ExpressionStatement"); + assertEq(statements[2].expression.name, "from"); + + var oneStatementAST = + Reflect.parse(`export { x } /* no ASI here */ + from 'foo'`, + { target: "module" }); + + assertEq(oneStatementAST.body.length, 1); + assertEq(oneStatementAST.body[0].type, "ExportDeclaration"); + + twoStatementAST = + Reflect.parse(`export { x } from "bar" + /bar/g`, + { target: "module" }); + + statements = twoStatementAST.body; + assertEq(statements.length, 2, + "should have two items in the module, not one ExportDeclaration"); + assertEq(statements[0].type, "ExportDeclaration"); + assertEq(statements[1].type, "ExpressionStatement"); + assertEq(statements[1].expression.type, "Literal"); + assertEq(statements[1].expression.value.toString(), "/bar/g"); + + twoStatementAST = + Reflect.parse(`export * from "bar" + /bar/g`, + { target: "module" }); + + statements = twoStatementAST.body; + assertEq(statements.length, 2, + "should have two items in the module, not one ExportDeclaration"); + assertEq(statements[0].type, "ExportDeclaration"); + assertEq(statements[1].type, "ExpressionStatement"); + assertEq(statements[1].expression.type, "Literal"); + assertEq(statements[1].expression.value.toString(), "/bar/g"); +} + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete"); diff --git a/js/src/tests/non262/extensions/keyword-unescaped-requirement.js b/js/src/tests/non262/extensions/keyword-unescaped-requirement.js new file mode 100644 index 0000000000..20d3555e3d --- /dev/null +++ b/js/src/tests/non262/extensions/keyword-unescaped-requirement.js @@ -0,0 +1,43 @@ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 1204027; +var summary = + "Escape sequences aren't allowed in bolded grammar tokens (that is, in " + + "keywords, possibly contextual keywords)"; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +var randomExtensions = + [ + "for \\u0065ach (var x in []);", + "for e\\u0061ch (var x in []);", + "[0 for \\u0065ach (var x in [])]", + "[0 for e\\u0061ch (var x in [])]", + "(0 for \\u0065ach (var x in []))", + "(0 for e\\u0061ch (var x in []))", + + // Soon to be not an extension, maybe... + "(for (x \\u006ff [1]) x)", + "(for (x o\\u0066 [1]) x)", + ]; + +for (var extension of randomExtensions) +{ + assertThrowsInstanceOf(() => Function(extension), SyntaxError, + "bad behavior for: " + extension); +} + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete"); diff --git a/js/src/tests/non262/extensions/mutable-proto-special-form.js b/js/src/tests/non262/extensions/mutable-proto-special-form.js new file mode 100644 index 0000000000..b196507f25 --- /dev/null +++ b/js/src/tests/non262/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/non262/extensions/nested-delete-name-in-evalcode.js b/js/src/tests/non262/extensions/nested-delete-name-in-evalcode.js new file mode 100644 index 0000000000..7dfab04589 --- /dev/null +++ b/js/src/tests/non262/extensions/nested-delete-name-in-evalcode.js @@ -0,0 +1,85 @@ +// Any copyright is dedicated to the Public Domain. +// http://creativecommons.org/licenses/publicdomain/ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 616294; +var summary = + "|delete x| inside a function in eval code, where that eval code includes " + + "|var x| at top level, actually does delete the binding for x"; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +var f; + +function testOuterLet() +{ + return eval("let x; (function() { return delete x; })"); +} + +f = testOuterLet(); + +assertEq(f(), false); // can't delete lexical declarations => false + + +function testOuterForLet() +{ + return eval("for (let x; false; ); (function() { return delete x; })"); +} + +f = testOuterForLet(); + +assertEq(f(), true); // not there => true (only non-configurable => false) + + +function testOuterForInLet() +{ + return eval("for (let x in {}); (function() { return delete x; })"); +} + +f = testOuterForInLet(); + +assertEq(f(), true); // configurable, so remove => true +assertEq(f(), true); // not there => true (only non-configurable => false) + + +function testOuterNestedVarInForLet() +{ + return eval("for (let q = 0; q < 5; q++) { var x; } (function() { return delete x; })"); +} + +f = testOuterNestedVarInForLet(); + +assertEq(f(), true); // configurable, so remove => true +assertEq(f(), true); // there => true + + +function testArgumentShadowLet() +{ + return eval("let x; (function(x) { return delete x; })"); +} + +f = testArgumentShadowLet(); + +assertEq(f(), false); // non-configurable argument => false + + +function testFunctionLocal() +{ + return eval("(function() { let x; return delete x; })"); +} + +f = testFunctionLocal(); + +assertEq(f(), false); // defined by function code => not configurable => false + + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("All tests passed!"); diff --git a/js/src/tests/non262/extensions/new-cross-compartment.js b/js/src/tests/non262/extensions/new-cross-compartment.js new file mode 100644 index 0000000000..cae4b187df --- /dev/null +++ b/js/src/tests/non262/extensions/new-cross-compartment.js @@ -0,0 +1,39 @@ +// Any copyright is dedicated to the Public Domain. +// http://creativecommons.org/licenses/publicdomain/ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 1178653; +var summary = + "|new| on a cross-compartment wrapper to a non-constructor shouldn't assert"; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +var g = newGlobal(); + +var otherStr = new g.String("foo"); +assertEq(otherStr instanceof g.String, true); +assertEq(otherStr.valueOf(), "foo"); + +try +{ + var constructor = g.parseInt; + new constructor(); + throw new Error("no error thrown"); +} +catch (e) +{ + // NOTE: not |g.TypeError|, because |new| itself throws because + // |!IsConstructor(constructor)|. + assertEq(e instanceof TypeError, true); +} + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete"); diff --git a/js/src/tests/non262/extensions/new-parenthesization.js b/js/src/tests/non262/extensions/new-parenthesization.js new file mode 100644 index 0000000000..a3aebf383f --- /dev/null +++ b/js/src/tests/non262/extensions/new-parenthesization.js @@ -0,0 +1,21 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + * Contributor: Jesse Ruderman + */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 521456; +var summary = + 'Incorrect decompilation of new (eval(v)).s and new (f.apply(2)).s'; +printBugNumber(BUGNUMBER); +printStatus(summary); + +function foo(c) { return new (eval(c)).s; } +function bar(f) { var a = new (f.apply(2).s); return a; } + +assertEq(bar.toString().search(/new\s+f/), -1); +assertEq(foo.toString().search(/new\s+eval/), -1); + +reportCompare(true, true); diff --git a/js/src/tests/non262/extensions/newer-type-functions-caller-arguments.js b/js/src/tests/non262/extensions/newer-type-functions-caller-arguments.js new file mode 100644 index 0000000000..8f2d47a11d --- /dev/null +++ b/js/src/tests/non262/extensions/newer-type-functions-caller-arguments.js @@ -0,0 +1,94 @@ +// Tests that newer-type functions (i.e. anything not defined by regular function declarations and +// expressions) throw when accessing their 'arguments' and 'caller' properties. + +// 9.2.7 (AddRestrictedFunctionProperties) defines accessors on Function.prototype which throw on +// every 'get' and 'set' of 'caller' and 'arguments'. +// Additionally, 16.2 (Forbidden Extensions) forbids adding properties to all non-"legacy" function +// declarations and expressions. This creates the effect that all newer-style functions act like +// strict-mode functions when accessing their 'caller' and 'arguments' properties. + +const container = { + async asyncMethod() {}, + *genMethod() {}, + method() {}, + get getterMethod() {}, + set setterMethod(x) {}, +}; + +function* genDecl(){} +async function asyncDecl(){} +class classDecl {} +class extClassDecl extends Object {} +class classDeclExplicitCtor { constructor(){} } +class extClassDeclExplicitCtor extends Object { constructor(){} } + +const functions = [ + // Declarations + genDecl, + asyncDecl, + classDecl, + extClassDecl, + classDeclExplicitCtor, + extClassDeclExplicitCtor, + + // Expressions + async function(){}, + function*(){}, + () => {}, + async () => {}, + class {}, + class extends Object {}, + class { constructor(){} }, + class extends Object { constructor(){} }, + + // Methods + container.asyncMethod, + container.genMethod, + container.method, + Object.getOwnPropertyDescriptor(container, "getterMethod").get, + Object.getOwnPropertyDescriptor(container, "setterMethod").set, + + // Bound functions + function(){}.bind(), + + // Built-ins (native and self-hosted) + Function, + Function.prototype.bind, +]; + +const supportsAsyncGenerator = (function() { + try { + eval("async function* f(){}"); + return true; + } catch (e) { + return false; + } +})(); + +if (supportsAsyncGenerator) { +eval(` + async function* asyncGenDecl(){} + + functions.push(asyncGenDecl); + functions.push(async function*(){}); + functions.push({async* asyncGenerator(){}}.asyncGenerator); +`); +} + +functions.forEach(f => { + checkArgumentsAccess(f); + checkCallerAccess(f); +}); + +function checkArgumentsAccess(f) { + assertThrowsInstanceOf(() => f.arguments, TypeError, + `Expected 'arguments' property access to throw on ${f}`); +} + +function checkCallerAccess(f) { + assertThrowsInstanceOf(() => f.caller, TypeError, + `Expected 'caller' property access to throw on ${f}`); +} + +if (typeof reportCompare === "function") + reportCompare(true, true); diff --git a/js/src/tests/non262/extensions/non_syntactic.js b/js/src/tests/non262/extensions/non_syntactic.js new file mode 100644 index 0000000000..941229df39 --- /dev/null +++ b/js/src/tests/non262/extensions/non_syntactic.js @@ -0,0 +1,39 @@ +// |reftest| skip-if(!xulRuntime.shell) -- needs evaluate() +// Any copyright is dedicated to the Public Domain. +// http://creativecommons.org/licenses/publicdomain/ + +// Check references to someVar, both as a variable and on |this|, in +// various evaluation contexts. +var someVar = 1; + +// Top level. +assertEq(someVar, 1); +assertEq(this.someVar, 1); + +// Inside evaluate. +evaluate("assertEq(someVar, 1);"); +evaluate("assertEq(this.someVar, 1);"); + +// With an object on the scope, no shadowing. +var someObject = { someOtherField: 2 }; +var evalOpt = { envChainObject: someObject }; +evaluate("assertEq(someVar, 1);", evalOpt); +evaluate("assertEq(this.someVar, undefined);", evalOpt); + +// With an object on the scope, shadowing global. +someObject = { someVar: 2 }; +evalOpt = { envChainObject: someObject }; +var alsoSomeObject = someObject; +evaluate("assertEq(someVar, 2);", evalOpt); +evaluate("assertEq(this.someVar, 2);", evalOpt); +evaluate("assertEq(this, alsoSomeObject);", evalOpt); + +// With an object on the scope, inside a function. +evaluate("(function() { assertEq(someVar, 2);})()", evalOpt); +evaluate("(function() { assertEq(this !== alsoSomeObject, true);})()", evalOpt); +evaluate("(function() { assertEq(this.someVar, 1);})()", evalOpt); + +// `this` is ShellWindowProxy instead of GlobalObject, and it's allowed. +evaluate("assertEq(someVar, 1);", { envChainObject: this }); + +reportCompare(true, true); diff --git a/js/src/tests/non262/extensions/object-toSource-override-on-getter.js b/js/src/tests/non262/extensions/object-toSource-override-on-getter.js new file mode 100644 index 0000000000..f79499a52f --- /dev/null +++ b/js/src/tests/non262/extensions/object-toSource-override-on-getter.js @@ -0,0 +1,14 @@ +// |reftest| skip-if(!Function.prototype.toSource) +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ */ + +let x = {}; +let y = function() {}; +y.toSource = function() { + return "[012345678901234567890123456789]"; +}; +Object.defineProperty(x, "", {enumerable: true, get: y}); +assertEq(x.toSource(), "({'':[012345678901234567890123456789]})"); + +if (typeof reportCompare === "function") + reportCompare(0, 0); diff --git a/js/src/tests/non262/extensions/object-toSource-undefined-getter.js b/js/src/tests/non262/extensions/object-toSource-undefined-getter.js new file mode 100644 index 0000000000..7c8e3289a4 --- /dev/null +++ b/js/src/tests/non262/extensions/object-toSource-undefined-getter.js @@ -0,0 +1,11 @@ +// |reftest| skip-if(!Object.prototype.toSource) + +/* 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/non262/extensions/object-toSource-with-symbol-keys.js b/js/src/tests/non262/extensions/object-toSource-with-symbol-keys.js new file mode 100644 index 0000000000..74ee7e9f31 --- /dev/null +++ b/js/src/tests/non262/extensions/object-toSource-with-symbol-keys.js @@ -0,0 +1,16 @@ +// |reftest| skip-if(!Object.prototype.toSource) + +/* 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/non262/extensions/parse-rest-destructuring-parameter.js b/js/src/tests/non262/extensions/parse-rest-destructuring-parameter.js new file mode 100644 index 0000000000..dda67c95f3 --- /dev/null +++ b/js/src/tests/non262/extensions/parse-rest-destructuring-parameter.js @@ -0,0 +1,27 @@ +// |reftest| skip-if(!xulRuntime.shell) +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +function funArgs(params) { + return Reflect.parse(`function f(${params}) {}`).body[0].rest; +} + +var arrayRest = funArgs("...[]"); +assertEq(arrayRest.type, "ArrayPattern"); +assertEq(arrayRest.elements.length, 0); + +arrayRest = funArgs("...[a]"); +assertEq(arrayRest.type, "ArrayPattern"); +assertEq(arrayRest.elements.length, 1); + +var objectRest = funArgs("...{}"); +assertEq(objectRest.type, "ObjectPattern"); +assertEq(objectRest.properties.length, 0); + +objectRest = funArgs("...{p: a}"); +assertEq(objectRest.type, "ObjectPattern"); +assertEq(objectRest.properties.length, 1); + +if (typeof reportCompare === "function") + reportCompare(0, 0); diff --git a/js/src/tests/non262/extensions/preventExtensions-cross-global.js b/js/src/tests/non262/extensions/preventExtensions-cross-global.js new file mode 100644 index 0000000000..0cc68e0fb4 --- /dev/null +++ b/js/src/tests/non262/extensions/preventExtensions-cross-global.js @@ -0,0 +1,49 @@ +// |reftest| skip-if(!xulRuntime.shell) -- needs newGlobal() +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + * Contributor: + * Jeff Walden <jwalden+code@mit.edu> + */ + +var gTestfile = 'preventExtensions-cross-global.js'; +//----------------------------------------------------------------------------- +var BUGNUMBER = 789897; +var summary = + "Object.preventExtensions and Object.isExtensible should work correctly " + + "across globals"; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +var otherGlobal = newGlobal(); + +var obj = {}; +assertEq(otherGlobal.Object.isExtensible(obj), true); +assertEq(otherGlobal.Object.preventExtensions(obj), obj); +assertEq(otherGlobal.Object.isExtensible(obj), false); + +var objFromOther = otherGlobal.Object(); +assertEq(Object.isExtensible(objFromOther), true); +assertEq(Object.preventExtensions(objFromOther), objFromOther); +assertEq(Object.isExtensible(objFromOther), false); + +var proxy = new Proxy({}, {}); +assertEq(otherGlobal.Object.isExtensible(proxy), true); +assertEq(otherGlobal.Object.preventExtensions(proxy), proxy); +assertEq(otherGlobal.Object.isExtensible(proxy), false); + +var proxyFromOther = otherGlobal.evaluate("new Proxy({}, {})"); +assertEq(Object.isExtensible(proxyFromOther), true); +assertEq(Object.preventExtensions(proxyFromOther), proxyFromOther); +assertEq(Object.isExtensible(proxyFromOther), false); + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete"); diff --git a/js/src/tests/non262/extensions/proxy-array-target-length-definition.js b/js/src/tests/non262/extensions/proxy-array-target-length-definition.js new file mode 100644 index 0000000000..c573c4ba08 --- /dev/null +++ b/js/src/tests/non262/extensions/proxy-array-target-length-definition.js @@ -0,0 +1,55 @@ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +var gTestfile = 'proxy-array-target-length-definition.js'; +var BUGNUMBER = 905947; +var summary = + "Redefining an array's |length| property when redefining the |length| " + + "property on a proxy with an array as target"; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +var arr = []; +var p = new Proxy(arr, {}); + +function assertThrowsTypeError(f) +{ + try { + f(); + assertEq(false, true, "Must have thrown"); + } catch (e) { + assertEq(e instanceof TypeError, true, "Must have thrown TypeError"); + } +} + +// Redefining non-configurable length should throw a TypeError +assertThrowsTypeError(function () { Object.defineProperty(p, "length", { value: 17, configurable: true }); }); + +// Same here. +assertThrowsTypeError(function () { Object.defineProperty(p, "length", { value: 42, enumerable: true }); }); + +// Check the property went unchanged. +var pd = Object.getOwnPropertyDescriptor(p, "length"); +assertEq(pd.value, 0); +assertEq(pd.writable, true); +assertEq(pd.enumerable, false); +assertEq(pd.configurable, false); + +var ad = Object.getOwnPropertyDescriptor(arr, "length"); +assertEq(ad.value, 0); +assertEq(ad.writable, true); +assertEq(ad.enumerable, false); +assertEq(ad.configurable, false); + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete"); diff --git a/js/src/tests/non262/extensions/proxy-enumeration.js b/js/src/tests/non262/extensions/proxy-enumeration.js new file mode 100644 index 0000000000..f872d635d8 --- /dev/null +++ b/js/src/tests/non262/extensions/proxy-enumeration.js @@ -0,0 +1,4 @@ +var list = Object.getOwnPropertyNames(this); +var found = list.indexOf("Proxy") != -1; +assertEq(found, true) +reportCompare(true, true) diff --git a/js/src/tests/non262/extensions/proxy-proto-setter.js b/js/src/tests/non262/extensions/proxy-proto-setter.js new file mode 100644 index 0000000000..37e620cd1c --- /dev/null +++ b/js/src/tests/non262/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/non262/extensions/proxy-strict.js b/js/src/tests/non262/extensions/proxy-strict.js new file mode 100644 index 0000000000..9dc9696853 --- /dev/null +++ b/js/src/tests/non262/extensions/proxy-strict.js @@ -0,0 +1,12 @@ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +var s = "grape"; +function f() { "use strict"; return this; } +var p = new Proxy(f, {}); +String.prototype.p = p; +assertEq(s.p(), "grape"); + +reportCompare(true,true); diff --git a/js/src/tests/non262/extensions/quote-string-for-nul-character.js b/js/src/tests/non262/extensions/quote-string-for-nul-character.js new file mode 100644 index 0000000000..f893410ed6 --- /dev/null +++ b/js/src/tests/non262/extensions/quote-string-for-nul-character.js @@ -0,0 +1,94 @@ +// Ensure we properly quote strings which can contain the NUL character before +// returning them to the user to avoid cutting off any trailing characters. + +function assertStringIncludes(actual, expected) { + assertEq(actual.includes(expected), true, `"${actual}" includes "${expected}"`); +} + +function assertErrorMessageIncludes(fn, str) { + try { + fn(); + } catch (e) { + assertStringIncludes(e.message, str); + return; + } + assertEq(true, false, "missing exception"); +} + +assertErrorMessageIncludes(() => "foo\0bar" in "asdf\0qwertz", "bar"); +assertErrorMessageIncludes(() => "foo\0bar" in "asdf\0qwertz", "qwertz"); + +if (this.Intl) { + assertErrorMessageIncludes(() => Intl.getCanonicalLocales("de\0Latn"), "Latn"); + + assertErrorMessageIncludes(() => Intl.Collator.supportedLocalesOf([], {localeMatcher:"lookup\0cookie"}), "cookie"); + assertErrorMessageIncludes(() => new Intl.Collator("en", {localeMatcher: "lookup\0cookie"}), "cookie"); + assertErrorMessageIncludes(() => new Intl.Collator("en", {usage: "sort\0cookie"}), "cookie"); + assertErrorMessageIncludes(() => new Intl.Collator("en", {caseFirst: "upper\0cookie"}), "cookie"); + assertErrorMessageIncludes(() => new Intl.Collator("en", {sensitivity: "base\0cookie"}), "cookie"); + + assertErrorMessageIncludes(() => Intl.DateTimeFormat.supportedLocalesOf([], {localeMatcher:"lookup\0cookie"}), "cookie"); + assertErrorMessageIncludes(() => new Intl.DateTimeFormat("en", {localeMatcher: "lookup\0cookie"}), "cookie"); + assertErrorMessageIncludes(() => new Intl.DateTimeFormat("en", {hourCycle: "h24\0cookie"}), "cookie"); + assertErrorMessageIncludes(() => new Intl.DateTimeFormat("en", {weekday: "narrow\0cookie"}), "cookie"); + assertErrorMessageIncludes(() => new Intl.DateTimeFormat("en", {era: "narrow\0cookie"}), "cookie"); + assertErrorMessageIncludes(() => new Intl.DateTimeFormat("en", {year: "2-digit\0cookie"}), "cookie"); + assertErrorMessageIncludes(() => new Intl.DateTimeFormat("en", {month: "2-digit\0cookie"}), "cookie"); + assertErrorMessageIncludes(() => new Intl.DateTimeFormat("en", {day: "2-digit\0cookie"}), "cookie"); + assertErrorMessageIncludes(() => new Intl.DateTimeFormat("en", {hour: "2-digit\0cookie"}), "cookie"); + assertErrorMessageIncludes(() => new Intl.DateTimeFormat("en", {minute: "2-digit\0cookie"}), "cookie"); + assertErrorMessageIncludes(() => new Intl.DateTimeFormat("en", {second: "2-digit\0cookie"}), "cookie"); + assertErrorMessageIncludes(() => new Intl.DateTimeFormat("en", {formatMatcher: "basic\0cookie"}), "cookie"); + assertErrorMessageIncludes(() => new Intl.DateTimeFormat("en", {timeZone: "UTC\0cookie"}), "cookie"); + + assertErrorMessageIncludes(() => Intl.NumberFormat.supportedLocalesOf([], {localeMatcher:"lookup\0cookie"}), "cookie"); + assertErrorMessageIncludes(() => new Intl.NumberFormat("en", {localeMatcher: "lookup\0cookie"}), "cookie"); + assertErrorMessageIncludes(() => new Intl.NumberFormat("en", {style: "decimal\0cookie"}), "cookie"); + assertErrorMessageIncludes(() => new Intl.NumberFormat("en", {currency: "USD\0cookie"}), "cookie"); + assertErrorMessageIncludes(() => new Intl.NumberFormat("en", {currencyDisplay: "code\0cookie"}), "cookie"); + + assertErrorMessageIncludes(() => Intl.PluralRules.supportedLocalesOf([], {localeMatcher:"lookup\0cookie"}), "cookie"); + assertErrorMessageIncludes(() => new Intl.PluralRules("en", {localeMatcher: "lookup\0cookie"}), "cookie"); + assertErrorMessageIncludes(() => new Intl.PluralRules("en", {type: "cardinal\0cookie"}), "cookie"); + + assertErrorMessageIncludes(() => Intl.RelativeTimeFormat.supportedLocalesOf([], {localeMatcher:"lookup\0cookie"}), "cookie"); + assertErrorMessageIncludes(() => new Intl.RelativeTimeFormat("en", {localeMatcher: "lookup\0cookie"}), "cookie"); + assertErrorMessageIncludes(() => new Intl.RelativeTimeFormat("en", {style: "long\0cookie"}), "cookie"); + assertErrorMessageIncludes(() => new Intl.RelativeTimeFormat("en", {numeric: "auto\0cookie"}), "cookie"); + assertErrorMessageIncludes(() => new Intl.RelativeTimeFormat().format(1, "day\0cookie"), "cookie"); + + assertErrorMessageIncludes(() => new Intl.Locale("de\0keks"), "keks"); + assertErrorMessageIncludes(() => new Intl.Locale("de", {language: "it\0biscotto"}), "biscotto"); + assertErrorMessageIncludes(() => new Intl.Locale("th", {script: "Thai\0คุกกี้"}), "\\u0E04\\u0E38\\u0E01\\u0E01\\u0E35\\u0E49"); + assertErrorMessageIncludes(() => new Intl.Locale("en", {region: "GB\0biscuit"}), "biscuit"); + + assertErrorMessageIncludes(() => new Intl.Locale("und", {calendar: "gregory\0F1"}), "F1"); + assertErrorMessageIncludes(() => new Intl.Locale("und", {collation: "phonebk\0F2"}), "F2"); + assertErrorMessageIncludes(() => new Intl.Locale("und", {hourCycle: "h24\0F3"}), "F3"); + assertErrorMessageIncludes(() => new Intl.Locale("und", {caseFirst: "false\0F4"}), "F4"); + assertErrorMessageIncludes(() => new Intl.Locale("und", {numberingSystem: "arab\0F5"}), "F5"); +} + +// Shell and helper functions. + +assertErrorMessageIncludes(() => assertEq(true, false, "foo\0bar"), "bar"); + +if (this.disassemble) { + assertStringIncludes(disassemble(Function("var re = /foo\0bar/")), "bar"); +} + +if (this.getBacktrace) { + const k = "asdf\0asdf"; + const o = {[k](a) { "use strict"; return getBacktrace({locals: true, args: true}); }}; + const r = o[k].call("foo\0bar", "baz\0faz"); + assertStringIncludes(r, "bar"); + assertStringIncludes(r, "faz"); +} + +// js/src/tests/browser.js provides its own |options| function, make sure we don't test that one. +if (this.options && typeof document === "undefined") { + assertErrorMessageIncludes(() => options("foo\0bar"), "bar"); +} + +if (typeof reportCompare === "function") + reportCompare(true, true); diff --git a/js/src/tests/non262/extensions/recursion.js b/js/src/tests/non262/extensions/recursion.js new file mode 100644 index 0000000000..0869b90a6a --- /dev/null +++ b/js/src/tests/non262/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 of f()); + } + catch (e) + { + gc(); + } + } + foopy(); +} +test(); + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("All tests passed!"); diff --git a/js/src/tests/non262/extensions/redeclaration-of-catch-warning.js b/js/src/tests/non262/extensions/redeclaration-of-catch-warning.js new file mode 100644 index 0000000000..efdfc0ef98 --- /dev/null +++ b/js/src/tests/non262/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 * + **************/ + +function assertRedeclarationErrorThrown(expression) +{ + "use strict"; + + 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/non262/extensions/reentrant-RegExp-creation-and-gc-during-new-RegExp-pattern-ToString.js b/js/src/tests/non262/extensions/reentrant-RegExp-creation-and-gc-during-new-RegExp-pattern-ToString.js new file mode 100644 index 0000000000..0ec0b493e4 --- /dev/null +++ b/js/src/tests/non262/extensions/reentrant-RegExp-creation-and-gc-during-new-RegExp-pattern-ToString.js @@ -0,0 +1,41 @@ +// |reftest| skip-if(!xulRuntime.shell) -- needs gc (newGlobal/evaluate are shimmed) +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +var gTestfile = + "reentrant-RegExp-creation-and-gc-during-new-RegExp-pattern-ToString.js"; +//----------------------------------------------------------------------------- +var BUGNUMBER = 1253099; +var summary = + "Don't assert when, in |new RegExp(pat)|, stringifying |pat| creates " + + "another RegExp and then performs a GC"; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +// The fresh global object is required to ensure that the outer |new RegExp| +// is the first RegExp created in the global (other than RegExp.prototype). +newGlobal().evaluate(` +var createsRegExpAndCallsGCWhenStringified = + { + toString: function() { + new RegExp("a"); + gc(); + return "q"; + } + }; + +assertEq(new RegExp(createsRegExpAndCallsGCWhenStringified).source, "q"); +`); + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete"); diff --git a/js/src/tests/non262/extensions/regress-103087.js b/js/src/tests/non262/extensions/regress-103087.js new file mode 100644 index 0000000000..9a305827e0 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-103087.js @@ -0,0 +1,141 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * Date: 04 October 2001 + * + * SUMMARY: Arose from Bugzilla bug 103087: + * "The RegExp MarkupSPE in demo crashes Mozilla" + * + * See http://bugzilla.mozilla.org/show_bug.cgi?id=103087 + * The SpiderMonkey shell crashed on some of these regexps. + * + * The reported crash was on i=24 below ('MarkupSPE' regexp) + * I crashed on that, and also on i=43 ('XML_SPE' regexp) + */ +//----------------------------------------------------------------------------- +var UBound = 0; +var BUGNUMBER = 103087; +var summary = "Testing that we don't crash on any of these regexps -"; +var re = ''; +var lm = ''; +var lc = ''; +var rc = ''; + + +// the regexps are built in pieces - +var NameStrt = "[A-Za-z_:]|[^\\x00-\\x7F]"; +var NameChar = "[A-Za-z0-9_:.-]|[^\\x00-\\x7F]"; +var Name = "(" + NameStrt + ")(" + NameChar + ")*"; +var TextSE = "[^<]+"; +var UntilHyphen = "[^-]*-"; +var Until2Hyphens = UntilHyphen + "([^-]" + UntilHyphen + ")*-"; +var CommentCE = Until2Hyphens + ">?"; +var UntilRSBs = "[^]]*]([^]]+])*]+"; +var CDATA_CE = UntilRSBs + "([^]>]" + UntilRSBs + ")*>"; +var S = "[ \\n\\t\\r]+"; +var QuoteSE = '"[^"]' + "*" + '"' + "|'[^']*'"; +var DT_IdentSE = S + Name + "(" + S + "(" + Name + "|" + QuoteSE + "))*"; +var MarkupDeclCE = "([^]\"'><]+|" + QuoteSE + ")*>"; +var S1 = "[\\n\\r\\t ]"; +var UntilQMs = "[^?]*\\?+"; +var PI_Tail = "\\?>|" + S1 + UntilQMs + "([^>?]" + UntilQMs + ")*>"; +var DT_ItemSE = "<(!(--" + Until2Hyphens + ">|[^-]" + MarkupDeclCE + ")|\\?" + Name + "(" + PI_Tail + "))|%" + Name + ";|" + S; +var DocTypeCE = DT_IdentSE + "(" + S + ")?(\\[(" + DT_ItemSE + ")*](" + S + ")?)?>?"; +var DeclCE = "--(" + CommentCE + ")?|\\[CDATA\\[(" + CDATA_CE + ")?|DOCTYPE(" + DocTypeCE + ")?"; +var PI_CE = Name + "(" + PI_Tail + ")?"; +var EndTagCE = Name + "(" + S + ")?>?"; +var AttValSE = '"[^<"]' + "*" + '"' + "|'[^<']*'"; +var ElemTagCE = Name + "(" + S + Name + "(" + S + ")?=(" + S + ")?(" + AttValSE + "))*(" + S + ")?/?>?"; +var MarkupSPE = "<(!(" + DeclCE + ")?|\\?(" + PI_CE + ")?|/(" + EndTagCE + ")?|(" + ElemTagCE + ")?)"; +var XML_SPE = TextSE + "|" + MarkupSPE; +var CommentRE = "<!--" + Until2Hyphens + ">"; +var CommentSPE = "<!--(" + CommentCE + ")?"; +var PI_RE = "<\\?" + Name + "(" + PI_Tail + ")"; +var Erroneous_PI_SE = "<\\?[^?]*(\\?[^>]+)*\\?>"; +var PI_SPE = "<\\?(" + PI_CE + ")?"; +var CDATA_RE = "<!\\[CDATA\\[" + CDATA_CE; +var CDATA_SPE = "<!\\[CDATA\\[(" + CDATA_CE + ")?"; +var ElemTagSE = "<(" + NameStrt + ")([^<>\"']+|" + AttValSE + ")*>"; +var ElemTagRE = "<" + Name + "(" + S + Name + "(" + S + ")?=(" + S + ")?(" + AttValSE + "))*(" + S + ")?/?>"; +var ElemTagSPE = "<" + ElemTagCE; +var EndTagRE = "</" + Name + "(" + S + ")?>"; +var EndTagSPE = "</(" + EndTagCE + ")?"; +var DocTypeSPE = "<!DOCTYPE(" + DocTypeCE + ")?"; +var PERef_APE = "%(" + Name + ";?)?"; +var HexPart = "x([0-9a-fA-F]+;?)?"; +var NumPart = "#([0-9]+;?|" + HexPart + ")?"; +var CGRef_APE = "&(" + Name + ";?|" + NumPart + ")?"; +var Text_PE = CGRef_APE + "|[^&]+"; +var EntityValue_PE = CGRef_APE + "|" + PERef_APE + "|[^%&]+"; + + +var rePatterns = new Array(AttValSE, CDATA_CE, CDATA_RE, CDATA_SPE, CGRef_APE, CommentCE, CommentRE, CommentSPE, DT_IdentSE, DT_ItemSE, DeclCE, DocTypeCE, DocTypeSPE, ElemTagCE, ElemTagRE, ElemTagSE, ElemTagSPE, EndTagCE, EndTagRE, EndTagSPE, EntityValue_PE, Erroneous_PI_SE, HexPart, MarkupDeclCE, MarkupSPE, Name, NameChar, NameStrt, NumPart, PERef_APE, PI_CE, PI_RE, PI_SPE, PI_Tail, QuoteSE, S, S1, TextSE, Text_PE, Until2Hyphens, UntilHyphen, UntilQMs, UntilRSBs, XML_SPE); + + +// here's a big string to test the regexps on - +var str = ''; +str += '<html xmlns="http://www.w3.org/1999/xhtml"' + '\n'; +str += ' xmlns:xlink="http://www.w3.org/XML/XLink/0.9">' + '\n'; +str += ' <head><title>Three Namespaces</title></head>' + '\n'; +str += ' <body>' + '\n'; +str += ' <h1 align="center">An Ellipse and a Rectangle</h1>' + '\n'; +str += ' <svg xmlns="http://www.w3.org/Graphics/SVG/SVG-19991203.dtd" ' + '\n'; +str += ' width="12cm" height="10cm">' + '\n'; +str += ' <ellipse rx="110" ry="130" />' + '\n'; +str += ' <rect x="4cm" y="1cm" width="3cm" height="6cm" />' + '\n'; +str += ' </svg>' + '\n'; +str += ' <p xlink:type="simple" xlink:href="ellipses.html">' + '\n'; +str += ' More about ellipses' + '\n'; +str += ' </p>' + '\n'; +str += ' <p xlink:type="simple" xlink:href="rectangles.html">' + '\n'; +str += ' More about rectangles' + '\n'; +str += ' </p>' + '\n'; +str += ' <hr/>' + '\n'; +str += ' <p>Last Modified February 13, 2000</p> ' + '\n'; +str += ' </body>' + '\n'; +str += '</html>'; + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + for (var i=0; i<rePatterns.length; i++) + { + status = inSection(i); + re = new RegExp(rePatterns[i]); + + // Test that we don't crash on any of these - + re.exec(str); + getResults(); + + // Just for the heck of it, test the current leftContext + re.exec(lc); + getResults(); + + // Test the current rightContext + re.exec(rc); + getResults(); + } + + reportCompare('No Crash', 'No Crash', ''); +} + + +function getResults() +{ + lm = RegExp.lastMatch; + lc = RegExp.leftContext; + rc = RegExp.rightContext; +} diff --git a/js/src/tests/non262/extensions/regress-104077.js b/js/src/tests/non262/extensions/regress-104077.js new file mode 100644 index 0000000000..189f0ce903 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-104077.js @@ -0,0 +1,195 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * + * Date: 10 October 2001 + * SUMMARY: Regression test for Bugzilla bug 104077 + * See http://bugzilla.mozilla.org/show_bug.cgi?id=104077 + * "JS crash: with/finally/return" + * + * Also http://bugzilla.mozilla.org/show_bug.cgi?id=120571 + * "JS crash: try/catch/continue." + * + * SpiderMonkey crashed on this code - it shouldn't. + * + * NOTE: the finally-blocks below should execute even if their try-blocks + * have return or throw statements in them: + * + * ------- Additional Comment #76 From Mike Shaver 2001-12-07 01:21 ------- + * finally trumps return, and all other control-flow constructs that cause + * program execution to jump out of the try block: throw, break, etc. Once you + * enter a try block, you will execute the finally block after leaving the try, + * regardless of what happens to make you leave the try. + * + */ +//----------------------------------------------------------------------------- +var UBound = 0; +var BUGNUMBER = 104077; +var summary = "Just testing that we don't crash on with/finally/return -"; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; + + +function addValues_3(obj) +{ + var sum = 0; + + with (obj) + { + try + { + sum = arg1 + arg2; + with (arg3) + { + while (sum < 10) + { + try + { + if (sum > 5) + return sum; + sum += 1; + } + catch (e) + { + sum += 1; + } + } + } + } + finally + { + try + { + sum +=1; + print("In finally block of addValues_3() function: sum = " + sum); + } + catch (e) { + if (e != 42) + throw e; + sum +=1; + print('In finally catch block of addValues_3() function: sum = ' + sum + ', e = ' + e); + } + finally + { + sum +=1; + print("In finally finally block of addValues_3() function: sum = " + sum); + return sum; + } + } + } +} + +status = inSection(9); +obj = new Object(); +obj.arg1 = 1; +obj.arg2 = 2; +obj.arg3 = new Object(); +obj.arg3.a = 10; +obj.arg3.b = 20; +actual = addValues_3(obj); +expect = 8; +captureThis(); + + + + +function addValues_4(obj) +{ + var sum = 0; + + with (obj) + { + try + { + sum = arg1 + arg2; + with (arg3) + { + while (sum < 10) + { + try + { + if (sum > 5) + return sum; + sum += 1; + } + catch (e) + { + sum += 1; + } + } + } + } + finally + { + try + { + sum += 1; + print("In finally block of addValues_4() function: sum = " + sum); + } + catch (e) { + if (e == 42) { + sum += 1; + print("In 1st finally catch block of addValues_4() function: sum = " + sum + ", e = " + e); + } else if (e == 43) { + sum += 1; + print("In 2nd finally catch block of addValues_4() function: sum = " + sum + ", e = " + e); + } else { + throw e; + } + } + finally + { + sum += 1; + print("In finally finally block of addValues_4() function: sum = " + sum); + return sum; + } + } + } +} + +status = inSection(10); +obj = new Object(); +obj.arg1 = 1; +obj.arg2 = 2; +obj.arg3 = new Object(); +obj.arg3.a = 10; +obj.arg3.b = 20; +actual = addValues_4(obj); +expect = 8; +captureThis(); + + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function captureThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + for (var i=0; i<UBound; i++) + { + reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); + } +} diff --git a/js/src/tests/non262/extensions/regress-178722.js b/js/src/tests/non262/extensions/regress-178722.js new file mode 100644 index 0000000000..9ec73d3d15 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-178722.js @@ -0,0 +1,90 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * + * Date: 06 November 2002 + * SUMMARY: arr.sort() should not output |undefined| when |arr| is empty + * See http://bugzilla.mozilla.org/show_bug.cgi?id=178722 + * + * ECMA-262 Ed.3: 15.4.4.11 Array.prototype.sort (comparefn) + * + * 1. Call the [[Get]] method of this object with argument "length". + * 2. Call ToUint32(Result(1)). + * 3. Perform an implementation-dependent sequence of calls to the [[Get]], + * [[Put]], and [[Delete]] methods of this object, etc. etc. + * 4. Return this object. + * + * + * Note that sort() is done in-place on |arr|. In other words, sort() is a + * "destructive" method rather than a "functional" method. The return value + * of |arr.sort()| and |arr| are the same object. + * + * If |arr| is an empty array, the return value of |arr.sort()| should be + * an empty array, not the value |undefined| as was occurring in bug 178722. + * + */ +//----------------------------------------------------------------------------- +var UBound = 0; +var BUGNUMBER = 178722; +var summary = 'arr.sort() should not output |undefined| when |arr| is empty'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; +var arr; + + +// create empty array or pseudo-array objects in various ways +function f () {return arguments}; +var arr5 = f(); +arr5.__proto__ = Array.prototype; + + +status = inSection(5); +arr = arr5.sort(); +actual = arr instanceof Array && arr.length === 0 && arr === arr5; +expect = true; +addThis(); + + +// now do the same thing, with non-default sorting: +function g() {return 1;} + +status = inSection('5a'); +arr = arr5.sort(g); +actual = arr instanceof Array && arr.length === 0 && arr === arr5; +expect = true; +addThis(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus(summary); + + for (var i=0; i<UBound; i++) + { + reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); + } +} diff --git a/js/src/tests/non262/extensions/regress-188206-01.js b/js/src/tests/non262/extensions/regress-188206-01.js new file mode 100644 index 0000000000..c54390709b --- /dev/null +++ b/js/src/tests/non262/extensions/regress-188206-01.js @@ -0,0 +1,71 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var UBound = 0; +var BUGNUMBER = 188206; +var summary = 'Invalid use of regexp quantifiers should generate SyntaxErrors'; +var TEST_PASSED = 'SyntaxError'; +var TEST_FAILED = 'Generated an error, but NOT a SyntaxError!'; +var TEST_FAILED_BADLY = 'Did not generate ANY error!!!'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; + + +/* + * Now do some weird things on the left side of the regexps - + */ +status = inSection(7); +testThis(' /*a/ '); + +status = inSection(8); +testThis(' /**a/ '); + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +/* + * Invalid syntax should generate a SyntaxError + */ +function testThis(sInvalidSyntax) +{ + expect = TEST_PASSED; + actual = TEST_FAILED_BADLY; + + try + { + eval(sInvalidSyntax); + } + catch(e) + { + if (e instanceof SyntaxError) + actual = TEST_PASSED; + else + actual = TEST_FAILED; + } + + statusitems[UBound] = status; + expectedvalues[UBound] = expect; + actualvalues[UBound] = actual; + UBound++; +} + + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus(summary); + + for (var i=0; i<UBound; i++) + { + reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); + } +} diff --git a/js/src/tests/non262/extensions/regress-188206-02.js b/js/src/tests/non262/extensions/regress-188206-02.js new file mode 100644 index 0000000000..4cf9dd7b30 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-188206-02.js @@ -0,0 +1,121 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var UBound = 0; +var BUGNUMBER = 188206; +var summary = 'Invalid use of regexp quantifiers should generate SyntaxErrors'; +var CHECK_PASSED = 'Should not generate an error'; +var CHECK_FAILED = 'Generated an error!'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; + + +/* + * Misusing the {DecmalDigits} quantifier - according to ECMA, + * but not according to Perl. + * + * ECMA-262 Edition 3 prohibits the use of unescaped braces in + * regexp patterns, unless they form part of a quantifier. + * + * Hovever, Perl does not prohibit this. If not used as part + * of a quantifer, Perl treats braces literally. + * + * We decided to follow Perl on this for backward compatibility. + * See http://bugzilla.mozilla.org/show_bug.cgi?id=190685. + * + * Therefore NONE of the following ECMA violations should generate + * a SyntaxError. Note we use checkThis() instead of testThis(). + */ +status = inSection(13); +checkThis(' /a*{/ '); + +status = inSection(14); +checkThis(' /a{}/ '); + +status = inSection(15); +checkThis(' /{a/ '); + +status = inSection(16); +checkThis(' /}a/ '); + +status = inSection(17); +checkThis(' /x{abc}/ '); + +status = inSection(18); +checkThis(' /{{0}/ '); + +status = inSection(19); +checkThis(' /{{1}/ '); + +status = inSection(20); +checkThis(' /x{{0}/ '); + +status = inSection(21); +checkThis(' /x{{1}/ '); + +status = inSection(22); +checkThis(' /x{{0}}/ '); + +status = inSection(23); +checkThis(' /x{{1}}/ '); + +status = inSection(24); +checkThis(' /x{{0}}/ '); + +status = inSection(25); +checkThis(' /x{{1}}/ '); + +status = inSection(26); +checkThis(' /x{{0}}/ '); + +status = inSection(27); +checkThis(' /x{{1}}/ '); + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +/* + * Allowed syntax shouldn't generate any errors + */ +function checkThis(sAllowedSyntax) +{ + expect = CHECK_PASSED; + actual = CHECK_PASSED; + + try + { + eval(sAllowedSyntax); + } + catch(e) + { + actual = CHECK_FAILED; + } + + statusitems[UBound] = status; + expectedvalues[UBound] = expect; + actualvalues[UBound] = actual; + UBound++; +} + + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus(summary); + + for (var i=0; i<UBound; i++) + { + reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); + } +} diff --git a/js/src/tests/non262/extensions/regress-192465.js b/js/src/tests/non262/extensions/regress-192465.js new file mode 100644 index 0000000000..71bfac8dce --- /dev/null +++ b/js/src/tests/non262/extensions/regress-192465.js @@ -0,0 +1,122 @@ +// |reftest| skip-if(!Object.prototype.toSource) + +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * + * Date: 10 February 2003 + * SUMMARY: Object.toSource() recursion should check stack overflow + * + * See http://bugzilla.mozilla.org/show_bug.cgi?id=192465 + * + * MODIFIED: 27 February 2003 + * + * We are adding an early return to this testcase, since it is causing + * big problems on Linux RedHat8! For a discussion of this issue, see + * http://bugzilla.mozilla.org/show_bug.cgi?id=174341#c24 and following. + * + * + * MODIFIED: 20 March 2003 + * + * Removed the early return and changed |N| below from 1000 to 90. + * Note |make_deep_nest(N)| returns an object graph of length N(N+1). + * So the graph has now been reduced from 1,001,000 to 8190. + * + * With this reduction, the bug still manifests on my WinNT and Linux + * boxes (crash due to stack overflow). So the testcase is again of use + * on those boxes. At the same time, Linux RedHat8 boxes can now run + * the test in a reasonable amount of time. + */ +//----------------------------------------------------------------------------- +var UBound = 0; +var BUGNUMBER = 192465; +var summary = 'Object.toSource() recursion should check stack overflow'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; + + +/* + * We're just testing that this script will compile and run. + * Set both |actual| and |expect| to a dummy value. + */ +status = inSection(1); +var N = 90; +try +{ + make_deep_nest(N); +} +catch (e) +{ + // An exception is OK, as the runtime can throw one in response to too deep + // recursion. We haven't crashed; good! Continue on to set the dummy values - +} +actual = 1; +expect = 1; +addThis(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + +/* + * EXAMPLE: + * + * If the global variable |N| is 2, then for |level| == 0, 1, 2, the return + * value of this function will be toSource() of these objects, respectively: + * + * {next:{next:END}} + * {next:{next:{next:{next:END}}}} + * {next:{next:{next:{next:{next:{next:END}}}}}} + * + */ +function make_deep_nest(level) +{ + var head = {}; + var cursor = head; + + for (var i=0; i!=N; ++i) + { + cursor.next = {}; + cursor = cursor.next; + } + + cursor.toSource = function() + { + if (level != 0) + return make_deep_nest(level - 1); + return "END"; + } + + return head.toSource(); +} + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus(summary); + + for (var i=0; i<UBound; i++) + { + reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); + } +} diff --git a/js/src/tests/non262/extensions/regress-220367-002.js b/js/src/tests/non262/extensions/regress-220367-002.js new file mode 100644 index 0000000000..5948c24eec --- /dev/null +++ b/js/src/tests/non262/extensions/regress-220367-002.js @@ -0,0 +1,75 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * + * Date: 26 September 2003 + * SUMMARY: Regexp conformance test + * + * See http://bugzilla.mozilla.org/show_bug.cgi?id=220367 + * + */ +//----------------------------------------------------------------------------- +var UBound = 0; +var BUGNUMBER = 220367; +var summary = 'Regexp conformance test'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; + +var re = /(a)|(b)/; + +re.test('a'); +status = inSection(1); +actual = RegExp.$1; +expect = 'a'; +addThis(); + +status = inSection(2); +actual = RegExp.$2; +expect = ''; +addThis(); + +re.test('b'); +status = inSection(3); +actual = RegExp.$1; +expect = ''; +addThis(); + +status = inSection(4); +actual = RegExp.$2; +expect = 'b'; +addThis(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus(summary); + + for (var i=0; i<UBound; i++) + { + reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); + } +} diff --git a/js/src/tests/non262/extensions/regress-226078.js b/js/src/tests/non262/extensions/regress-226078.js new file mode 100644 index 0000000000..fe238652ac --- /dev/null +++ b/js/src/tests/non262/extensions/regress-226078.js @@ -0,0 +1,33 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 226078; +var summary = 'Do not Crash @ js_Interpret 3127f864'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +printBugNumber(BUGNUMBER); +printStatus (summary); + + +function SetLangHead(l){ + with(p){ + for(var i in x) + if(getElementById("TxtH"+i)!=undefined) + printStatus('huh'); + } +} +x=[0,1,2,3]; +p={getElementById: function (id){ + printStatus(id); + if (typeof dis === "function") { + dis(SetLangHead); + } + return undefined; +}}; +SetLangHead(1); + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/non262/extensions/regress-228087.js b/js/src/tests/non262/extensions/regress-228087.js new file mode 100644 index 0000000000..c0b1661752 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-228087.js @@ -0,0 +1,316 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 4 -*- +/* This Source Code Form is subject to the terms of the Mozilla Public +* License, v. 2.0. If a copy of the MPL was not distributed with this +* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * + * Date: 12 December 2003 + * SUMMARY: Testing regexps with unescaped braces + * See http://bugzilla.mozilla.org/show_bug.cgi?id=228087 + * + * Note: unbalanced, unescaped braces are not permitted by ECMA-262 Ed.3, + * but we decided to follow Perl and IE and allow this for compatibility. + * + * See http://bugzilla.mozilla.org/show_bug.cgi?id=188206 and its testcase. + * See http://bugzilla.mozilla.org/show_bug.cgi?id=223273 and its testcase. + */ +//----------------------------------------------------------------------------- +var i = 0; +var BUGNUMBER = 228087; +var summary = 'Testing regexps with unescaped braces'; +var status = ''; +var statusmessages = new Array(); +var pattern = ''; +var patterns = new Array(); +var string = ''; +var strings = new Array(); +var actualmatch = ''; +var actualmatches = new Array(); +var expectedmatch = ''; +var expectedmatches = new Array(); +var e; + + +string = 'foo {1} foo {2} foo'; + +// try an example with the braces escaped +status = inSection(1); +try +{ + pattern = new RegExp('\{1.*\}', 'g'); + actualmatch = string.match(pattern); +} +catch (e) +{ + pattern = 'error'; + actualmatch = ''; +} +expectedmatch = Array('{1} foo {2}'); +addThis(); + +// just like Section 1, without the braces being escaped +status = inSection(2); +try +{ + pattern = new RegExp('{1.*}', 'g'); + actualmatch = string.match(pattern); +} +catch (e) +{ + pattern = 'error'; + actualmatch = ''; +} +expectedmatch = Array('{1} foo {2}'); +addThis(); + +// try an example with the braces escaped +status = inSection(3); +try +{ + pattern = new RegExp('\{1[.!\}]*\}', 'g'); + actualmatch = string.match(pattern); +} +catch (e) +{ + pattern = 'error'; + actualmatch = ''; +} +expectedmatch = Array('{1}'); +addThis(); + +// just like Section 3, without the braces being escaped +status = inSection(4); +try +{ + pattern = new RegExp('{1[.!}]*}', 'g'); + actualmatch = string.match(pattern); +} +catch (e) +{ + pattern = 'error'; + actualmatch = ''; +} +expectedmatch = Array('{1}'); +addThis(); + + +string = 'abccccc{3 }c{ 3}c{3, }c{3 ,}c{3 ,4}c{3, 4}c{3,4 }de'; + +// use braces in a normal quantifier construct +status = inSection(5); +try +{ + pattern = new RegExp('c{3}'); + actualmatch = string.match(pattern); +} +catch (e) +{ + pattern = 'error'; + actualmatch = ''; +} +expectedmatch = Array('ccc'); +addThis(); + +// now disrupt the quantifer - the braces should now be interpreted literally +status = inSection(6); +try +{ + pattern = new RegExp('c{3 }'); + actualmatch = string.match(pattern); +} +catch (e) +{ + pattern = 'error'; + actualmatch = ''; +} +expectedmatch = Array('c{3 }'); +addThis(); + +status = inSection(7); +try +{ + pattern = new RegExp('c{3.}'); + actualmatch = string.match(pattern); +} +catch (e) +{ + pattern = 'error'; + actualmatch = ''; +} +expectedmatch = Array('c{3 }'); +addThis(); + +status = inSection(8); +try +{ + // need to escape the \ in \s since + // this has been converted to a constructor call + // instead of a literal regexp + pattern = new RegExp('c{3\\s}'); + actualmatch = string.match(pattern); +} +catch (e) +{ + pattern = 'error'; + actualmatch = ''; +} +expectedmatch = Array('c{3 }'); +addThis(); + +status = inSection(9); +try +{ + pattern = new RegExp('c{3[ ]}'); + actualmatch = string.match(pattern); +} +catch (e) +{ + pattern = 'error'; + actualmatch = ''; +} +expectedmatch = Array('c{3 }'); +addThis(); + +status = inSection(10); +try +{ + pattern = new RegExp('c{ 3}'); + actualmatch = string.match(pattern); +} +catch (e) +{ + pattern = 'error'; + actualmatch = ''; +} +expectedmatch = Array('c{ 3}'); +addThis(); + +// using braces in a normal quantifier construct again +status = inSection(11); +try +{ + pattern = new RegExp('c{3,}'); + actualmatch = string.match(pattern); +} +catch (e) +{ + pattern = 'error'; + actualmatch = ''; +} +expectedmatch = Array('ccccc'); +addThis(); + +// now disrupt it - the braces should now be interpreted literally +status = inSection(12); +try +{ + pattern = new RegExp('c{3, }'); + actualmatch = string.match(pattern); +} +catch (e) +{ + pattern = 'error'; + actualmatch = ''; +} +expectedmatch = Array('c{3, }'); +addThis(); + +status = inSection(13); +try +{ + pattern = new RegExp('c{3 ,}'); + actualmatch = string.match(pattern); +} +catch (e) +{ + pattern = 'error'; + actualmatch = ''; +} +expectedmatch = Array('c{3 ,}'); +addThis(); + +// using braces in a normal quantifier construct again +status = inSection(14); +try +{ + pattern = new RegExp('c{3,4}'); + actualmatch = string.match(pattern); +} +catch (e) +{ + pattern = 'error'; + actualmatch = ''; +} +expectedmatch = Array('cccc'); +addThis(); + +// now disrupt it - the braces should now be interpreted literally +status = inSection(15); +try +{ + pattern = new RegExp('c{3 ,4}'); + actualmatch = string.match(pattern); +} +catch (e) +{ + pattern = 'error'; + actualmatch = ''; +} +expectedmatch = Array('c{3 ,4}'); +addThis(); + +status = inSection(16); +try +{ + pattern = new RegExp('c{3, 4}'); + actualmatch = string.match(pattern); +} +catch (e) +{ + pattern = 'error'; + actualmatch = ''; +} +expectedmatch = Array('c{3, 4}'); +addThis(); + +status = inSection(17); +try +{ + pattern = new RegExp('c{3,4 }'); + actualmatch = string.match(pattern); +} +catch (e) +{ + pattern = 'error'; + actualmatch = ''; +} +expectedmatch = Array('c{3,4 }'); +addThis(); + + + + +//------------------------------------------------------------------------------------------------- +test(); +//------------------------------------------------------------------------------------------------- + + + +function addThis() +{ + statusmessages[i] = status; + patterns[i] = pattern; + strings[i] = string; + actualmatches[i] = actualmatch; + expectedmatches[i] = expectedmatch; + i++; +} + + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); +} diff --git a/js/src/tests/non262/extensions/regress-245148.js b/js/src/tests/non262/extensions/regress-245148.js new file mode 100644 index 0000000000..e291056f35 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-245148.js @@ -0,0 +1,20 @@ +// |reftest| skip-if(!Array.prototype.toSource) + +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 245148; +var summary = '[null].toSource() == "[null]"'; +var actual = ''; +var expect = ''; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +expect = '[null]'; +actual = [null].toSource(); + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/non262/extensions/regress-255245.js b/js/src/tests/non262/extensions/regress-255245.js new file mode 100644 index 0000000000..9d486fe962 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-255245.js @@ -0,0 +1,29 @@ +// |reftest| skip-if(!Function.prototype.toSource) + +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 255245; +var summary = 'Function.prototype.toSource/.toString show "setrval" instead of "return"'; +var actual = ''; +var expect = ''; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +function f() { + try { + } catch (e) { + return false; + } + finally { + } +} + +expect = -1; +actual = f.toSource().indexOf('setrval'); + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/non262/extensions/regress-274152.js b/js/src/tests/non262/extensions/regress-274152.js new file mode 100644 index 0000000000..0f3cd70e53 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-274152.js @@ -0,0 +1,48 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 274152; +var summary = 'Do not ignore unicode format-control characters'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = 'SyntaxError: illegal character'; + + var formatcontrolchars = ['\u200E', + '\u0600', + '\u0601', + '\u0602', + '\u0603', + '\u06DD', + '\u070F']; + + for (var i = 0; i < formatcontrolchars.length; i++) + { + var char = formatcontrolchars[i]; + + try + { + eval("hi" + char + "there = 'howdie';"); + } + catch(ex) + { + actual = ex + ''; + } + + var hex = char.codePointAt(0).toString(16).toUpperCase().padStart(4, '0'); + reportCompare(`${expect} U+${hex}`, actual, summary + ': ' + i); + } +} diff --git a/js/src/tests/non262/extensions/regress-300079.js b/js/src/tests/non262/extensions/regress-300079.js new file mode 100644 index 0000000000..d2a1090c09 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-300079.js @@ -0,0 +1,42 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 300079; +var summary = "precompiled functions should inherit from current window's Function.prototype"; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + if (typeof clone == 'undefined') { + expect = 'SKIPPED'; + actual = 'SKIPPED'; + } + else { + expect = 'PASSED'; + + f = evaluate("(function () { return a * a; })", {envChainObject: {a: 3}}); + gc(); + try { + a_squared = f(2); + if (a_squared != 9) + throw "Unexpected return from g: a_squared == " + a_squared; + actual = "PASSED"; + } catch (e) { + actual = "FAILED: " + e; + } + } + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-311161.js b/js/src/tests/non262/extensions/regress-311161.js new file mode 100644 index 0000000000..7f54f734eb --- /dev/null +++ b/js/src/tests/non262/extensions/regress-311161.js @@ -0,0 +1,1440 @@ +// |reftest| skip-if(!Object.prototype.toSource) + +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 311161; +var summary = 'toSource exposes random memory or crashes'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +printBugNumber(BUGNUMBER); +printStatus (summary); + + +var commands = + [{origCount:1, fun:(function anonymous() {allElements[2].style.background = "#fcd";})}, +{origCount:2, fun:(function anonymous() {allElements[9].style.width = "20em";})}, +{origCount:3, fun:(function anonymous() {allElements[4].style.width = "200%";})}, +{origCount:4, fun:(function anonymous() {allElements[6].style.clear = "right";})}, +{origCount:5, fun:(function anonymous() {allElements[8].style.visibility = "hidden";})}, +{origCount:6, fun:(function anonymous() {allElements[1].style.overflow = "visible";})}, +{origCount:7, fun:(function anonymous() {allElements[4].style.position = "fixed";})}, +{origCount:8, fun:(function anonymous() {allElements[10].style.display = "-moz-inline-box";})}, +{origCount:9, fun:(function anonymous() {allElements[10].style.overflow = "auto";})}, +{origCount:10, fun:(function anonymous() {allElements[11].style.color = "red";})}, +{origCount:11, fun:(function anonymous() {allElements[4].style.height = "2em";})}, +{origCount:12, fun:(function anonymous() {allElements[9].style.height = "100px";})}, +{origCount:13, fun:(function anonymous() {allElements[5].style['float'] = "none";})}, +{origCount:14, fun:(function anonymous() {allElements[9].style.color = "blue";})}, +{origCount:15, fun:(function anonymous() {allElements[2].style.clear = "right";})}, +{origCount:16, fun:(function anonymous() {allElements[1].style.height = "auto";})}, +{origCount:17, fun:(function anonymous() {allElements[0].style.overflow = "hidden";})}, +{origCount:18, fun:(function anonymous() {allElements[4].style.display = "table-row-group";})}, +{origCount:19, fun:(function anonymous() {allElements[4].style.overflow = "auto";})}, +{origCount:20, fun:(function anonymous() {allElements[7].style.height = "100px";})}, +{origCount:21, fun:(function anonymous() {allElements[5].style.color = "green";})}, +{origCount:22, fun:(function anonymous() {allElements[3].style.display = "-moz-grid-group";})}, +{origCount:23, fun:(function anonymous() {allElements[7].style['float'] = "none";})}, +{origCount:24, fun:(function anonymous() {allElements[10].style.position = "static";})}, +{origCount:25, fun:(function anonymous() {allElements[3].style['float'] = "none";})}, +{origCount:26, fun:(function anonymous() {allElements[4].style['float'] = "none";})}, +{origCount:27, fun:(function anonymous() {allElements[8].style['float'] = "none";})}, +{origCount:28, fun:(function anonymous() {allElements[5].style.visibility = "collapse";})}, +{origCount:29, fun:(function anonymous() {allElements[1].style.position = "static";})}, +{origCount:30, fun:(function anonymous() {allElements[2].style.color = "black";})}, +{origCount:31, fun:(function anonymous() {allElements[0].style.position = "fixed";})}, +{origCount:32, fun:(function anonymous() {allElements[0].style.display = "table-row-group";})}, +{origCount:33, fun:(function anonymous() {allElements[9].style.position = "relative";})}, +{origCount:34, fun:(function anonymous() {allElements[5].style.position = "static";})}, +{origCount:35, fun:(function anonymous() {allElements[6].style.background = "transparent";})}, +{origCount:36, fun:(function anonymous() {allElements[6].style.color = "blue";})}, +{origCount:37, fun:(function anonymous() {allElements[9].style.background = "url(http://www.google.com/images/logo_sm.gif)";})}, +{origCount:38, fun:(function anonymous() {allElements[8].style.display = "-moz-grid";})}, +{origCount:39, fun:(function anonymous() {allElements[9].style.color = "black";})}, +{origCount:40, fun:(function anonymous() {allElements[4].style.position = "static";})}, +{origCount:41, fun:(function anonymous() {allElements[10].style.height = "auto";})}, +{origCount:42, fun:(function anonymous() {allElements[9].style.color = "green";})}, +{origCount:43, fun:(function anonymous() {allElements[4].style.height = "auto";})}, +{origCount:44, fun:(function anonymous() {allElements[2].style.clear = "both";})}, +{origCount:45, fun:(function anonymous() {allElements[8].style.width = "1px";})}, +{origCount:46, fun:(function anonymous() {allElements[2].style.visibility = "visible";})}, +{origCount:47, fun:(function anonymous() {allElements[1].style.clear = "left";})}, +{origCount:48, fun:(function anonymous() {allElements[11].style.overflow = "auto";})}, +{origCount:49, fun:(function anonymous() {allElements[11].style['float'] = "left";})}, +{origCount:50, fun:(function anonymous() {allElements[8].style['float'] = "left";})}, +{origCount:51, fun:(function anonymous() {allElements[6].style.height = "10%";})}, +{origCount:52, fun:(function anonymous() {allElements[11].style.display = "-moz-inline-box";})}, +{origCount:53, fun:(function anonymous() {allElements[3].style.clear = "left";})}, +{origCount:54, fun:(function anonymous() {allElements[11].style.visibility = "hidden";})}, +{origCount:55, fun:(function anonymous() {allElements[4].style['float'] = "right";})}, +{origCount:56, fun:(function anonymous() {allElements[0].style.width = "1px";})}, +{origCount:57, fun:(function anonymous() {allElements[3].style.height = "200%";})}, +{origCount:58, fun:(function anonymous() {allElements[7].style.height = "10%";})}, +{origCount:59, fun:(function anonymous() {allElements[4].style.clear = "none";})}, +{origCount:60, fun:(function anonymous() {allElements[11].style['float'] = "none";})}, +{origCount:61, fun:(function anonymous() {allElements[9].style['float'] = "left";})}, +{origCount:62, fun:(function anonymous() {allElements[4].style.overflow = "scroll";})}, +{origCount:63, fun:(function anonymous() {allElements[12].style.height = "200%";})}, +{origCount:64, fun:(function anonymous() {allElements[2].style.color = "green";})}, +{origCount:65, fun:(function anonymous() {allElements[3].style['float'] = "none";})}, +{origCount:66, fun:(function anonymous() {allElements[10].style.background = "transparent";})}, +{origCount:67, fun:(function anonymous() {allElements[0].style.height = "auto";})}, +{origCount:68, fun:(function anonymous() {allElements[6].style.clear = "left";})}, +{origCount:69, fun:(function anonymous() {allElements[7].style.background = "url(http://www.google.com/images/logo_sm.gif)";})}, +{origCount:70, fun:(function anonymous() {allElements[8].style.display = "-moz-popup";})}, +{origCount:71, fun:(function anonymous() {allElements[2].style.height = "10%";})}, +{origCount:72, fun:(function anonymous() {allElements[7].style.display = "table-cell";})}, +{origCount:73, fun:(function anonymous() {allElements[3].style.background = "url(http://www.google.com/images/logo_sm.gif)";})}, +{origCount:74, fun:(function anonymous() {allElements[8].style.color = "red";})}, +{origCount:75, fun:(function anonymous() {allElements[1].style.overflow = "auto";})}, +{origCount:76, fun:(function anonymous() {allElements[1].style.background = "#fcd";})}, +{origCount:77, fun:(function anonymous() {allElements[0].style.color = "red";})}, +{origCount:78, fun:(function anonymous() {allElements[4].style.background = "#fcd";})}, +{origCount:79, fun:(function anonymous() {allElements[5].style.position = "static";})}, +{origCount:80, fun:(function anonymous() {allElements[8].style.clear = "both";})}, +{origCount:81, fun:(function anonymous() {allElements[7].style.clear = "both";})}, +{origCount:82, fun:(function anonymous() {allElements[5].style.clear = "both";})}, +{origCount:83, fun:(function anonymous() {allElements[10].style.display = "-moz-grid-group";})}, +{origCount:84, fun:(function anonymous() {allElements[12].style.clear = "right";})}, +{origCount:85, fun:(function anonymous() {allElements[5].style['float'] = "left";})}, +{origCount:86, fun:(function anonymous() {allElements[8].style.position = "absolute";})}, +{origCount:87, fun:(function anonymous() {allElements[11].style.background = "#fcd";})}, +{origCount:88, fun:(function anonymous() {allElements[9].style.position = "relative";})}, +{origCount:89, fun:(function anonymous() {allElements[5].style.width = "20em";})}, +{origCount:90, fun:(function anonymous() {allElements[6].style.position = "absolute";})}, +{origCount:91, fun:(function anonymous() {allElements[5].style.overflow = "scroll";})}, +{origCount:92, fun:(function anonymous() {allElements[6].style.background = "#fcd";})}, +{origCount:93, fun:(function anonymous() {allElements[2].style.visibility = "visible";})}, +{origCount:94, fun:(function anonymous() {allElements[11].style.background = "#fcd";})}, +{origCount:95, fun:(function anonymous() {allElements[0].style.visibility = "hidden";})}, +{origCount:96, fun:(function anonymous() {allElements[0].style.color = "blue";})}, +{origCount:97, fun:(function anonymous() {allElements[3].style['float'] = "left";})}, +{origCount:98, fun:(function anonymous() {allElements[3].style.height = "200%";})}, +{origCount:99, fun:(function anonymous() {allElements[4].style.background = "url(http://www.google.com/images/logo_sm.gif)";})}, +{origCount:100, fun:(function anonymous() {allElements[12].style.width = "10%";})}, +{origCount:101, fun:(function anonymous() {allElements[6].style.background = "url(http://www.google.com/images/logo_sm.gif)";})}, +{origCount:102, fun:(function anonymous() {allElements[5].style.width = "auto";})}, +{origCount:103, fun:(function anonymous() {allElements[1].style.position = "static";})}, +{origCount:104, fun:(function anonymous() {allElements[12].style['float'] = "right";})}, +{origCount:105, fun:(function anonymous() {allElements[5].style['float'] = "right";})}, +{origCount:106, fun:(function anonymous() {allElements[12].style.height = "200%";})}, +{origCount:107, fun:(function anonymous() {allElements[11].style['float'] = "none";})}, +{origCount:108, fun:(function anonymous() {allElements[9].style.width = "20em";})}, +{origCount:109, fun:(function anonymous() {allElements[10].style.background = "url(http://www.google.com/images/logo_sm.gif)";})}, +{origCount:110, fun:(function anonymous() {allElements[7].style['float'] = "none";})}, +{origCount:111, fun:(function anonymous() {allElements[6].style.visibility = "collapse";})}, +{origCount:112, fun:(function anonymous() {allElements[11].style.height = "200%";})}, +{origCount:113, fun:(function anonymous() {allElements[3].style.visibility = "visible";})}, +{origCount:114, fun:(function anonymous() {allElements[12].style.width = "200%";})}, +{origCount:115, fun:(function anonymous() {allElements[5].style.height = "10%";})}, +{origCount:116, fun:(function anonymous() {allElements[1].style['float'] = "left";})}, +{origCount:117, fun:(function anonymous() {allElements[5].style.overflow = "scroll";})}, +{origCount:118, fun:(function anonymous() {allElements[9].style.width = "10%";})}, +{origCount:119, fun:(function anonymous() {allElements[6].style.position = "static";})}, +{origCount:120, fun:(function anonymous() {allElements[1].style.background = "#fcd";})}, +{origCount:121, fun:(function anonymous() {allElements[12].style['float'] = "right";})}, +{origCount:122, fun:(function anonymous() {allElements[7].style.width = "1px";})}, +{origCount:123, fun:(function anonymous() {allElements[3].style.color = "blue";})}, +{origCount:124, fun:(function anonymous() {allElements[6].style.background = "#fcd";})}, +{origCount:125, fun:(function anonymous() {allElements[8].style.overflow = "auto";})}, +{origCount:126, fun:(function anonymous() {allElements[1].style.overflow = "auto";})}, +{origCount:127, fun:(function anonymous() {allElements[5].style['float'] = "none";})}, +{origCount:128, fun:(function anonymous() {allElements[12].style.color = "green";})}, +{origCount:129, fun:(function anonymous() {allElements[0].style.color = "black";})}, +{origCount:130, fun:(function anonymous() {allElements[1].style.position = "relative";})}, +{origCount:131, fun:(function anonymous() {allElements[9].style.overflow = "auto";})}, +{origCount:132, fun:(function anonymous() {allElements[1].style.display = "table-row";})}, +{origCount:133, fun:(function anonymous() {allElements[10].style['float'] = "right";})}, +{origCount:134, fun:(function anonymous() {allElements[2].style.visibility = "hidden";})}, +{origCount:135, fun:(function anonymous() {allElements[9].style.overflow = "auto";})}, +{origCount:136, fun:(function anonymous() {allElements[9].style.clear = "none";})}, +{origCount:137, fun:(function anonymous() {allElements[9].style.position = "absolute";})}, +{origCount:138, fun:(function anonymous() {allElements[0].style.width = "10%";})}, +{origCount:139, fun:(function anonymous() {allElements[1].style.height = "10%";})}, +{origCount:140, fun:(function anonymous() {allElements[5].style.height = "auto";})}, +{origCount:141, fun:(function anonymous() {allElements[4].style.position = "fixed";})}, +{origCount:142, fun:(function anonymous() {allElements[3].style.background = "url(http://www.google.com/images/logo_sm.gif)";})}, +{origCount:143, fun:(function anonymous() {allElements[7].style.display = "table-header-group";})}, +{origCount:144, fun:(function anonymous() {allElements[10].style.position = "fixed";})}, +{origCount:145, fun:(function anonymous() {allElements[4].style.background = "transparent";})}, +{origCount:146, fun:(function anonymous() {allElements[6].style.position = "relative";})}, +{origCount:147, fun:(function anonymous() {allElements[10].style.clear = "both";})}, +{origCount:148, fun:(function anonymous() {allElements[8].style.display = "table-header-group";})}, +{origCount:149, fun:(function anonymous() {allElements[5].style.height = "200%";})}, +{origCount:150, fun:(function anonymous() {allElements[7].style.height = "2em";})}, +{origCount:151, fun:(function anonymous() {allElements[6].style.position = "relative";})}, +{origCount:152, fun:(function anonymous() {allElements[7].style.height = "2em";})}, +{origCount:153, fun:(function anonymous() {allElements[3].style.width = "10%";})}, +{origCount:154, fun:(function anonymous() {allElements[12].style.color = "blue";})}, +{origCount:155, fun:(function anonymous() {allElements[2].style.color = "green";})}, +{origCount:156, fun:(function anonymous() {allElements[2].style.visibility = "visible";})}, +{origCount:157, fun:(function anonymous() {allElements[6].style['float'] = "right";})}, +{origCount:158, fun:(function anonymous() {allElements[6].style.visibility = "collapse";})}, +{origCount:159, fun:(function anonymous() {allElements[8].style.position = "absolute";})}, +{origCount:160, fun:(function anonymous() {allElements[3].style.height = "2em";})}, +{origCount:161, fun:(function anonymous() {allElements[10].style.display = "-moz-grid-line";})}, +{origCount:162, fun:(function anonymous() {allElements[9].style.color = "red";})}, +{origCount:163, fun:(function anonymous() {allElements[6].style.overflow = "hidden";})}, +{origCount:164, fun:(function anonymous() {allElements[4].style.overflow = "scroll";})}, +{origCount:165, fun:(function anonymous() {allElements[11].style.height = "100px";})}, +{origCount:166, fun:(function anonymous() {allElements[5].style.display = "table-footer-group";})}, +{origCount:167, fun:(function anonymous() {allElements[5].style.color = "red";})}, +{origCount:168, fun:(function anonymous() {allElements[3].style.width = "20em";})}, +{origCount:169, fun:(function anonymous() {allElements[4].style['float'] = "right";})}, +{origCount:170, fun:(function anonymous() {allElements[2].style.background = "transparent";})}, +{origCount:171, fun:(function anonymous() {allElements[0].style.position = "fixed";})}, +{origCount:172, fun:(function anonymous() {allElements[6].style.visibility = "hidden";})}, +{origCount:173, fun:(function anonymous() {allElements[11].style['float'] = "right";})}, +{origCount:174, fun:(function anonymous() {allElements[8].style.height = "200%";})}, +{origCount:175, fun:(function anonymous() {allElements[1].style.position = "relative";})}, +{origCount:176, fun:(function anonymous() {allElements[11].style.width = "auto";})}, +{origCount:177, fun:(function anonymous() {allElements[2].style.background = "#fcd";})}, +{origCount:178, fun:(function anonymous() {allElements[6].style.position = "absolute";})}, +{origCount:179, fun:(function anonymous() {allElements[3].style.position = "absolute";})}, +{origCount:180, fun:(function anonymous() {allElements[12].style['float'] = "right";})}, +{origCount:181, fun:(function anonymous() {allElements[11].style.background = "transparent";})}, +{origCount:182, fun:(function anonymous() {allElements[6].style.height = "200%";})}, +{origCount:183, fun:(function anonymous() {allElements[2].style['float'] = "none";})}, +{origCount:184, fun:(function anonymous() {allElements[5].style.position = "absolute";})}, +{origCount:185, fun:(function anonymous() {allElements[8].style.color = "blue";})}, +{origCount:186, fun:(function anonymous() {allElements[2].style['float'] = "left";})}, +{origCount:187, fun:(function anonymous() {allElements[6].style.height = "200%";})}, +{origCount:188, fun:(function anonymous() {allElements[0].style.width = "20em";})}, +{origCount:189, fun:(function anonymous() {allElements[1].style.display = "table-row-group";})}, +{origCount:190, fun:(function anonymous() {allElements[3].style.visibility = "hidden";})}, +{origCount:191, fun:(function anonymous() {allElements[11].style.width = "10%";})}, +{origCount:192, fun:(function anonymous() {allElements[4].style.width = "200%";})}, +{origCount:193, fun:(function anonymous() {allElements[0].style['float'] = "right";})}, +{origCount:194, fun:(function anonymous() {allElements[5].style.background = "#fcd";})}, +{origCount:195, fun:(function anonymous() {allElements[12].style.visibility = "hidden";})}, +{origCount:196, fun:(function anonymous() {allElements[0].style.display = "table-column";})}, +{origCount:197, fun:(function anonymous() {allElements[0].style.width = "auto";})}, +{origCount:198, fun:(function anonymous() {allElements[4].style.color = "green";})}, +{origCount:199, fun:(function anonymous() {allElements[6].style.clear = "none";})}, +{origCount:200, fun:(function anonymous() {allElements[10].style.overflow = "hidden";})}, +{origCount:201, fun:(function anonymous() {allElements[9].style.visibility = "collapse";})}, +{origCount:202, fun:(function anonymous() {allElements[9].style.height = "100px";})}, +{origCount:203, fun:(function anonymous() {allElements[1].style.width = "auto";})}, +{origCount:204, fun:(function anonymous() {allElements[4].style.position = "fixed";})}, +{origCount:205, fun:(function anonymous() {allElements[11].style['float'] = "none";})}, +{origCount:206, fun:(function anonymous() {allElements[1].style.clear = "right";})}, +{origCount:207, fun:(function anonymous() {allElements[5].style.display = "-moz-stack";})}, +{origCount:208, fun:(function anonymous() {allElements[3].style.color = "black";})}, +{origCount:209, fun:(function anonymous() {allElements[1].style.background = "transparent";})}, +{origCount:210, fun:(function anonymous() {allElements[3].style['float'] = "left";})}, +{origCount:211, fun:(function anonymous() {allElements[2].style.height = "2em";})}, +{origCount:212, fun:(function anonymous() {allElements[4].style.width = "auto";})}, +{origCount:213, fun:(function anonymous() {allElements[0].style['float'] = "none";})}, +{origCount:214, fun:(function anonymous() {allElements[10].style.display = "table-caption";})}, +{origCount:215, fun:(function anonymous() {allElements[0].style.overflow = "auto";})}, +{origCount:216, fun:(function anonymous() {allElements[0].style.color = "green";})}, +{origCount:217, fun:(function anonymous() {allElements[5].style.background = "#fcd";})}, +{origCount:218, fun:(function anonymous() {allElements[5].style.visibility = "hidden";})}, +{origCount:219, fun:(function anonymous() {allElements[7].style.width = "200%";})}, +{origCount:220, fun:(function anonymous() {allElements[2].style.background = "transparent";})}, +{origCount:221, fun:(function anonymous() {allElements[10].style.visibility = "hidden";})}, +{origCount:222, fun:(function anonymous() {allElements[10].style['float'] = "right";})}, +{origCount:223, fun:(function anonymous() {allElements[6].style.position = "absolute";})}, +{origCount:224, fun:(function anonymous() {allElements[5].style.background = "transparent";})}, +{origCount:225, fun:(function anonymous() {allElements[12].style.overflow = "hidden";})}, +{origCount:226, fun:(function anonymous() {allElements[7].style.clear = "left";})}, +{origCount:227, fun:(function anonymous() {allElements[7].style.height = "200%";})}, +{origCount:228, fun:(function anonymous() {allElements[5].style.position = "absolute";})}, +{origCount:229, fun:(function anonymous() {allElements[7].style['float'] = "none";})}, +{origCount:230, fun:(function anonymous() {allElements[5].style.clear = "both";})}, +{origCount:231, fun:(function anonymous() {allElements[4].style.clear = "left";})}, +{origCount:232, fun:(function anonymous() {allElements[10].style.position = "fixed";})}, +{origCount:233, fun:(function anonymous() {allElements[2].style.overflow = "scroll";})}, +{origCount:234, fun:(function anonymous() {allElements[12].style.background = "#fcd";})}, +{origCount:235, fun:(function anonymous() {allElements[6].style.color = "black";})}, +{origCount:236, fun:(function anonymous() {allElements[3].style.position = "absolute";})}, +{origCount:237, fun:(function anonymous() {allElements[8].style.color = "red";})}, +{origCount:238, fun:(function anonymous() {allElements[12].style.background = "transparent";})}, +{origCount:239, fun:(function anonymous() {allElements[10].style['float'] = "none";})}, +{origCount:240, fun:(function anonymous() {allElements[6].style['float'] = "right";})}, +{origCount:241, fun:(function anonymous() {allElements[5].style['float'] = "none";})}, +{origCount:242, fun:(function anonymous() {allElements[0].style.color = "red";})}, +{origCount:243, fun:(function anonymous() {allElements[10].style['float'] = "none";})}, +{origCount:244, fun:(function anonymous() {allElements[1].style.width = "1px";})}, +{origCount:245, fun:(function anonymous() {allElements[3].style.position = "fixed";})}, +{origCount:246, fun:(function anonymous() {allElements[11].style.clear = "left";})}, +{origCount:247, fun:(function anonymous() {allElements[2].style.position = "absolute";})}, +{origCount:248, fun:(function anonymous() {allElements[9].style.background = "#fcd";})}, +{origCount:249, fun:(function anonymous() {allElements[11].style.position = "relative";})}, +{origCount:250, fun:(function anonymous() {allElements[1].style.height = "100px";})}, +{origCount:251, fun:(function anonymous() {allElements[9].style.background = "transparent";})}, +{origCount:252, fun:(function anonymous() {allElements[2].style.display = "block";})}, +{origCount:253, fun:(function anonymous() {allElements[12].style.background = "#fcd";})}, +{origCount:254, fun:(function anonymous() {allElements[4].style.background = "url(http://www.google.com/images/logo_sm.gif)";})}, +{origCount:255, fun:(function anonymous() {allElements[12].style.color = "black";})}, +{origCount:256, fun:(function anonymous() {allElements[0].style.height = "auto";})}, +{origCount:257, fun:(function anonymous() {allElements[0].style.height = "100px";})}, +{origCount:258, fun:(function anonymous() {allElements[5].style.clear = "right";})}, +{origCount:259, fun:(function anonymous() {allElements[7].style.height = "100px";})}, +{origCount:260, fun:(function anonymous() {allElements[11].style.background = "transparent";})}, +{origCount:261, fun:(function anonymous() {allElements[11].style.width = "20em";})}, +{origCount:262, fun:(function anonymous() {allElements[10].style.width = "1px";})}, +{origCount:263, fun:(function anonymous() {allElements[3].style.clear = "left";})}, +{origCount:264, fun:(function anonymous() {allElements[7].style['float'] = "left";})}, +{origCount:265, fun:(function anonymous() {allElements[1].style['float'] = "none";})}, +{origCount:266, fun:(function anonymous() {allElements[4].style.overflow = "scroll";})}, +{origCount:267, fun:(function anonymous() {allElements[9].style.height = "auto";})}, +{origCount:268, fun:(function anonymous() {allElements[7].style.background = "transparent";})}, +{origCount:269, fun:(function anonymous() {allElements[5].style.display = "table";})}, +{origCount:270, fun:(function anonymous() {allElements[7].style.width = "200%";})}, +{origCount:271, fun:(function anonymous() {allElements[7].style.clear = "left";})}, +{origCount:272, fun:(function anonymous() {allElements[9].style.visibility = "hidden";})}, +{origCount:273, fun:(function anonymous() {allElements[6].style.height = "10%";})}, +{origCount:274, fun:(function anonymous() {allElements[3].style.position = "fixed";})}, +{origCount:275, fun:(function anonymous() {allElements[6].style.display = "block";})}, +{origCount:276, fun:(function anonymous() {allElements[7].style.overflow = "visible";})}, +{origCount:277, fun:(function anonymous() {allElements[12].style['float'] = "none";})}, +{origCount:278, fun:(function anonymous() {allElements[0].style['float'] = "none";})}, +{origCount:279, fun:(function anonymous() {allElements[2].style.height = "10%";})}, +{origCount:280, fun:(function anonymous() {allElements[11].style.clear = "right";})}, +{origCount:281, fun:(function anonymous() {allElements[6].style.clear = "both";})}, +{origCount:282, fun:(function anonymous() {allElements[6].style.display = "-moz-box";})}, +{origCount:283, fun:(function anonymous() {allElements[3].style.height = "100px";})}, +{origCount:284, fun:(function anonymous() {allElements[2].style.color = "blue";})}, +{origCount:285, fun:(function anonymous() {allElements[10].style.background = "url(http://www.google.com/images/logo_sm.gif)";})}, +{origCount:286, fun:(function anonymous() {allElements[4].style.background = "transparent";})}, +{origCount:287, fun:(function anonymous() {allElements[5].style.height = "auto";})}, +{origCount:288, fun:(function anonymous() {allElements[3].style.background = "url(http://www.google.com/images/logo_sm.gif)";})}, +{origCount:289, fun:(function anonymous() {allElements[5].style.background = "url(http://www.google.com/images/logo_sm.gif)";})}, +{origCount:290, fun:(function anonymous() {allElements[4].style.clear = "right";})}, +{origCount:291, fun:(function anonymous() {allElements[3].style.overflow = "auto";})}, +{origCount:292, fun:(function anonymous() {allElements[10].style.display = "-moz-stack";})}, +{origCount:293, fun:(function anonymous() {allElements[2].style.color = "red";})}, +{origCount:294, fun:(function anonymous() {allElements[0].style.display = "-moz-groupbox";})}, +{origCount:295, fun:(function anonymous() {allElements[7].style.position = "fixed";})}, +{origCount:296, fun:(function anonymous() {allElements[4].style.color = "green";})}, +{origCount:297, fun:(function anonymous() {allElements[9].style.display = "-moz-box";})}, +{origCount:298, fun:(function anonymous() {allElements[1].style.color = "green";})}, +{origCount:299, fun:(function anonymous() {allElements[12].style.visibility = "hidden";})}, +{origCount:300, fun:(function anonymous() {allElements[8].style.color = "red";})}, +{origCount:301, fun:(function anonymous() {allElements[8].style['float'] = "left";})}, +{origCount:302, fun:(function anonymous() {allElements[3].style.height = "2em";})}, +{origCount:303, fun:(function anonymous() {allElements[1].style.width = "auto";})}, +{origCount:304, fun:(function anonymous() {allElements[4].style.height = "10%";})}, +{origCount:305, fun:(function anonymous() {allElements[8].style.width = "20em";})}, +{origCount:306, fun:(function anonymous() {allElements[2].style.height = "2em";})}, +{origCount:307, fun:(function anonymous() {allElements[7].style.color = "red";})}, +{origCount:308, fun:(function anonymous() {allElements[2].style.display = "-moz-inline-box";})}, +{origCount:309, fun:(function anonymous() {allElements[4].style.visibility = "visible";})}, +{origCount:310, fun:(function anonymous() {allElements[7].style.display = "-moz-deck";})}, +{origCount:311, fun:(function anonymous() {allElements[2].style.visibility = "hidden";})}, +{origCount:312, fun:(function anonymous() {allElements[9].style.clear = "both";})}, +{origCount:313, fun:(function anonymous() {allElements[6].style['float'] = "left";})}, +{origCount:314, fun:(function anonymous() {allElements[12].style.position = "static";})}, +{origCount:315, fun:(function anonymous() {allElements[6].style.background = "url(http://www.google.com/images/logo_sm.gif)";})}, +{origCount:316, fun:(function anonymous() {allElements[8].style.visibility = "visible";})}, +{origCount:317, fun:(function anonymous() {allElements[8].style.background = "#fcd";})}, +{origCount:318, fun:(function anonymous() {allElements[1].style.visibility = "collapse";})}, +{origCount:319, fun:(function anonymous() {allElements[3].style.position = "static";})}, +{origCount:320, fun:(function anonymous() {allElements[8].style.overflow = "hidden";})}, +{origCount:321, fun:(function anonymous() {allElements[8].style.clear = "left";})}, +{origCount:322, fun:(function anonymous() {allElements[8].style.position = "static";})}, +{origCount:323, fun:(function anonymous() {allElements[1].style['float'] = "none";})}, +{origCount:324, fun:(function anonymous() {allElements[5].style.visibility = "hidden";})}, +{origCount:325, fun:(function anonymous() {allElements[12].style.background = "url(http://www.google.com/images/logo_sm.gif)";})}, +{origCount:326, fun:(function anonymous() {allElements[3].style.overflow = "visible";})}, +{origCount:327, fun:(function anonymous() {allElements[8].style.visibility = "collapse";})}, +{origCount:328, fun:(function anonymous() {allElements[7].style.position = "static";})}, +{origCount:329, fun:(function anonymous() {allElements[5].style.visibility = "collapse";})}, +{origCount:330, fun:(function anonymous() {allElements[8].style.visibility = "visible";})}, +{origCount:331, fun:(function anonymous() {allElements[8].style.height = "auto";})}, +{origCount:332, fun:(function anonymous() {allElements[10].style.overflow = "scroll";})}, +{origCount:333, fun:(function anonymous() {allElements[7].style.overflow = "visible";})}, +{origCount:334, fun:(function anonymous() {allElements[5].style.visibility = "visible";})}, +{origCount:335, fun:(function anonymous() {allElements[8].style.position = "fixed";})}, +{origCount:336, fun:(function anonymous() {allElements[10].style.display = "-moz-grid-line";})}, +{origCount:337, fun:(function anonymous() {allElements[2].style['float'] = "left";})}, +{origCount:338, fun:(function anonymous() {allElements[3].style.position = "absolute";})}, +{origCount:339, fun:(function anonymous() {allElements[5].style.color = "green";})}, +{origCount:340, fun:(function anonymous() {allElements[2].style.display = "-moz-groupbox";})}, +{origCount:341, fun:(function anonymous() {allElements[10].style.overflow = "auto";})}, +{origCount:342, fun:(function anonymous() {allElements[10].style['float'] = "left";})}, +{origCount:343, fun:(function anonymous() {allElements[8].style.clear = "both";})}, +{origCount:344, fun:(function anonymous() {allElements[8].style.clear = "right";})}, +{origCount:345, fun:(function anonymous() {allElements[2].style.color = "blue";})}, +{origCount:346, fun:(function anonymous() {allElements[10].style.height = "10%";})}, +{origCount:347, fun:(function anonymous() {allElements[11].style.overflow = "hidden";})}, +{origCount:348, fun:(function anonymous() {allElements[10].style.background = "url(http://www.google.com/images/logo_sm.gif)";})}, +{origCount:349, fun:(function anonymous() {allElements[0].style['float'] = "left";})}, +{origCount:350, fun:(function anonymous() {allElements[11].style.width = "10%";})}, +{origCount:351, fun:(function anonymous() {allElements[11].style.overflow = "hidden";})}, +{origCount:352, fun:(function anonymous() {allElements[5].style.color = "green";})}, +{origCount:353, fun:(function anonymous() {allElements[11].style.position = "relative";})}, +{origCount:354, fun:(function anonymous() {allElements[9].style.position = "static";})}, +{origCount:355, fun:(function anonymous() {allElements[4].style.height = "10%";})}, +{origCount:356, fun:(function anonymous() {allElements[1].style.position = "fixed";})}, +{origCount:357, fun:(function anonymous() {allElements[6].style.position = "fixed";})}, +{origCount:358, fun:(function anonymous() {allElements[12].style.display = "block";})}, +{origCount:359, fun:(function anonymous() {allElements[10].style.display = "-moz-inline-block";})}, +{origCount:360, fun:(function anonymous() {allElements[6].style.height = "100px";})}, +{origCount:361, fun:(function anonymous() {allElements[6].style.background = "url(http://www.google.com/images/logo_sm.gif)";})}, +{origCount:362, fun:(function anonymous() {allElements[2].style['float'] = "right";})}, +{origCount:363, fun:(function anonymous() {allElements[0].style.display = "-moz-grid-group";})}, +{origCount:364, fun:(function anonymous() {allElements[4].style.background = "#fcd";})}, +{origCount:365, fun:(function anonymous() {allElements[8].style['float'] = "none";})}, +{origCount:366, fun:(function anonymous() {allElements[3].style.position = "relative";})}, +{origCount:367, fun:(function anonymous() {allElements[8].style.position = "static";})}, +{origCount:368, fun:(function anonymous() {allElements[3].style.position = "relative";})}, +{origCount:369, fun:(function anonymous() {allElements[5].style.width = "auto";})}, +{origCount:370, fun:(function anonymous() {allElements[8].style.clear = "none";})}, +{origCount:371, fun:(function anonymous() {allElements[4].style.color = "red";})}, +{origCount:372, fun:(function anonymous() {allElements[11].style.width = "auto";})}, +{origCount:373, fun:(function anonymous() {allElements[9].style['float'] = "right";})}, +{origCount:374, fun:(function anonymous() {allElements[2].style.width = "20em";})}, +{origCount:375, fun:(function anonymous() {allElements[10].style.position = "relative";})}, +{origCount:376, fun:(function anonymous() {allElements[12].style.position = "relative";})}, +{origCount:377, fun:(function anonymous() {allElements[0].style.display = "-moz-grid";})}, +{origCount:378, fun:(function anonymous() {allElements[5].style.clear = "left";})}, +{origCount:379, fun:(function anonymous() {allElements[8].style.color = "green";})}, +{origCount:380, fun:(function anonymous() {allElements[0].style.clear = "both";})}, +{origCount:381, fun:(function anonymous() {allElements[0].style['float'] = "left";})}, +{origCount:382, fun:(function anonymous() {allElements[1].style.background = "#fcd";})}, +{origCount:383, fun:(function anonymous() {allElements[7].style.background = "url(http://www.google.com/images/logo_sm.gif)";})}, +{origCount:384, fun:(function anonymous() {allElements[12].style.visibility = "hidden";})}, +{origCount:385, fun:(function anonymous() {allElements[7].style['float'] = "right";})}, +{origCount:386, fun:(function anonymous() {allElements[11].style.display = "table-row";})}, +{origCount:387, fun:(function anonymous() {allElements[3].style.position = "absolute";})}, +{origCount:388, fun:(function anonymous() {allElements[2].style.height = "200%";})}, +{origCount:389, fun:(function anonymous() {allElements[1].style.clear = "none";})}, +{origCount:390, fun:(function anonymous() {allElements[4].style.position = "static";})}, +{origCount:391, fun:(function anonymous() {allElements[4].style.position = "relative";})}, +{origCount:392, fun:(function anonymous() {allElements[7].style.position = "fixed";})}, +{origCount:393, fun:(function anonymous() {allElements[4].style.background = "transparent";})}, +{origCount:394, fun:(function anonymous() {allElements[2].style.height = "200%";})}, +{origCount:395, fun:(function anonymous() {allElements[6].style.position = "relative";})}, +{origCount:396, fun:(function anonymous() {allElements[8].style.overflow = "auto";})}, +{origCount:397, fun:(function anonymous() {allElements[0].style.background = "transparent";})}, +{origCount:398, fun:(function anonymous() {allElements[2].style.position = "static";})}, +{origCount:399, fun:(function anonymous() {allElements[4].style['float'] = "none";})}, +{origCount:400, fun:(function anonymous() {allElements[1].style.height = "200%";})}, +{origCount:401, fun:(function anonymous() {allElements[10].style.color = "green";})}, +{origCount:402, fun:(function anonymous() {allElements[11].style.overflow = "hidden";})}, +{origCount:403, fun:(function anonymous() {allElements[8].style.height = "200%";})}, +{origCount:404, fun:(function anonymous() {allElements[9].style.visibility = "hidden";})}, +{origCount:405, fun:(function anonymous() {allElements[4].style.display = "block";})}, +{origCount:406, fun:(function anonymous() {allElements[12].style.height = "200%";})}, +{origCount:407, fun:(function anonymous() {allElements[0].style.width = "auto";})}, +{origCount:408, fun:(function anonymous() {allElements[0].style.position = "static";})}, +{origCount:409, fun:(function anonymous() {allElements[2].style['float'] = "right";})}, +{origCount:410, fun:(function anonymous() {allElements[1].style.display = "-moz-grid-group";})}, +{origCount:411, fun:(function anonymous() {allElements[2].style.visibility = "hidden";})}, +{origCount:412, fun:(function anonymous() {allElements[9].style.background = "url(http://www.google.com/images/logo_sm.gif)";})}, +{origCount:413, fun:(function anonymous() {allElements[2].style.width = "auto";})}, +{origCount:414, fun:(function anonymous() {allElements[0].style.display = "-moz-inline-box";})}, +{origCount:415, fun:(function anonymous() {allElements[9].style.clear = "none";})}, +{origCount:416, fun:(function anonymous() {allElements[6].style['float'] = "none";})}, +{origCount:417, fun:(function anonymous() {allElements[12].style.visibility = "hidden";})}, +{origCount:418, fun:(function anonymous() {allElements[5].style.position = "absolute";})}, +{origCount:419, fun:(function anonymous() {allElements[3].style.width = "1px";})}, +{origCount:420, fun:(function anonymous() {allElements[0].style.height = "2em";})}, +{origCount:421, fun:(function anonymous() {allElements[0].style['float'] = "right";})}, +{origCount:422, fun:(function anonymous() {allElements[10].style.background = "url(http://www.google.com/images/logo_sm.gif)";})}, +{origCount:423, fun:(function anonymous() {allElements[8].style.display = "-moz-inline-box";})}, +{origCount:424, fun:(function anonymous() {allElements[12].style.clear = "none";})}, +{origCount:425, fun:(function anonymous() {allElements[3].style.background = "transparent";})}, +{origCount:426, fun:(function anonymous() {allElements[12].style.overflow = "scroll";})}, +{origCount:427, fun:(function anonymous() {allElements[4].style.height = "200%";})}, +{origCount:428, fun:(function anonymous() {allElements[12].style.visibility = "collapse";})}, +{origCount:429, fun:(function anonymous() {allElements[2].style.clear = "right";})}, +{origCount:430, fun:(function anonymous() {allElements[6].style.background = "url(http://www.google.com/images/logo_sm.gif)";})}, +{origCount:431, fun:(function anonymous() {allElements[2].style.color = "blue";})}, +{origCount:432, fun:(function anonymous() {allElements[9].style.clear = "right";})}, +{origCount:433, fun:(function anonymous() {allElements[7].style.background = "transparent";})}, +{origCount:434, fun:(function anonymous() {allElements[1].style.width = "10%";})}, +{origCount:435, fun:(function anonymous() {allElements[9].style.width = "10%";})}, +{origCount:436, fun:(function anonymous() {allElements[11].style.display = "table-column-group";})}, +{origCount:437, fun:(function anonymous() {allElements[0].style.visibility = "visible";})}, +{origCount:438, fun:(function anonymous() {allElements[6].style.color = "black";})}, +{origCount:439, fun:(function anonymous() {allElements[9].style.position = "relative";})}, +{origCount:440, fun:(function anonymous() {allElements[1].style.visibility = "hidden";})}, +{origCount:441, fun:(function anonymous() {allElements[2].style.overflow = "hidden";})}, +{origCount:442, fun:(function anonymous() {allElements[3].style.color = "black";})}, +{origCount:443, fun:(function anonymous() {allElements[9].style.height = "200%";})}, +{origCount:444, fun:(function anonymous() {allElements[1].style.height = "200%";})}, +{origCount:445, fun:(function anonymous() {allElements[9].style['float'] = "right";})}, +{origCount:446, fun:(function anonymous() {allElements[1].style.color = "green";})}, +{origCount:447, fun:(function anonymous() {allElements[6].style.clear = "left";})}, +{origCount:448, fun:(function anonymous() {allElements[6].style.height = "2em";})}, +{origCount:449, fun:(function anonymous() {allElements[5].style.overflow = "visible";})}, +{origCount:450, fun:(function anonymous() {allElements[8].style.visibility = "collapse";})}, +{origCount:451, fun:(function anonymous() {allElements[9].style.color = "blue";})}, +{origCount:452, fun:(function anonymous() {allElements[12].style.height = "200%";})}, +{origCount:453, fun:(function anonymous() {allElements[10].style.color = "red";})}, +{origCount:454, fun:(function anonymous() {allElements[8].style.display = "table-cell";})}, +{origCount:455, fun:(function anonymous() {allElements[12].style['float'] = "right";})}, +{origCount:456, fun:(function anonymous() {allElements[2].style.overflow = "auto";})}, +{origCount:457, fun:(function anonymous() {allElements[7].style['float'] = "none";})}, +{origCount:458, fun:(function anonymous() {allElements[9].style.clear = "left";})}, +{origCount:459, fun:(function anonymous() {allElements[12].style.clear = "right";})}, +{origCount:460, fun:(function anonymous() {allElements[9].style.position = "absolute";})}, +{origCount:461, fun:(function anonymous() {allElements[6].style.position = "fixed";})}, +{origCount:462, fun:(function anonymous() {allElements[7].style.color = "blue";})}, +{origCount:463, fun:(function anonymous() {allElements[5].style.position = "absolute";})}, +{origCount:464, fun:(function anonymous() {allElements[5].style.display = "-moz-popup";})}, +{origCount:465, fun:(function anonymous() {allElements[1].style.position = "static";})}, +{origCount:466, fun:(function anonymous() {allElements[9].style.position = "absolute";})}, +{origCount:467, fun:(function anonymous() {allElements[11].style.background = "transparent";})}, +{origCount:468, fun:(function anonymous() {allElements[11].style.background = "#fcd";})}, +{origCount:469, fun:(function anonymous() {allElements[1].style.background = "#fcd";})}, +{origCount:470, fun:(function anonymous() {allElements[0].style.display = "table-row";})}, +{origCount:471, fun:(function anonymous() {allElements[1].style.background = "#fcd";})}, +{origCount:472, fun:(function anonymous() {allElements[8].style.position = "fixed";})}, +{origCount:473, fun:(function anonymous() {allElements[2].style['float'] = "left";})}, +{origCount:474, fun:(function anonymous() {allElements[1].style.color = "red";})}, +{origCount:475, fun:(function anonymous() {allElements[9].style.height = "2em";})}, +{origCount:476, fun:(function anonymous() {allElements[7].style.display = "-moz-grid";})}, +{origCount:477, fun:(function anonymous() {allElements[0].style.height = "2em";})}, +{origCount:478, fun:(function anonymous() {allElements[6].style.position = "absolute";})}, +{origCount:479, fun:(function anonymous() {allElements[5].style.clear = "none";})}, +{origCount:480, fun:(function anonymous() {allElements[3].style.overflow = "hidden";})}, +{origCount:481, fun:(function anonymous() {allElements[3].style['float'] = "none";})}, +{origCount:482, fun:(function anonymous() {allElements[0].style['float'] = "none";})}, +{origCount:483, fun:(function anonymous() {allElements[11].style.height = "100px";})}, +{origCount:484, fun:(function anonymous() {allElements[3].style.display = "-moz-inline-box";})}, +{origCount:485, fun:(function anonymous() {allElements[7].style.display = "block";})}, +{origCount:486, fun:(function anonymous() {allElements[3].style.visibility = "visible";})}, +{origCount:487, fun:(function anonymous() {allElements[9].style.clear = "left";})}, +{origCount:488, fun:(function anonymous() {allElements[5].style.width = "200%";})}, +{origCount:489, fun:(function anonymous() {allElements[8].style['float'] = "right";})}, +{origCount:490, fun:(function anonymous() {allElements[12].style.height = "100px";})}, +{origCount:491, fun:(function anonymous() {allElements[8].style.display = "-moz-deck";})}, +{origCount:492, fun:(function anonymous() {allElements[3].style.clear = "right";})}, +{origCount:493, fun:(function anonymous() {allElements[1].style['float'] = "none";})}, +{origCount:494, fun:(function anonymous() {allElements[8].style.overflow = "visible";})}, +{origCount:495, fun:(function anonymous() {allElements[4].style.height = "10%";})}, +{origCount:496, fun:(function anonymous() {allElements[7].style.color = "red";})}, +{origCount:497, fun:(function anonymous() {allElements[8].style.clear = "right";})}, +{origCount:498, fun:(function anonymous() {allElements[2].style.background = "url(http://www.google.com/images/logo_sm.gif)";})}, +{origCount:499, fun:(function anonymous() {allElements[5].style.height = "100px";})}, +{origCount:500, fun:(function anonymous() {allElements[11].style.clear = "none";})}, +{origCount:501, fun:(function anonymous() {allElements[12].style.background = "url(http://www.google.com/images/logo_sm.gif)";})}, +{origCount:502, fun:(function anonymous() {allElements[0].style.display = "-moz-grid";})}, +{origCount:503, fun:(function anonymous() {allElements[7].style.height = "100px";})}, +{origCount:504, fun:(function anonymous() {allElements[12].style.visibility = "visible";})}, +{origCount:505, fun:(function anonymous() {allElements[8].style.background = "#fcd";})}, +{origCount:506, fun:(function anonymous() {allElements[0].style.color = "black";})}, +{origCount:507, fun:(function anonymous() {allElements[6].style.overflow = "hidden";})}, +{origCount:508, fun:(function anonymous() {allElements[6].style.background = "transparent";})}, +{origCount:509, fun:(function anonymous() {allElements[5].style.color = "black";})}, +{origCount:510, fun:(function anonymous() {allElements[9].style.background = "transparent";})}, +{origCount:511, fun:(function anonymous() {allElements[10].style.position = "fixed";})}, +{origCount:512, fun:(function anonymous() {allElements[0].style.clear = "right";})}, +{origCount:513, fun:(function anonymous() {allElements[11].style.display = "table-caption";})}, +{origCount:514, fun:(function anonymous() {allElements[10].style.clear = "right";})}, +{origCount:515, fun:(function anonymous() {allElements[1].style.visibility = "hidden";})}, +{origCount:516, fun:(function anonymous() {allElements[4].style.clear = "left";})}, +{origCount:517, fun:(function anonymous() {allElements[10].style['float'] = "none";})}, +{origCount:518, fun:(function anonymous() {allElements[12].style.overflow = "scroll";})}, +{origCount:519, fun:(function anonymous() {allElements[3].style.width = "1px";})}, +{origCount:520, fun:(function anonymous() {allElements[0].style.position = "fixed";})}, +{origCount:521, fun:(function anonymous() {allElements[10].style.height = "200%";})}, +{origCount:522, fun:(function anonymous() {allElements[11].style.position = "relative";})}, +{origCount:523, fun:(function anonymous() {allElements[10].style.color = "black";})}, +{origCount:524, fun:(function anonymous() {allElements[11].style.background = "transparent";})}, +{origCount:525, fun:(function anonymous() {allElements[6].style.visibility = "collapse";})}, +{origCount:526, fun:(function anonymous() {allElements[3].style.background = "transparent";})}, +{origCount:527, fun:(function anonymous() {allElements[4].style.visibility = "visible";})}, +{origCount:528, fun:(function anonymous() {allElements[5].style.background = "transparent";})}, +{origCount:529, fun:(function anonymous() {allElements[8].style['float'] = "none";})}, +{origCount:530, fun:(function anonymous() {allElements[8].style.height = "auto";})}, +{origCount:531, fun:(function anonymous() {allElements[9].style.background = "#fcd";})}, +{origCount:532, fun:(function anonymous() {allElements[4].style.height = "auto";})}, +{origCount:533, fun:(function anonymous() {allElements[11].style.background = "#fcd";})}, +{origCount:534, fun:(function anonymous() {allElements[10].style.width = "20em";})}, +{origCount:535, fun:(function anonymous() {allElements[6].style.position = "fixed";})}, +{origCount:536, fun:(function anonymous() {allElements[4].style['float'] = "left";})}, +{origCount:537, fun:(function anonymous() {allElements[10].style.clear = "none";})}, +{origCount:538, fun:(function anonymous() {allElements[4].style.height = "auto";})}, +{origCount:539, fun:(function anonymous() {allElements[3].style.clear = "right";})}, +{origCount:540, fun:(function anonymous() {allElements[1].style.width = "200%";})}, +{origCount:541, fun:(function anonymous() {allElements[2].style.background = "url(http://www.google.com/images/logo_sm.gif)";})}, +{origCount:542, fun:(function anonymous() {allElements[12].style.clear = "left";})}, +{origCount:543, fun:(function anonymous() {allElements[10].style.visibility = "hidden";})}, +{origCount:544, fun:(function anonymous() {allElements[3].style.height = "auto";})}, +{origCount:545, fun:(function anonymous() {allElements[7].style.visibility = "collapse";})}, +{origCount:546, fun:(function anonymous() {allElements[4].style.width = "auto";})}, +{origCount:547, fun:(function anonymous() {allElements[10].style.height = "auto";})}, +{origCount:548, fun:(function anonymous() {allElements[6].style['float'] = "none";})}, +{origCount:549, fun:(function anonymous() {allElements[10].style.overflow = "auto";})}, +{origCount:550, fun:(function anonymous() {allElements[1].style.height = "auto";})}, +{origCount:551, fun:(function anonymous() {allElements[11].style.overflow = "hidden";})}, +{origCount:552, fun:(function anonymous() {allElements[6].style.background = "transparent";})}, +{origCount:553, fun:(function anonymous() {allElements[4].style['float'] = "left";})}, +{origCount:554, fun:(function anonymous() {allElements[12].style.height = "200%";})}, +{origCount:555, fun:(function anonymous() {allElements[8].style.color = "green";})}, +{origCount:556, fun:(function anonymous() {allElements[10].style.background = "#fcd";})}, +{origCount:557, fun:(function anonymous() {allElements[0].style.overflow = "hidden";})}, +{origCount:558, fun:(function anonymous() {allElements[6].style.overflow = "hidden";})}, +{origCount:559, fun:(function anonymous() {allElements[10].style.clear = "right";})}, +{origCount:560, fun:(function anonymous() {allElements[3].style.background = "transparent";})}, +{origCount:561, fun:(function anonymous() {allElements[5].style.color = "green";})}, +{origCount:562, fun:(function anonymous() {allElements[6].style.position = "static";})}, +{origCount:563, fun:(function anonymous() {allElements[1].style.overflow = "hidden";})}, +{origCount:564, fun:(function anonymous() {allElements[6].style.display = "inline";})}, +{origCount:565, fun:(function anonymous() {allElements[2].style['float'] = "left";})}, +{origCount:566, fun:(function anonymous() {allElements[7].style.visibility = "visible";})}, +{origCount:567, fun:(function anonymous() {allElements[1].style.color = "blue";})}, +{origCount:568, fun:(function anonymous() {allElements[1].style.clear = "both";})}, +{origCount:569, fun:(function anonymous() {allElements[0].style.position = "relative";})}, +{origCount:570, fun:(function anonymous() {allElements[5].style.height = "100px";})}, +{origCount:571, fun:(function anonymous() {allElements[6].style.height = "auto";})}, +{origCount:572, fun:(function anonymous() {allElements[10].style['float'] = "left";})}, +{origCount:573, fun:(function anonymous() {allElements[8].style.position = "absolute";})}, +{origCount:574, fun:(function anonymous() {allElements[7].style.background = "#fcd";})}, +{origCount:575, fun:(function anonymous() {allElements[12].style.display = "-moz-popup";})}, +{origCount:576, fun:(function anonymous() {allElements[2].style.position = "absolute";})}, +{origCount:577, fun:(function anonymous() {allElements[9].style.background = "url(http://www.google.com/images/logo_sm.gif)";})}, +{origCount:578, fun:(function anonymous() {allElements[11].style.overflow = "visible";})}, +{origCount:579, fun:(function anonymous() {allElements[2].style.display = "-moz-inline-box";})}, +{origCount:580, fun:(function anonymous() {allElements[0].style.display = "-moz-popup";})}, +{origCount:581, fun:(function anonymous() {allElements[10].style['float'] = "right";})}, +{origCount:582, fun:(function anonymous() {allElements[12].style.height = "10%";})}, +{origCount:583, fun:(function anonymous() {allElements[10].style.position = "static";})}, +{origCount:584, fun:(function anonymous() {allElements[12].style.height = "200%";})}, +{origCount:585, fun:(function anonymous() {allElements[8].style.height = "auto";})}, +{origCount:586, fun:(function anonymous() {allElements[4].style.color = "green";})}, +{origCount:587, fun:(function anonymous() {allElements[7].style.color = "red";})}, +{origCount:588, fun:(function anonymous() {allElements[7].style.visibility = "collapse";})}, +{origCount:589, fun:(function anonymous() {allElements[11].style['float'] = "left";})}, +{origCount:590, fun:(function anonymous() {allElements[11].style.visibility = "hidden";})}, +{origCount:591, fun:(function anonymous() {allElements[12].style.overflow = "visible";})}, +{origCount:592, fun:(function anonymous() {allElements[8].style['float'] = "none";})}, +{origCount:593, fun:(function anonymous() {allElements[2].style.display = "table-cell";})}, +{origCount:594, fun:(function anonymous() {allElements[1].style.color = "black";})}, +{origCount:595, fun:(function anonymous() {allElements[11].style.color = "green";})}, +{origCount:596, fun:(function anonymous() {allElements[9].style.color = "red";})}, +{origCount:597, fun:(function anonymous() {allElements[3].style['float'] = "none";})}, +{origCount:598, fun:(function anonymous() {allElements[10].style.display = "inline";})}, +{origCount:599, fun:(function anonymous() {allElements[10].style.background = "url(http://www.google.com/images/logo_sm.gif)";})}, +{origCount:600, fun:(function anonymous() {allElements[7].style.width = "10%";})}, +{origCount:601, fun:(function anonymous() {allElements[9].style['float'] = "left";})}, +{origCount:602, fun:(function anonymous() {allElements[6].style.width = "10%";})}, +{origCount:603, fun:(function anonymous() {allElements[5].style.position = "absolute";})}, +{origCount:604, fun:(function anonymous() {allElements[11].style.position = "static";})}, +{origCount:605, fun:(function anonymous() {allElements[3].style.clear = "none";})}, +{origCount:606, fun:(function anonymous() {allElements[0].style['float'] = "right";})}, +{origCount:607, fun:(function anonymous() {allElements[6].style.position = "static";})}, +{origCount:608, fun:(function anonymous() {allElements[3].style.height = "2em";})}, +{origCount:609, fun:(function anonymous() {allElements[7].style.width = "20em";})}, +{origCount:610, fun:(function anonymous() {allElements[11].style.overflow = "scroll";})}, +{origCount:611, fun:(function anonymous() {allElements[8].style.position = "relative";})}, +{origCount:612, fun:(function anonymous() {allElements[4].style['float'] = "left";})}, +{origCount:613, fun:(function anonymous() {allElements[3].style.background = "url(http://www.google.com/images/logo_sm.gif)";})}, +{origCount:614, fun:(function anonymous() {allElements[11].style.height = "auto";})}, +{origCount:615, fun:(function anonymous() {allElements[7].style['float'] = "right";})}, +{origCount:616, fun:(function anonymous() {allElements[10].style.overflow = "scroll";})}, +{origCount:617, fun:(function anonymous() {allElements[0].style.color = "green";})}, +{origCount:618, fun:(function anonymous() {allElements[7].style['float'] = "none";})}, +{origCount:619, fun:(function anonymous() {allElements[11].style.height = "10%";})}, +{origCount:620, fun:(function anonymous() {allElements[4].style.height = "200%";})}, +{origCount:621, fun:(function anonymous() {allElements[6].style.display = "-moz-popup";})}, +{origCount:622, fun:(function anonymous() {allElements[8].style.position = "relative";})}, +{origCount:623, fun:(function anonymous() {allElements[3].style.width = "1px";})}, +{origCount:624, fun:(function anonymous() {allElements[8].style.height = "auto";})}, +{origCount:625, fun:(function anonymous() {allElements[5].style['float'] = "right";})}, +{origCount:626, fun:(function anonymous() {allElements[10].style.background = "transparent";})}, +{origCount:627, fun:(function anonymous() {allElements[4].style.visibility = "visible";})}, +{origCount:628, fun:(function anonymous() {allElements[5].style.display = "list-item";})}, +{origCount:629, fun:(function anonymous() {allElements[5].style.height = "100px";})}, +{origCount:630, fun:(function anonymous() {allElements[9].style.background = "transparent";})}, +{origCount:631, fun:(function anonymous() {allElements[11].style.clear = "both";})}, +{origCount:632, fun:(function anonymous() {allElements[2].style.overflow = "visible";})}, +{origCount:633, fun:(function anonymous() {allElements[1].style.visibility = "hidden";})}, +{origCount:634, fun:(function anonymous() {allElements[1].style['float'] = "none";})}, +{origCount:635, fun:(function anonymous() {allElements[6].style.height = "2em";})}, +{origCount:636, fun:(function anonymous() {allElements[9].style.position = "relative";})}, +{origCount:637, fun:(function anonymous() {allElements[3].style.clear = "left";})}, +{origCount:638, fun:(function anonymous() {allElements[6].style.display = "table-header-group";})}, +{origCount:639, fun:(function anonymous() {allElements[10].style.display = "-moz-box";})}, +{origCount:640, fun:(function anonymous() {allElements[8].style.color = "blue";})}, +{origCount:641, fun:(function anonymous() {allElements[6].style.width = "200%";})}, +{origCount:642, fun:(function anonymous() {allElements[8].style['float'] = "none";})}, +{origCount:643, fun:(function anonymous() {allElements[7].style.height = "10%";})}, +{origCount:644, fun:(function anonymous() {allElements[8].style.width = "1px";})}, +{origCount:645, fun:(function anonymous() {allElements[5].style.clear = "right";})}, +{origCount:646, fun:(function anonymous() {allElements[2].style.display = "table-row-group";})}, +{origCount:647, fun:(function anonymous() {allElements[4].style.color = "blue";})}, +{origCount:648, fun:(function anonymous() {allElements[5].style.color = "red";})}, +{origCount:649, fun:(function anonymous() {allElements[10].style.background = "transparent";})}, +{origCount:650, fun:(function anonymous() {allElements[10].style.visibility = "visible";})}, +{origCount:651, fun:(function anonymous() {allElements[12].style.height = "auto";})}, +{origCount:652, fun:(function anonymous() {allElements[7].style.background = "url(http://www.google.com/images/logo_sm.gif)";})}, +{origCount:653, fun:(function anonymous() {allElements[2].style.visibility = "visible";})}, +{origCount:654, fun:(function anonymous() {allElements[2].style.clear = "none";})}, +{origCount:655, fun:(function anonymous() {allElements[11].style.position = "relative";})}, +{origCount:656, fun:(function anonymous() {allElements[10].style.width = "200%";})}, +{origCount:657, fun:(function anonymous() {allElements[4].style.overflow = "scroll";})}, +{origCount:658, fun:(function anonymous() {allElements[12].style.clear = "none";})}, +{origCount:659, fun:(function anonymous() {allElements[12].style['float'] = "none";})}, +{origCount:660, fun:(function anonymous() {allElements[10].style.overflow = "scroll";})}, +{origCount:661, fun:(function anonymous() {allElements[12].style.clear = "left";})}, +{origCount:662, fun:(function anonymous() {allElements[10].style.clear = "right";})}, +{origCount:663, fun:(function anonymous() {allElements[9].style.clear = "none";})}, +{origCount:664, fun:(function anonymous() {allElements[2].style.overflow = "hidden";})}, +{origCount:665, fun:(function anonymous() {allElements[7].style.overflow = "visible";})}, +{origCount:666, fun:(function anonymous() {allElements[4].style.width = "1px";})}, +{origCount:667, fun:(function anonymous() {allElements[11].style.color = "blue";})}, +{origCount:668, fun:(function anonymous() {allElements[8].style.position = "relative";})}, +{origCount:669, fun:(function anonymous() {allElements[12].style.color = "black";})}, +{origCount:670, fun:(function anonymous() {allElements[4].style.background = "url(http://www.google.com/images/logo_sm.gif)";})}, +{origCount:671, fun:(function anonymous() {allElements[2].style['float'] = "right";})}, +{origCount:672, fun:(function anonymous() {allElements[10].style['float'] = "left";})}, +{origCount:673, fun:(function anonymous() {allElements[10].style.clear = "right";})}, +{origCount:674, fun:(function anonymous() {allElements[5].style.color = "black";})}, +{origCount:675, fun:(function anonymous() {allElements[2].style.clear = "right";})}, +{origCount:676, fun:(function anonymous() {allElements[5].style.height = "200%";})}, +{origCount:677, fun:(function anonymous() {allElements[8].style.position = "absolute";})}, +{origCount:678, fun:(function anonymous() {allElements[3].style.clear = "none";})}, +{origCount:679, fun:(function anonymous() {allElements[7].style.position = "relative";})}, +{origCount:680, fun:(function anonymous() {allElements[1].style.background = "transparent";})}, +{origCount:681, fun:(function anonymous() {allElements[3].style.position = "static";})}, +{origCount:682, fun:(function anonymous() {allElements[5].style['float'] = "left";})}, +{origCount:683, fun:(function anonymous() {allElements[0].style.background = "url(http://www.google.com/images/logo_sm.gif)";})}, +{origCount:684, fun:(function anonymous() {allElements[7].style.display = "-moz-grid-line";})}, +{origCount:685, fun:(function anonymous() {allElements[3].style.background = "transparent";})}, +{origCount:686, fun:(function anonymous() {allElements[9].style.background = "url(http://www.google.com/images/logo_sm.gif)";})}, +{origCount:687, fun:(function anonymous() {allElements[3].style.background = "#fcd";})}, +{origCount:688, fun:(function anonymous() {allElements[4].style['float'] = "left";})}, +{origCount:689, fun:(function anonymous() {allElements[5].style['float'] = "none";})}, +{origCount:690, fun:(function anonymous() {allElements[10].style.display = "table-cell";})}, +{origCount:691, fun:(function anonymous() {allElements[12].style.height = "200%";})}, +{origCount:692, fun:(function anonymous() {allElements[3].style.background = "url(http://www.google.com/images/logo_sm.gif)";})}, +{origCount:693, fun:(function anonymous() {allElements[3].style.height = "200%";})}, +{origCount:694, fun:(function anonymous() {allElements[2].style.height = "2em";})}, +{origCount:695, fun:(function anonymous() {allElements[8].style.clear = "both";})}, +{origCount:696, fun:(function anonymous() {allElements[11].style.clear = "none";})}, +{origCount:697, fun:(function anonymous() {allElements[6].style.clear = "right";})}, +{origCount:698, fun:(function anonymous() {allElements[9].style.color = "red";})}, +{origCount:699, fun:(function anonymous() {allElements[1].style['float'] = "left";})}, +{origCount:700, fun:(function anonymous() {allElements[12].style.background = "url(http://www.google.com/images/logo_sm.gif)";})}, +{origCount:701, fun:(function anonymous() {allElements[10].style.display = "-moz-deck";})}, +{origCount:702, fun:(function anonymous() {allElements[12].style.height = "auto";})}, +{origCount:703, fun:(function anonymous() {allElements[12].style.clear = "none";})}, +{origCount:704, fun:(function anonymous() {allElements[1].style.visibility = "hidden";})}, +{origCount:705, fun:(function anonymous() {allElements[11].style['float'] = "right";})}, +{origCount:706, fun:(function anonymous() {allElements[8].style.overflow = "hidden";})}, +{origCount:707, fun:(function anonymous() {allElements[11].style.display = "-moz-grid-group";})}, +{origCount:708, fun:(function anonymous() {allElements[12].style.color = "black";})}, +{origCount:709, fun:(function anonymous() {allElements[4].style.clear = "right";})}, +{origCount:710, fun:(function anonymous() {allElements[4].style['float'] = "right";})}, +{origCount:711, fun:(function anonymous() {allElements[7].style.height = "auto";})}, +{origCount:712, fun:(function anonymous() {allElements[2].style.clear = "left";})}, +{origCount:713, fun:(function anonymous() {allElements[11].style.clear = "right";})}, +{origCount:714, fun:(function anonymous() {allElements[11].style.display = "table-header-group";})}, +{origCount:715, fun:(function anonymous() {allElements[8].style.height = "2em";})}, +{origCount:716, fun:(function anonymous() {allElements[7].style.color = "green";})}, +{origCount:717, fun:(function anonymous() {allElements[1].style.width = "auto";})}, +{origCount:718, fun:(function anonymous() {allElements[9].style.background = "url(http://www.google.com/images/logo_sm.gif)";})}, +{origCount:719, fun:(function anonymous() {allElements[10].style.height = "2em";})}, +{origCount:720, fun:(function anonymous() {allElements[8].style.width = "auto";})}, +{origCount:721, fun:(function anonymous() {allElements[10].style.background = "#fcd";})}, +{origCount:722, fun:(function anonymous() {allElements[9].style.display = "table-row-group";})}, +{origCount:723, fun:(function anonymous() {allElements[8].style.overflow = "scroll";})}, +{origCount:724, fun:(function anonymous() {allElements[2].style.display = "table-caption";})}, +{origCount:725, fun:(function anonymous() {allElements[7].style.background = "url(http://www.google.com/images/logo_sm.gif)";})}, +{origCount:726, fun:(function anonymous() {allElements[5].style.visibility = "collapse";})}, +{origCount:727, fun:(function anonymous() {allElements[12].style.position = "absolute";})}, +{origCount:728, fun:(function anonymous() {allElements[9].style.color = "red";})}, +{origCount:729, fun:(function anonymous() {allElements[1].style.display = "table-row";})}, +{origCount:730, fun:(function anonymous() {allElements[6].style.color = "black";})}, +{origCount:731, fun:(function anonymous() {allElements[4].style.visibility = "visible";})}, +{origCount:732, fun:(function anonymous() {allElements[0].style.color = "black";})}, +{origCount:733, fun:(function anonymous() {allElements[0].style.clear = "both";})}, +{origCount:734, fun:(function anonymous() {allElements[8].style['float'] = "none";})}, +{origCount:735, fun:(function anonymous() {allElements[5].style.width = "20em";})}, +{origCount:736, fun:(function anonymous() {allElements[9].style['float'] = "left";})}, +{origCount:737, fun:(function anonymous() {allElements[12].style.height = "10%";})}, +{origCount:738, fun:(function anonymous() {allElements[7].style.height = "10%";})}, +{origCount:739, fun:(function anonymous() {allElements[12].style.color = "black";})}, +{origCount:740, fun:(function anonymous() {allElements[7].style.visibility = "hidden";})}, +{origCount:741, fun:(function anonymous() {allElements[9].style.visibility = "collapse";})}, +{origCount:742, fun:(function anonymous() {allElements[11].style.display = "-moz-inline-box";})}, +{origCount:743, fun:(function anonymous() {allElements[7].style.position = "static";})}, +{origCount:744, fun:(function anonymous() {allElements[0].style.display = "-moz-box";})}, +{origCount:745, fun:(function anonymous() {allElements[11].style.clear = "both";})}, +{origCount:746, fun:(function anonymous() {allElements[4].style.position = "fixed";})}, +{origCount:747, fun:(function anonymous() {allElements[11].style.background = "#fcd";})}, +{origCount:748, fun:(function anonymous() {allElements[0].style.position = "fixed";})}, +{origCount:749, fun:(function anonymous() {allElements[0].style.width = "1px";})}, +{origCount:750, fun:(function anonymous() {allElements[6].style.visibility = "hidden";})}, +{origCount:751, fun:(function anonymous() {allElements[8].style.position = "absolute";})}, +{origCount:752, fun:(function anonymous() {allElements[0].style.color = "green";})}, +{origCount:753, fun:(function anonymous() {allElements[0].style.clear = "both";})}, +{origCount:754, fun:(function anonymous() {allElements[0].style.overflow = "auto";})}, +{origCount:755, fun:(function anonymous() {allElements[6].style.clear = "left";})}, +{origCount:756, fun:(function anonymous() {allElements[10].style.position = "static";})}, +{origCount:757, fun:(function anonymous() {allElements[4].style.background = "#fcd";})}, +{origCount:758, fun:(function anonymous() {allElements[8].style.color = "black";})}, +{origCount:759, fun:(function anonymous() {allElements[0].style.position = "relative";})}, +{origCount:760, fun:(function anonymous() {allElements[12].style.overflow = "auto";})}, +{origCount:761, fun:(function anonymous() {allElements[10].style.visibility = "hidden";})}, +{origCount:762, fun:(function anonymous() {allElements[0].style.visibility = "collapse";})}, +{origCount:763, fun:(function anonymous() {allElements[12].style.height = "100px";})}, +{origCount:764, fun:(function anonymous() {allElements[2].style.overflow = "visible";})}, +{origCount:765, fun:(function anonymous() {allElements[12].style.overflow = "auto";})}, +{origCount:766, fun:(function anonymous() {allElements[10].style.position = "fixed";})}, +{origCount:767, fun:(function anonymous() {allElements[0].style.overflow = "hidden";})}, +{origCount:768, fun:(function anonymous() {allElements[1].style.display = "table-cell";})}, +{origCount:769, fun:(function anonymous() {allElements[7].style.clear = "both";})}, +{origCount:770, fun:(function anonymous() {allElements[8].style.position = "relative";})}, +{origCount:771, fun:(function anonymous() {allElements[10].style.color = "red";})}, +{origCount:772, fun:(function anonymous() {allElements[6].style.display = "-moz-inline-box";})}, +{origCount:773, fun:(function anonymous() {allElements[2].style.overflow = "hidden";})}, +{origCount:774, fun:(function anonymous() {allElements[2].style['float'] = "none";})}, +{origCount:775, fun:(function anonymous() {allElements[0].style.clear = "left";})}, +{origCount:776, fun:(function anonymous() {allElements[12].style.display = "table-cell";})}, +{origCount:777, fun:(function anonymous() {allElements[7].style.background = "transparent";})}, +{origCount:778, fun:(function anonymous() {allElements[2].style['float'] = "right";})}, +{origCount:779, fun:(function anonymous() {allElements[3].style.overflow = "scroll";})}, +{origCount:780, fun:(function anonymous() {allElements[2].style.width = "1px";})}, +{origCount:781, fun:(function anonymous() {allElements[4].style.clear = "both";})}, +{origCount:782, fun:(function anonymous() {allElements[3].style.height = "auto";})}, +{origCount:783, fun:(function anonymous() {allElements[3].style.color = "green";})}, +{origCount:784, fun:(function anonymous() {allElements[10].style.color = "red";})}, +{origCount:785, fun:(function anonymous() {allElements[3].style.position = "static";})}, +{origCount:786, fun:(function anonymous() {allElements[1].style.position = "absolute";})}, +{origCount:787, fun:(function anonymous() {allElements[8].style.height = "100px";})}, +{origCount:788, fun:(function anonymous() {allElements[6].style.overflow = "scroll";})}, +{origCount:789, fun:(function anonymous() {allElements[11].style.position = "relative";})}, +{origCount:790, fun:(function anonymous() {allElements[3].style.display = "-moz-grid-line";})}, +{origCount:791, fun:(function anonymous() {allElements[2].style.visibility = "collapse";})}, +{origCount:792, fun:(function anonymous() {allElements[11].style['float'] = "none";})}, +{origCount:793, fun:(function anonymous() {allElements[11].style.background = "url(http://www.google.com/images/logo_sm.gif)";})}, +{origCount:794, fun:(function anonymous() {allElements[7].style['float'] = "right";})}, +{origCount:795, fun:(function anonymous() {allElements[5].style.display = "table-column";})}, +{origCount:796, fun:(function anonymous() {allElements[9].style.background = "transparent";})}, +{origCount:797, fun:(function anonymous() {allElements[12].style['float'] = "right";})}, +{origCount:798, fun:(function anonymous() {allElements[8].style.position = "static";})}, +{origCount:799, fun:(function anonymous() {allElements[0].style.position = "fixed";})}, +{origCount:800, fun:(function anonymous() {allElements[8].style.overflow = "visible";})}, +{origCount:801, fun:(function anonymous() {allElements[10].style.height = "100px";})}, +{origCount:802, fun:(function anonymous() {allElements[0].style.clear = "right";})}, +{origCount:803, fun:(function anonymous() {allElements[9].style.color = "black";})}, +{origCount:804, fun:(function anonymous() {allElements[3].style.width = "1px";})}, +{origCount:805, fun:(function anonymous() {allElements[0].style.clear = "none";})}, +{origCount:806, fun:(function anonymous() {allElements[7].style.width = "200%";})}, +{origCount:807, fun:(function anonymous() {allElements[2].style.overflow = "visible";})}, +{origCount:808, fun:(function anonymous() {allElements[4].style.overflow = "visible";})}, +{origCount:809, fun:(function anonymous() {allElements[5].style.display = "table-row";})}, +{origCount:810, fun:(function anonymous() {allElements[10].style.clear = "none";})}, +{origCount:811, fun:(function anonymous() {allElements[0].style.color = "red";})}, +{origCount:812, fun:(function anonymous() {allElements[5].style.clear = "right";})}, +{origCount:813, fun:(function anonymous() {allElements[5].style['float'] = "none";})}, +{origCount:814, fun:(function anonymous() {allElements[6].style.background = "#fcd";})}, +{origCount:815, fun:(function anonymous() {allElements[12].style.background = "url(http://www.google.com/images/logo_sm.gif)";})}, +{origCount:816, fun:(function anonymous() {allElements[3].style.visibility = "visible";})}, +{origCount:817, fun:(function anonymous() {allElements[11].style.clear = "none";})}, +{origCount:818, fun:(function anonymous() {allElements[2].style.visibility = "visible";})}, +{origCount:819, fun:(function anonymous() {allElements[8].style.position = "relative";})}, +{origCount:820, fun:(function anonymous() {allElements[7].style.height = "auto";})}, +{origCount:821, fun:(function anonymous() {allElements[5].style.clear = "both";})}, +{origCount:822, fun:(function anonymous() {allElements[9].style.overflow = "auto";})}, +{origCount:823, fun:(function anonymous() {allElements[9].style.position = "static";})}, +{origCount:824, fun:(function anonymous() {allElements[11].style.position = "absolute";})}, +{origCount:825, fun:(function anonymous() {allElements[9].style.width = "200%";})}, +{origCount:826, fun:(function anonymous() {allElements[7].style['float'] = "none";})}, +{origCount:827, fun:(function anonymous() {allElements[11].style.position = "static";})}, +{origCount:828, fun:(function anonymous() {allElements[0].style.overflow = "hidden";})}, +{origCount:829, fun:(function anonymous() {allElements[5].style.background = "url(http://www.google.com/images/logo_sm.gif)";})}, +{origCount:830, fun:(function anonymous() {allElements[6].style.position = "fixed";})}, +{origCount:831, fun:(function anonymous() {allElements[9].style['float'] = "right";})}, +{origCount:832, fun:(function anonymous() {allElements[6].style['float'] = "none";})}, +{origCount:833, fun:(function anonymous() {allElements[2].style.background = "transparent";})}, +{origCount:834, fun:(function anonymous() {allElements[3].style.overflow = "scroll";})}, +{origCount:835, fun:(function anonymous() {allElements[0].style.height = "auto";})}, +{origCount:836, fun:(function anonymous() {allElements[0].style.position = "static";})}, +{origCount:837, fun:(function anonymous() {allElements[8].style.display = "-moz-grid-line";})}, +{origCount:838, fun:(function anonymous() {allElements[4].style.height = "10%";})}, +{origCount:839, fun:(function anonymous() {allElements[5].style.width = "1px";})}, +{origCount:840, fun:(function anonymous() {allElements[4].style.position = "fixed";})}, +{origCount:841, fun:(function anonymous() {allElements[7].style.clear = "none";})}, +{origCount:842, fun:(function anonymous() {allElements[6].style.display = "table-column";})}, +{origCount:843, fun:(function anonymous() {allElements[7].style.visibility = "visible";})}, +{origCount:844, fun:(function anonymous() {allElements[1].style.background = "#fcd";})}, +{origCount:845, fun:(function anonymous() {allElements[7].style.height = "2em";})}, +{origCount:846, fun:(function anonymous() {allElements[5].style.display = "table-column";})}, +{origCount:847, fun:(function anonymous() {allElements[0].style.clear = "both";})}, +{origCount:848, fun:(function anonymous() {allElements[11].style['float'] = "right";})}, +{origCount:849, fun:(function anonymous() {allElements[4].style.visibility = "visible";})}, +{origCount:850, fun:(function anonymous() {allElements[9].style.overflow = "scroll";})}, +{origCount:851, fun:(function anonymous() {allElements[8].style.height = "200%";})}, +{origCount:852, fun:(function anonymous() {allElements[5].style.height = "200%";})}, +{origCount:853, fun:(function anonymous() {allElements[5].style.clear = "none";})}, +{origCount:854, fun:(function anonymous() {allElements[2].style.background = "#fcd";})}, +{origCount:855, fun:(function anonymous() {allElements[12].style.visibility = "hidden";})}, +{origCount:856, fun:(function anonymous() {allElements[4].style.clear = "both";})}, +{origCount:857, fun:(function anonymous() {allElements[8].style.width = "10%";})}, +{origCount:858, fun:(function anonymous() {allElements[4].style.color = "red";})}, +{origCount:859, fun:(function anonymous() {allElements[9].style.height = "10%";})}, +{origCount:860, fun:(function anonymous() {allElements[4].style.visibility = "hidden";})}, +{origCount:861, fun:(function anonymous() {allElements[7].style.clear = "left";})}, +{origCount:862, fun:(function anonymous() {allElements[11].style.background = "#fcd";})}, +{origCount:863, fun:(function anonymous() {allElements[7].style.color = "green";})}, +{origCount:864, fun:(function anonymous() {allElements[1].style.clear = "left";})}, +{origCount:865, fun:(function anonymous() {allElements[12].style.background = "url(http://www.google.com/images/logo_sm.gif)";})}, +{origCount:866, fun:(function anonymous() {allElements[6].style.width = "auto";})}, +{origCount:867, fun:(function anonymous() {allElements[1].style.height = "100px";})}, +{origCount:868, fun:(function anonymous() {allElements[3].style.display = "-moz-inline-block";})}, +{origCount:869, fun:(function anonymous() {allElements[5].style.visibility = "visible";})}, +{origCount:870, fun:(function anonymous() {allElements[11].style.color = "blue";})}, +{origCount:871, fun:(function anonymous() {allElements[1].style.position = "static";})}, +{origCount:872, fun:(function anonymous() {allElements[6].style.visibility = "visible";})}, +{origCount:873, fun:(function anonymous() {allElements[7].style.color = "red";})}, +{origCount:874, fun:(function anonymous() {allElements[8].style.color = "blue";})}, +{origCount:875, fun:(function anonymous() {allElements[1].style['float'] = "right";})}, +{origCount:876, fun:(function anonymous() {allElements[6].style['float'] = "right";})}, +{origCount:877, fun:(function anonymous() {allElements[1].style.clear = "left";})}, +{origCount:878, fun:(function anonymous() {allElements[6].style.background = "url(http://www.google.com/images/logo_sm.gif)";})}, +{origCount:879, fun:(function anonymous() {allElements[11].style.display = "inline";})}, +{origCount:880, fun:(function anonymous() {allElements[11].style['float'] = "none";})}, +{origCount:881, fun:(function anonymous() {allElements[10].style.color = "black";})}, +{origCount:882, fun:(function anonymous() {allElements[0].style.visibility = "hidden";})}, +{origCount:883, fun:(function anonymous() {allElements[1].style.color = "green";})}, +{origCount:884, fun:(function anonymous() {allElements[4].style.height = "10%";})}, +{origCount:885, fun:(function anonymous() {allElements[2].style.background = "url(http://www.google.com/images/logo_sm.gif)";})}, +{origCount:886, fun:(function anonymous() {allElements[0].style.display = "list-item";})}, +{origCount:887, fun:(function anonymous() {allElements[4].style['float'] = "left";})}, +{origCount:888, fun:(function anonymous() {allElements[6].style.overflow = "hidden";})}, +{origCount:889, fun:(function anonymous() {allElements[12].style.clear = "left";})}, +{origCount:890, fun:(function anonymous() {allElements[1].style.clear = "none";})}, +{origCount:891, fun:(function anonymous() {allElements[4].style.clear = "left";})}, +{origCount:892, fun:(function anonymous() {allElements[1].style.position = "relative";})}, +{origCount:893, fun:(function anonymous() {allElements[11].style.position = "absolute";})}, +{origCount:894, fun:(function anonymous() {allElements[12].style.background = "#fcd";})}, +{origCount:895, fun:(function anonymous() {allElements[10].style.position = "relative";})}, +{origCount:896, fun:(function anonymous() {allElements[10].style.display = "-moz-box";})}, +{origCount:897, fun:(function anonymous() {allElements[6].style.position = "fixed";})}, +{origCount:898, fun:(function anonymous() {allElements[1].style.overflow = "scroll";})}, +{origCount:899, fun:(function anonymous() {allElements[3].style.width = "10%";})}, +{origCount:900, fun:(function anonymous() {allElements[3].style.background = "transparent";})}, +{origCount:901, fun:(function anonymous() {allElements[6].style.background = "transparent";})}, +{origCount:902, fun:(function anonymous() {allElements[5].style.visibility = "visible";})}, +{origCount:903, fun:(function anonymous() {allElements[6].style.background = "#fcd";})}, +{origCount:904, fun:(function anonymous() {allElements[0].style.overflow = "scroll";})}, +{origCount:905, fun:(function anonymous() {allElements[7].style['float'] = "none";})}, +{origCount:906, fun:(function anonymous() {allElements[6].style.background = "url(http://www.google.com/images/logo_sm.gif)";})}, +{origCount:907, fun:(function anonymous() {allElements[1].style.height = "200%";})}, +{origCount:908, fun:(function anonymous() {allElements[12].style.display = "table-row";})}, +{origCount:909, fun:(function anonymous() {allElements[5].style.height = "10%";})}, +{origCount:910, fun:(function anonymous() {allElements[11].style.position = "relative";})}, +{origCount:911, fun:(function anonymous() {allElements[10].style.display = "-moz-stack";})}, +{origCount:912, fun:(function anonymous() {allElements[7].style.color = "green";})}, +{origCount:913, fun:(function anonymous() {allElements[8].style.clear = "left";})}, +{origCount:914, fun:(function anonymous() {allElements[5].style.clear = "right";})}, +{origCount:915, fun:(function anonymous() {allElements[3].style['float'] = "left";})}, +{origCount:916, fun:(function anonymous() {allElements[8].style.display = "table-header-group";})}, +{origCount:917, fun:(function anonymous() {allElements[12].style.display = "-moz-grid-group";})}, +{origCount:918, fun:(function anonymous() {allElements[8].style.position = "fixed";})}, +{origCount:919, fun:(function anonymous() {allElements[1].style.clear = "none";})}, +{origCount:920, fun:(function anonymous() {allElements[10].style.height = "10%";})}, +{origCount:921, fun:(function anonymous() {allElements[0].style['float'] = "left";})}, +{origCount:922, fun:(function anonymous() {allElements[4].style['float'] = "left";})}, +{origCount:923, fun:(function anonymous() {allElements[0].style.display = "-moz-inline-box";})}, +{origCount:924, fun:(function anonymous() {allElements[8].style.clear = "left";})}, +{origCount:925, fun:(function anonymous() {allElements[6].style.clear = "right";})}, +{origCount:926, fun:(function anonymous() {allElements[0].style.overflow = "hidden";})}, +{origCount:927, fun:(function anonymous() {allElements[9].style.height = "100px";})}, +{origCount:928, fun:(function anonymous() {allElements[11].style.color = "blue";})}, +{origCount:929, fun:(function anonymous() {allElements[0].style.clear = "left";})}, +{origCount:930, fun:(function anonymous() {allElements[6].style.background = "#fcd";})}, +{origCount:931, fun:(function anonymous() {allElements[10].style['float'] = "none";})}, +{origCount:932, fun:(function anonymous() {allElements[3].style.display = "-moz-inline-box";})}, +{origCount:933, fun:(function anonymous() {allElements[4].style.width = "1px";})}, +{origCount:934, fun:(function anonymous() {allElements[5].style.display = "table-row";})}, +{origCount:935, fun:(function anonymous() {allElements[12].style.height = "2em";})}, +{origCount:936, fun:(function anonymous() {allElements[4].style.visibility = "collapse";})}, +{origCount:937, fun:(function anonymous() {allElements[0].style.background = "transparent";})}, +{origCount:938, fun:(function anonymous() {allElements[4].style.background = "#fcd";})}, +{origCount:939, fun:(function anonymous() {allElements[11].style.overflow = "scroll";})}, +{origCount:940, fun:(function anonymous() {allElements[10].style.background = "url(http://www.google.com/images/logo_sm.gif)";})}, +{origCount:941, fun:(function anonymous() {allElements[10].style.background = "#fcd";})}, +{origCount:942, fun:(function anonymous() {allElements[0].style.width = "20em";})}, +{origCount:943, fun:(function anonymous() {allElements[1].style.overflow = "scroll";})}, +{origCount:944, fun:(function anonymous() {allElements[5].style.clear = "left";})}, +{origCount:945, fun:(function anonymous() {allElements[3].style.display = "table";})}, +{origCount:946, fun:(function anonymous() {allElements[2].style.display = "table-footer-group";})}, +{origCount:947, fun:(function anonymous() {allElements[6].style.visibility = "visible";})}, +{origCount:948, fun:(function anonymous() {allElements[9].style.display = "-moz-inline-block";})}, +{origCount:949, fun:(function anonymous() {allElements[2].style.clear = "right";})}, +{origCount:950, fun:(function anonymous() {allElements[4].style.overflow = "visible";})}, +{origCount:951, fun:(function anonymous() {allElements[8].style.width = "200%";})}, +{origCount:952, fun:(function anonymous() {allElements[5].style.overflow = "hidden";})}, +{origCount:953, fun:(function anonymous() {allElements[2].style.height = "auto";})}, +{origCount:954, fun:(function anonymous() {allElements[3].style.overflow = "visible";})}, +{origCount:955, fun:(function anonymous() {allElements[2].style.color = "blue";})}, +{origCount:956, fun:(function anonymous() {allElements[2].style.width = "10%";})}, +{origCount:957, fun:(function anonymous() {allElements[11].style.visibility = "collapse";})}, +{origCount:958, fun:(function anonymous() {allElements[7].style.background = "url(http://www.google.com/images/logo_sm.gif)";})}, +{origCount:959, fun:(function anonymous() {allElements[9].style.position = "fixed";})}, +{origCount:960, fun:(function anonymous() {allElements[9].style.background = "transparent";})}, +{origCount:961, fun:(function anonymous() {allElements[0].style.clear = "right";})}, +{origCount:962, fun:(function anonymous() {allElements[0].style['float'] = "left";})}, +{origCount:963, fun:(function anonymous() {allElements[1].style.width = "1px";})}, +{origCount:964, fun:(function anonymous() {allElements[9].style.height = "2em";})}, +{origCount:965, fun:(function anonymous() {allElements[3].style.width = "20em";})}, +{origCount:966, fun:(function anonymous() {allElements[1].style.width = "200%";})}, +{origCount:967, fun:(function anonymous() {allElements[10].style.overflow = "hidden";})}, +{origCount:968, fun:(function anonymous() {allElements[9].style.clear = "both";})}, +{origCount:969, fun:(function anonymous() {allElements[2].style.clear = "both";})}, +{origCount:970, fun:(function anonymous() {allElements[9].style['float'] = "left";})}, +{origCount:971, fun:(function anonymous() {allElements[8].style.clear = "left";})}, +{origCount:972, fun:(function anonymous() {allElements[6].style.height = "auto";})}, +{origCount:973, fun:(function anonymous() {allElements[7].style.background = "#fcd";})}, +{origCount:974, fun:(function anonymous() {allElements[4].style.clear = "none";})}, +{origCount:975, fun:(function anonymous() {allElements[2].style.position = "relative";})}, +{origCount:976, fun:(function anonymous() {allElements[8].style['float'] = "left";})}, +{origCount:977, fun:(function anonymous() {allElements[12].style.visibility = "hidden";})}, +{origCount:978, fun:(function anonymous() {allElements[8].style.height = "100px";})}, +{origCount:979, fun:(function anonymous() {allElements[2].style['float'] = "left";})}, +{origCount:980, fun:(function anonymous() {allElements[11].style.clear = "left";})}, +{origCount:981, fun:(function anonymous() {allElements[1].style.color = "blue";})}, +{origCount:982, fun:(function anonymous() {allElements[6].style.height = "100px";})}, +{origCount:983, fun:(function anonymous() {allElements[2].style.overflow = "scroll";})}, +{origCount:984, fun:(function anonymous() {allElements[10].style.background = "url(http://www.google.com/images/logo_sm.gif)";})}, +{origCount:985, fun:(function anonymous() {allElements[9].style.clear = "both";})}, +{origCount:986, fun:(function anonymous() {allElements[4].style.height = "10%";})}, +{origCount:987, fun:(function anonymous() {allElements[0].style.background = "url(http://www.google.com/images/logo_sm.gif)";})}, +{origCount:988, fun:(function anonymous() {allElements[2].style.background = "transparent";})}, +{origCount:989, fun:(function anonymous() {allElements[4].style.color = "green";})}, +{origCount:990, fun:(function anonymous() {allElements[11].style.color = "green";})}, +{origCount:991, fun:(function anonymous() {allElements[2].style.clear = "left";})}, +{origCount:992, fun:(function anonymous() {allElements[8].style.background = "url(http://www.google.com/images/logo_sm.gif)";})}, +{origCount:993, fun:(function anonymous() {allElements[10].style.background = "transparent";})}, +{origCount:994, fun:(function anonymous() {allElements[11].style.overflow = "auto";})}, +{origCount:995, fun:(function anonymous() {allElements[5].style.overflow = "visible";})}, +{origCount:996, fun:(function anonymous() {allElements[11].style.visibility = "collapse";})}, +{origCount:997, fun:(function anonymous() {allElements[7].style.clear = "both";})}, +{origCount:998, fun:(function anonymous() {allElements[12].style.position = "fixed";})}, +{origCount:999, fun:(function anonymous() {allElements[5].style.color = "green";})}, +{origCount:1000, fun:(function anonymous() {allElements[6].style.display = "-moz-box";})}, +{origCount:1001, fun:(function anonymous() {allElements[5].style.overflow = "auto";})}, +{origCount:1002, fun:(function anonymous() {allElements[9].style.height = "2em";})}, +{origCount:1003, fun:(function anonymous() {allElements[11].style['float'] = "left";})}, +{origCount:1004, fun:(function anonymous() {allElements[2].style['float'] = "none";})}, +{origCount:1005, fun:(function anonymous() {allElements[0].style.overflow = "scroll";})}, +{origCount:1006, fun:(function anonymous() {allElements[12].style.background = "transparent";})}, +{origCount:1007, fun:(function anonymous() {allElements[4].style.visibility = "hidden";})}, +{origCount:1008, fun:(function anonymous() {allElements[7].style.overflow = "scroll";})}, +{origCount:1009, fun:(function anonymous() {allElements[1].style.width = "auto";})}, +{origCount:1010, fun:(function anonymous() {allElements[3].style.overflow = "hidden";})}, +{origCount:1011, fun:(function anonymous() {allElements[7].style.display = "table-header-group";})}, +{origCount:1012, fun:(function anonymous() {allElements[5].style.display = "-moz-box";})}, +{origCount:1013, fun:(function anonymous() {allElements[2].style['float'] = "left";})}, +{origCount:1014, fun:(function anonymous() {allElements[3].style.height = "auto";})}, +{origCount:1015, fun:(function anonymous() {allElements[2].style.overflow = "auto";})}, +{origCount:1016, fun:(function anonymous() {allElements[3].style['float'] = "right";})}, +{origCount:1017, fun:(function anonymous() {allElements[0].style.height = "2em";})}, +{origCount:1018, fun:(function anonymous() {allElements[9].style.background = "transparent";})}, +{origCount:1019, fun:(function anonymous() {allElements[11].style.background = "url(http://www.google.com/images/logo_sm.gif)";})}, +{origCount:1020, fun:(function anonymous() {allElements[12].style.visibility = "hidden";})}, +{origCount:1021, fun:(function anonymous() {allElements[3].style.clear = "both";})}, +{origCount:1022, fun:(function anonymous() {allElements[3].style.visibility = "visible";})}, +{origCount:1023, fun:(function anonymous() {allElements[4].style.overflow = "auto";})}, +{origCount:1024, fun:(function anonymous() {allElements[12].style['float'] = "right";})}, +{origCount:1025, fun:(function anonymous() {allElements[7].style.display = "table";})}, +{origCount:1026, fun:(function anonymous() {allElements[6].style.color = "blue";})}, +{origCount:1027, fun:(function anonymous() {allElements[2].style.color = "black";})}, +{origCount:1028, fun:(function anonymous() {allElements[1].style.color = "black";})}, +{origCount:1029, fun:(function anonymous() {allElements[8].style['float'] = "right";})}, +{origCount:1030, fun:(function anonymous() {allElements[2].style.display = "-moz-grid-group";})}, +{origCount:1031, fun:(function anonymous() {allElements[1].style.background = "#fcd";})}, +{origCount:1032, fun:(function anonymous() {allElements[12].style.height = "auto";})}, +{origCount:1033, fun:(function anonymous() {allElements[1].style.clear = "both";})}, +{origCount:1034, fun:(function anonymous() {allElements[11].style.width = "auto";})}, +{origCount:1035, fun:(function anonymous() {allElements[10].style.position = "relative";})}, +{origCount:1036, fun:(function anonymous() {allElements[3].style.position = "fixed";})}, +{origCount:1037, fun:(function anonymous() {allElements[8].style.clear = "both";})}, +{origCount:1038, fun:(function anonymous() {allElements[4].style['float'] = "left";})}, +{origCount:1039, fun:(function anonymous() {allElements[11].style.overflow = "auto";})}, +{origCount:1040, fun:(function anonymous() {allElements[7].style.height = "200%";})}, +{origCount:1041, fun:(function anonymous() {allElements[11].style.width = "200%";})}, +{origCount:1042, fun:(function anonymous() {allElements[3].style.overflow = "visible";})}, +{origCount:1043, fun:(function anonymous() {allElements[0].style.position = "fixed";})}, +{origCount:1044, fun:(function anonymous() {allElements[8].style.clear = "none";})}, +{origCount:1045, fun:(function anonymous() {allElements[7].style.width = "10%";})}, +{origCount:1046, fun:(function anonymous() {allElements[2].style.height = "100px";})}, +{origCount:1047, fun:(function anonymous() {allElements[12].style.clear = "left";})}, +{origCount:1048, fun:(function anonymous() {allElements[2].style.overflow = "visible";})}, +{origCount:1049, fun:(function anonymous() {allElements[4].style.background = "transparent";})}, +{origCount:1050, fun:(function anonymous() {allElements[11].style['float'] = "none";})}, +{origCount:1051, fun:(function anonymous() {allElements[3].style['float'] = "right";})}, +{origCount:1052, fun:(function anonymous() {allElements[9].style.height = "auto";})}, +{origCount:1053, fun:(function anonymous() {allElements[11].style.display = "-moz-grid";})}, +{origCount:1054, fun:(function anonymous() {allElements[0].style.position = "fixed";})}, +{origCount:1055, fun:(function anonymous() {allElements[7].style.width = "20em";})}, +{origCount:1056, fun:(function anonymous() {allElements[0].style.height = "100px";})}, +{origCount:1057, fun:(function anonymous() {allElements[10].style.clear = "none";})}, +{origCount:1058, fun:(function anonymous() {allElements[2].style.width = "10%";})}, +{origCount:1059, fun:(function anonymous() {allElements[9].style.visibility = "collapse";})}, +{origCount:1060, fun:(function anonymous() {allElements[10].style.display = "-moz-inline-box";})}, +{origCount:1061, fun:(function anonymous() {allElements[10].style.height = "200%";})}, +{origCount:1062, fun:(function anonymous() {allElements[1].style.background = "url(http://www.google.com/images/logo_sm.gif)";})}, +{origCount:1063, fun:(function anonymous() {allElements[3].style.clear = "right";})}, +{origCount:1064, fun:(function anonymous() {allElements[7].style.overflow = "auto";})}, +{origCount:1065, fun:(function anonymous() {allElements[6].style.visibility = "visible";})}, +{origCount:1066, fun:(function anonymous() {allElements[5].style['float'] = "right";})}, +{origCount:1067, fun:(function anonymous() {allElements[11].style.height = "200%";})}, +{origCount:1068, fun:(function anonymous() {allElements[1].style.position = "static";})}, +{origCount:1069, fun:(function anonymous() {allElements[8].style.clear = "none";})}, +{origCount:1070, fun:(function anonymous() {allElements[11].style.display = "-moz-groupbox";})}, +{origCount:1071, fun:(function anonymous() {allElements[2].style.visibility = "visible";})}, +{origCount:1072, fun:(function anonymous() {allElements[0].style.background = "transparent";})}, +{origCount:1073, fun:(function anonymous() {allElements[10].style.width = "auto";})}, +{origCount:1074, fun:(function anonymous() {allElements[12].style.clear = "right";})}, +{origCount:1075, fun:(function anonymous() {allElements[12].style['float'] = "right";})}, +{origCount:1076, fun:(function anonymous() {allElements[0].style.width = "200%";})}, +{origCount:1077, fun:(function anonymous() {allElements[10].style.clear = "left";})}, +{origCount:1078, fun:(function anonymous() {allElements[7].style.display = "-moz-deck";})}, +{origCount:1079, fun:(function anonymous() {allElements[9].style.color = "green";})}, +{origCount:1080, fun:(function anonymous() {allElements[10].style.color = "black";})}, +{origCount:1081, fun:(function anonymous() {allElements[1].style.width = "200%";})}, +{origCount:1082, fun:(function anonymous() {allElements[2].style.position = "fixed";})}, +{origCount:1083, fun:(function anonymous() {allElements[3].style.height = "100px";})}, +{origCount:1084, fun:(function anonymous() {allElements[12].style.background = "#fcd";})}, +{origCount:1085, fun:(function anonymous() {allElements[7].style.visibility = "collapse";})}, +{origCount:1086, fun:(function anonymous() {allElements[6].style.clear = "both";})}, +{origCount:1087, fun:(function anonymous() {allElements[3].style.overflow = "visible";})}, +{origCount:1088, fun:(function anonymous() {allElements[2].style.width = "10%";})}, +{origCount:1089, fun:(function anonymous() {allElements[9].style.color = "red";})}, +{origCount:1090, fun:(function anonymous() {allElements[3].style.display = "-moz-inline-box";})}, +{origCount:1091, fun:(function anonymous() {allElements[4].style['float'] = "right";})}, +{origCount:1092, fun:(function anonymous() {allElements[2].style.overflow = "visible";})}, +{origCount:1093, fun:(function anonymous() {allElements[4].style.clear = "none";})}, +{origCount:1094, fun:(function anonymous() {allElements[1].style.display = "table-row";})}, +{origCount:1095, fun:(function anonymous() {allElements[1].style.display = "-moz-deck";})}, +{origCount:1096, fun:(function anonymous() {allElements[7].style.overflow = "visible";})}, +{origCount:1097, fun:(function anonymous() {allElements[12].style.color = "black";})}, +{origCount:1098, fun:(function anonymous() {allElements[9].style.width = "20em";})}, +{origCount:1099, fun:(function anonymous() {allElements[3].style.color = "green";})}, +{origCount:1100, fun:(function anonymous() {allElements[0].style.overflow = "auto";})}, +{origCount:1101, fun:(function anonymous() {allElements[4].style.background = "#fcd";})}, +{origCount:1102, fun:(function anonymous() {allElements[9].style.background = "#fcd";})}, +{origCount:1103, fun:(function anonymous() {allElements[7].style.clear = "none";})}, +{origCount:1104, fun:(function anonymous() {allElements[2].style['float'] = "none";})}, +{origCount:1105, fun:(function anonymous() {allElements[2].style.clear = "none";})}, +{origCount:1106, fun:(function anonymous() {allElements[10].style.color = "blue";})}, +{origCount:1107, fun:(function anonymous() {allElements[7].style.clear = "none";})}, +{origCount:1108, fun:(function anonymous() {allElements[10].style.height = "10%";})}, +{origCount:1109, fun:(function anonymous() {allElements[0].style.overflow = "scroll";})}, +{origCount:1110, fun:(function anonymous() {allElements[7].style.display = "-moz-grid-group";})}, +{origCount:1111, fun:(function anonymous() {allElements[12].style.overflow = "visible";})}, +{origCount:1112, fun:(function anonymous() {allElements[6].style.width = "20em";})}, +{origCount:1113, fun:(function anonymous() {allElements[8].style.overflow = "auto";})}, +{origCount:1114, fun:(function anonymous() {allElements[10].style['float'] = "none";})}, +{origCount:1115, fun:(function anonymous() {allElements[5].style.width = "auto";})}, +{origCount:1116, fun:(function anonymous() {allElements[11].style.display = "table-caption";})}, +{origCount:1117, fun:(function anonymous() {allElements[8].style.width = "200%";})}, +{origCount:1118, fun:(function anonymous() {allElements[1].style.width = "1px";})}, +{origCount:1119, fun:(function anonymous() {allElements[8].style.background = "transparent";})}, +{origCount:1120, fun:(function anonymous() {allElements[9].style['float'] = "none";})}, +{origCount:1121, fun:(function anonymous() {allElements[9].style['float'] = "none";})}, +{origCount:1122, fun:(function anonymous() {allElements[1].style.display = "list-item";})}, +{origCount:1123, fun:(function anonymous() {allElements[3].style['float'] = "none";})}, +{origCount:1124, fun:(function anonymous() {allElements[8].style.background = "url(http://www.google.com/images/logo_sm.gif)";})}, +{origCount:1125, fun:(function anonymous() {allElements[7].style.height = "auto";})}, +{origCount:1126, fun:(function anonymous() {allElements[7].style.height = "10%";})}, +{origCount:1127, fun:(function anonymous() {allElements[0].style.display = "-moz-inline-box";})}, +{origCount:1128, fun:(function anonymous() {allElements[3].style.clear = "right";})}, +{origCount:1129, fun:(function anonymous() {allElements[11].style.clear = "left";})}, +{origCount:1130, fun:(function anonymous() {allElements[1].style.color = "black";})}, +{origCount:1131, fun:(function anonymous() {allElements[5].style['float'] = "none";})}, +{origCount:1132, fun:(function anonymous() {allElements[4].style.width = "10%";})}, +{origCount:1133, fun:(function anonymous() {allElements[2].style.display = "-moz-grid";})}, +{origCount:1134, fun:(function anonymous() {allElements[4].style.height = "100px";})}, +{origCount:1135, fun:(function anonymous() {allElements[4].style.clear = "both";})}, +{origCount:1136, fun:(function anonymous() {allElements[6].style.position = "static";})}, +{origCount:1137, fun:(function anonymous() {allElements[2].style['float'] = "left";})}, +{origCount:1138, fun:(function anonymous() {allElements[0].style.overflow = "scroll";})}, +{origCount:1139, fun:(function anonymous() {allElements[3].style.display = "table-cell";})}, +{origCount:1140, fun:(function anonymous() {allElements[4].style.color = "blue";})}, +{origCount:1141, fun:(function anonymous() {allElements[9].style.clear = "left";})}, +{origCount:1142, fun:(function anonymous() {allElements[9].style.clear = "none";})}, +{origCount:1143, fun:(function anonymous() {allElements[11].style['float'] = "left";})}, +{origCount:1144, fun:(function anonymous() {allElements[7].style.display = "-moz-inline-block";})}, +{origCount:1145, fun:(function anonymous() {allElements[3].style.clear = "none";})}, +{origCount:1146, fun:(function anonymous() {allElements[2].style.visibility = "collapse";})}, +{origCount:1147, fun:(function anonymous() {allElements[12].style['float'] = "none";})}, +{origCount:1148, fun:(function anonymous() {allElements[12].style.background = "transparent";})}, +{origCount:1149, fun:(function anonymous() {allElements[6].style.width = "1px";})}, +{origCount:1150, fun:(function anonymous() {allElements[1].style.width = "10%";})}, +{origCount:1151, fun:(function anonymous() {allElements[1].style['float'] = "none";})}, +{origCount:1152, fun:(function anonymous() {allElements[0].style.width = "1px";})}, +{origCount:1153, fun:(function anonymous() {allElements[2].style.width = "20em";})}, +{origCount:1154, fun:(function anonymous() {allElements[0].style.display = "-moz-popup";})}, +{origCount:1155, fun:(function anonymous() {allElements[0].style.color = "red";})}, +{origCount:1156, fun:(function anonymous() {allElements[6].style.visibility = "visible";})}, +{origCount:1157, fun:(function anonymous() {allElements[12].style.background = "#fcd";})}, +{origCount:1158, fun:(function anonymous() {allElements[9].style.visibility = "hidden";})}, +{origCount:1159, fun:(function anonymous() {allElements[4].style.overflow = "scroll";})}, +{origCount:1160, fun:(function anonymous() {allElements[1].style.background = "url(http://www.google.com/images/logo_sm.gif)";})}, +{origCount:1161, fun:(function anonymous() {allElements[6].style.display = "block";})}, +{origCount:1162, fun:(function anonymous() {allElements[11].style.background = "#fcd";})}, +{origCount:1163, fun:(function anonymous() {allElements[9].style.visibility = "collapse";})}, +{origCount:1164, fun:(function anonymous() {allElements[5].style.background = "#fcd";})}, +{origCount:1165, fun:(function anonymous() {allElements[4].style.clear = "left";})}, +{origCount:1166, fun:(function anonymous() {allElements[0].style['float'] = "right";})}, +{origCount:1167, fun:(function anonymous() {allElements[10].style.width = "200%";})}, +{origCount:1168, fun:(function anonymous() {allElements[1].style['float'] = "left";})}, +{origCount:1169, fun:(function anonymous() {allElements[4].style.height = "auto";})}, +{origCount:1170, fun:(function anonymous() {allElements[12].style['float'] = "right";})}, +{origCount:1171, fun:(function anonymous() {allElements[4].style.color = "blue";})}, +{origCount:1172, fun:(function anonymous() {allElements[11].style.visibility = "visible";})}, +{origCount:1173, fun:(function anonymous() {allElements[1].style.position = "absolute";})}, +{origCount:1174, fun:(function anonymous() {allElements[3].style.visibility = "visible";})}, +{origCount:1175, fun:(function anonymous() {allElements[12].style.position = "fixed";})}, +{origCount:1176, fun:(function anonymous() {allElements[5].style.display = "table-column-group";})}, +{origCount:1177, fun:(function anonymous() {allElements[2].style.clear = "right";})}, +{origCount:1178, fun:(function anonymous() {allElements[9].style.overflow = "hidden";})}, +{origCount:1179, fun:(function anonymous() {allElements[3].style.width = "20em";})}, +{origCount:1180, fun:(function anonymous() {allElements[4].style.position = "relative";})}, +{origCount:1181, fun:(function anonymous() {allElements[5].style.width = "20em";})}, +{origCount:1182, fun:(function anonymous() {allElements[10].style.visibility = "visible";})}, +{origCount:1183, fun:(function anonymous() {allElements[0].style.overflow = "scroll";})}, +{origCount:1184, fun:(function anonymous() {allElements[5].style.color = "red";})}, +{origCount:1185, fun:(function anonymous() {allElements[4].style.clear = "right";})}, +{origCount:1186, fun:(function anonymous() {allElements[5].style.overflow = "hidden";})}, +{origCount:1187, fun:(function anonymous() {allElements[10].style.clear = "none";})}, +{origCount:1188, fun:(function anonymous() {allElements[1].style.position = "fixed";})}, +{origCount:1189, fun:(function anonymous() {allElements[9].style.width = "1px";})}, +{origCount:1190, fun:(function anonymous() {allElements[0].style.color = "blue";})}, +{origCount:1191, fun:(function anonymous() {allElements[5].style.position = "static";})}, +{origCount:1192, fun:(function anonymous() {allElements[4].style.overflow = "hidden";})}, +{origCount:1193, fun:(function anonymous() {allElements[2].style.position = "relative";})}, +{origCount:1194, fun:(function anonymous() {allElements[4].style.position = "absolute";})}, +{origCount:1195, fun:(function anonymous() {allElements[4].style['float'] = "none";})}, +{origCount:1196, fun:(function anonymous() {allElements[7].style.color = "black";})}, +{origCount:1197, fun:(function anonymous() {allElements[4].style.color = "blue";})}, +{origCount:1198, fun:(function anonymous() {allElements[1].style.position = "absolute";})}, +{origCount:1199, fun:(function anonymous() {allElements[5].style.overflow = "scroll";})}, +{origCount:1200, fun:(function anonymous() {allElements[6].style.visibility = "visible";})}, +{origCount:1201, fun:(function anonymous() {allElements[11].style.clear = "right";})}, +{origCount:1202, fun:(function anonymous() {allElements[12].style.position = "static";})}, +{origCount:1203, fun:(function anonymous() {allElements[2].style.background = "url(http://www.google.com/images/logo_sm.gif)";})}, +{origCount:1204, fun:(function anonymous() {allElements[11].style.visibility = "hidden";})}, +{origCount:1205, fun:(function anonymous() {allElements[7].style.color = "red";})}, +{origCount:1206, fun:(function anonymous() {allElements[7].style.clear = "right";})}, +{origCount:1207, fun:(function anonymous() {allElements[4].style.clear = "none";})}, +{origCount:1208, fun:(function anonymous() {allElements[4].style.display = "list-item";})}, +{origCount:1209, fun:(function anonymous() {allElements[12].style.background = "transparent";})}, +{origCount:1210, fun:(function anonymous() {allElements[7].style['float'] = "left";})}, +{origCount:1211, fun:(function anonymous() {allElements[8].style.color = "red";})}, +{origCount:1212, fun:(function anonymous() {allElements[7].style.width = "20em";})}, +{origCount:1213, fun:(function anonymous() {allElements[9].style.clear = "right";})}, +{origCount:1214, fun:(function anonymous() {allElements[8].style.height = "100px";})}, +{origCount:1215, fun:(function anonymous() {allElements[8].style.color = "red";})}, +{origCount:1216, fun:(function anonymous() {allElements[2].style.background = "url(http://www.google.com/images/logo_sm.gif)";})}, +{origCount:1217, fun:(function anonymous() {allElements[8].style.overflow = "auto";})}, +{origCount:1218, fun:(function anonymous() {allElements[5].style.position = "relative";})}, +{origCount:1219, fun:(function anonymous() {allElements[0].style['float'] = "left";})}, +{origCount:1220, fun:(function anonymous() {allElements[10].style.overflow = "visible";})}, +{origCount:1221, fun:(function anonymous() {allElements[3].style.overflow = "visible";})}, +{origCount:1222, fun:(function anonymous() {allElements[8].style.visibility = "hidden";})}, +{origCount:1223, fun:(function anonymous() {allElements[6].style.visibility = "hidden";})}, +{origCount:1224, fun:(function anonymous() {allElements[3].style['float'] = "right";})}, +{origCount:1225, fun:(function anonymous() {allElements[3].style.width = "1px";})}, +{origCount:1226, fun:(function anonymous() {allElements[12].style['float'] = "left";})}, +{origCount:1227, fun:(function anonymous() {allElements[9].style.display = "list-item";})}, +{origCount:1228, fun:(function anonymous() {allElements[1].style.width = "20em";})}, +{origCount:1229, fun:(function anonymous() {allElements[4].style['float'] = "left";})}, +{origCount:1230, fun:(function anonymous() {allElements[12].style.overflow = "auto";})}, +{origCount:1231, fun:(function anonymous() {allElements[5].style.overflow = "hidden";})}, +{origCount:1232, fun:(function anonymous() {allElements[12].style.overflow = "auto";})}, +{origCount:1233, fun:(function anonymous() {allElements[2].style.height = "2em";})}, +{origCount:1234, fun:(function anonymous() {allElements[5].style.display = "table-cell";})}, +{origCount:1235, fun:(function anonymous() {allElements[1].style.background = "#fcd";})}, +{origCount:1236, fun:(function anonymous() {allElements[8].style.height = "200%";})}, +{origCount:1237, fun:(function anonymous() {allElements[5].style.clear = "both";})}, +{origCount:1238, fun:(function anonymous() {allElements[12].style.height = "auto";})}, +{origCount:1239, fun:(function anonymous() {allElements[7].style.overflow = "auto";})}, +{origCount:1240, fun:(function anonymous() {allElements[8].style.overflow = "auto";})}, +{origCount:1241, fun:(function anonymous() {allElements[9].style.visibility = "visible";})}, +{origCount:1242, fun:(function anonymous() {allElements[2].style.display = "-moz-deck";})}, +{origCount:1243, fun:(function anonymous() {allElements[5].style.color = "black";})}, +{origCount:1244, fun:(function anonymous() {allElements[10].style.clear = "none";})}, +{origCount:1245, fun:(function anonymous() {allElements[10].style['float'] = "right";})}, +{origCount:1246, fun:(function anonymous() {allElements[11].style.width = "20em";})}, +{origCount:1247, fun:(function anonymous() {allElements[4].style.background = "#fcd";})}, +{origCount:1248, fun:(function anonymous() {allElements[8].style.position = "fixed";})}, +{origCount:1249, fun:(function anonymous() {allElements[3].style.clear = "both";})}, +{origCount:1250, fun:(function anonymous() {allElements[7].style.visibility = "collapse";})}, +{origCount:1251, fun:(function anonymous() {allElements[0].style.overflow = "visible";})}, +{origCount:1252, fun:(function anonymous() {allElements[12].style.height = "100px";})}, +{origCount:1253, fun:(function anonymous() {allElements[10].style.clear = "right";})}, +{origCount:1254, fun:(function anonymous() {allElements[0].style.overflow = "hidden";})}, +{origCount:1255, fun:(function anonymous() {allElements[1].style.overflow = "hidden";})}, +{origCount:1256, fun:(function anonymous() {allElements[3].style.position = "static";})}, +{origCount:1257, fun:(function anonymous() {allElements[1].style.width = "10%";})}, +{origCount:1258, fun:(function anonymous() {allElements[12].style['float'] = "right";})}, +{origCount:1259, fun:(function anonymous() {allElements[3].style.overflow = "auto";})}, +{origCount:1260, fun:(function anonymous() {allElements[4].style.color = "green";})}, +{origCount:1261, fun:(function anonymous() {allElements[10].style.width = "auto";})}, +{origCount:1262, fun:(function anonymous() {allElements[11].style.overflow = "hidden";})}, +{origCount:1263, fun:(function anonymous() {allElements[1].style.clear = "none";})}, +{origCount:1264, fun:(function anonymous() {allElements[11].style['float'] = "right";})}, +{origCount:1265, fun:(function anonymous() {allElements[7].style.background = "url(http://www.google.com/images/logo_sm.gif)";})}, +{origCount:1266, fun:(function anonymous() {allElements[7].style.overflow = "visible";})}, +{origCount:1267, fun:(function anonymous() {allElements[5].style['float'] = "left";})}, +{origCount:1268, fun:(function anonymous() {allElements[5].style.position = "fixed";})}, +{origCount:1269, fun:(function anonymous() {allElements[0].style.visibility = "hidden";})}, +{origCount:1270, fun:(function anonymous() {allElements[9].style.height = "100px";})}, +{origCount:1271, fun:(function anonymous() {allElements[10].style.height = "200%";})}, +{origCount:1272, fun:(function anonymous() {allElements[9].style.position = "absolute";})}, +{origCount:1273, fun:(function anonymous() {allElements[12].style.clear = "both";})}, +{origCount:1274, fun:(function anonymous() {allElements[11].style.visibility = "visible";})}, +{origCount:1275, fun:(function anonymous() {allElements[11].style.position = "fixed";})}, +{origCount:1276, fun:(function anonymous() {allElements[6].style.width = "20em";})}, +{origCount:1277, fun:(function anonymous() {allElements[12].style.height = "200%";})}, +{origCount:1278, fun:(function anonymous() {allElements[10].style.display = "list-item";})}, +{origCount:1279, fun:(function anonymous() {allElements[5].style.clear = "left";})}, +{origCount:1280, fun:(function anonymous() {allElements[3].style.clear = "left";})}, +{origCount:1281, fun:(function anonymous() {allElements[8].style.position = "fixed";})}, +{origCount:1282, fun:(function anonymous() {allElements[1].style.overflow = "auto";})}, +{origCount:1283, fun:(function anonymous() {allElements[0].style.height = "10%";})}, +{origCount:1284, fun:(function anonymous() {allElements[10].style['float'] = "right";})}, +{origCount:1285, fun:(function anonymous() {allElements[10].style.clear = "both";})}, +{origCount:1286, fun:(function anonymous() {allElements[7].style.background = "transparent";})}, +{origCount:1287, fun:(function anonymous() {allElements[4].style.visibility = "visible";})}, +{origCount:1288, fun:(function anonymous() {allElements[9].style.display = "-moz-box";})}, +{origCount:1289, fun:(function anonymous() {allElements[0].style.width = "auto";})}, +{origCount:1290, fun:(function anonymous() {allElements[8].style.color = "black";})}, +{origCount:1291, fun:(function anonymous() {allElements[1].style['float'] = "right";})}, +{origCount:1292, fun:(function anonymous() {allElements[9].style.position = "relative";})}, +{origCount:1293, fun:(function anonymous() {allElements[12].style.clear = "none";})}, +{origCount:1294, fun:(function anonymous() {allElements[3].style.width = "1px";})}, +{origCount:1295, fun:(function anonymous() {allElements[12].style.color = "red";})}, +{origCount:1296, fun:(function anonymous() {allElements[6].style.display = "-moz-inline-block";})}, +{origCount:1297, fun:(function anonymous() {allElements[4].style.width = "10%";})}, +{origCount:1298, fun:(function anonymous() {allElements[11].style.height = "2em";})}, +{origCount:1299, fun:(function anonymous() {allElements[6].style.height = "2em";})}, +{origCount:1300, fun:(function anonymous() {allElements[8].style.visibility = "collapse";})}, +{origCount:1301, fun:(function anonymous() {allElements[9].style.position = "absolute";})}, +{origCount:1302, fun:(function anonymous() {allElements[2].style.color = "green";})}, +{origCount:1303, fun:(function anonymous() {allElements[5].style.overflow = "auto";})}, +{origCount:1304, fun:(function anonymous() {allElements[11].style.visibility = "collapse";})}, +{origCount:1305, fun:(function anonymous() {allElements[12].style.color = "black";})}, +{origCount:1306, fun:(function anonymous() {allElements[12].style.background = "transparent";})}, +{origCount:1307, fun:(function anonymous() {allElements[6].style['float'] = "left";})}, +{origCount:1308, fun:(function anonymous() {allElements[11].style['float'] = "right";})}, +{origCount:1309, fun:(function anonymous() {allElements[6].style.clear = "none";})}, +{origCount:1310, fun:(function anonymous() {allElements[10].style.background = "url(http://www.google.com/images/logo_sm.gif)";})}, +{origCount:1311, fun:(function anonymous() {allElements[3].style.display = "-moz-grid-group";})}, +{origCount:1312, fun:(function anonymous() {allElements[3].style['float'] = "right";})}, +{origCount:1313, fun:(function anonymous() {allElements[2].style.color = "blue";})}, +{origCount:1314, fun:(function anonymous() {allElements[5].style.visibility = "hidden";})}, +{origCount:1315, fun:(function anonymous() {allElements[6].style.background = "transparent";})}, +{origCount:1316, fun:(function anonymous() {allElements[9].style['float'] = "right";})}, +{origCount:1317, fun:(function anonymous() {allElements[7].style.background = "#fcd";})}, +{origCount:1318, fun:(function anonymous() {allElements[5].style.visibility = "collapse";})}, +{origCount:1319, fun:(function anonymous() {allElements[9].style.clear = "both";})}, +{origCount:1320, fun:(function anonymous() {allElements[11].style.color = "green";})}, +{origCount:1321, fun:(function anonymous() {allElements[4].style.clear = "none";})}, +{origCount:1322, fun:(function anonymous() {allElements[6].style.display = "-moz-deck";})}, +{origCount:1323, fun:(function anonymous() {allElements[9].style.clear = "none";})}, +{origCount:1324, fun:(function anonymous() {allElements[6].style.position = "static";})}, +{origCount:1325, fun:(function anonymous() {allElements[2].style.overflow = "scroll";})}, +{origCount:1326, fun:(function anonymous() {allElements[3].style.background = "transparent";})}, +{origCount:1327, fun:(function anonymous() {allElements[1].style.overflow = "auto";})}, +{origCount:1328, fun:(function anonymous() {allElements[2].style.visibility = "hidden";})}, +{origCount:1329, fun:(function anonymous() {allElements[10].style.overflow = "hidden";})}, +{origCount:1330, fun:(function anonymous() {allElements[6].style.overflow = "visible";})}, +{origCount:1331, fun:(function anonymous() {allElements[8].style.width = "auto";})}, +{origCount:1332, fun:(function anonymous() {allElements[7].style.width = "200%";})}, +{origCount:1333, fun:(function anonymous() {allElements[11].style.width = "200%";})}, +{origCount:1334, fun:(function anonymous() {allElements[10].style.visibility = "collapse";})}, +{origCount:1335, fun:(function anonymous() {allElements[11].style.background = "transparent";})}, +{origCount:1336, fun:(function anonymous() {allElements[5].style.overflow = "visible";})}, +{origCount:1337, fun:(function anonymous() {allElements[12].style['float'] = "right";})}, +{origCount:1338, fun:(function anonymous() {allElements[10].style.background = "#fcd";})}, +{origCount:1339, fun:(function anonymous() {allElements[6].style['float'] = "right";})}, +{origCount:1340, fun:(function anonymous() {allElements[4].style.visibility = "visible";})}, +{origCount:1341, fun:(function anonymous() {allElements[10].style.height = "auto";})}, +{origCount:1342, fun:(function anonymous() {allElements[3].style.position = "static";})}, +{origCount:1343, fun:(function anonymous() {allElements[2].style.display = "-moz-box";})}, +{origCount:1344, fun:(function anonymous() {allElements[12].style.color = "red";})}, +{origCount:1345, fun:(function anonymous() {allElements[0].style.clear = "none";})}, +{origCount:1346, fun:(function anonymous() {allElements[10].style.clear = "left";})}, +{origCount:1347, fun:(function anonymous() {allElements[8].style['float'] = "none";})}, +{origCount:1348, fun:(function anonymous() {allElements[0].style.visibility = "collapse";})}, +{origCount:1349, fun:(function anonymous() {allElements[4].style.visibility = "hidden";})}, +{origCount:1350, fun:(function anonymous() {allElements[0].style.position = "absolute";})}, +{origCount:1351, fun:(function anonymous() {allElements[6].style.display = "-moz-grid-group";})}, +{origCount:1352, fun:(function anonymous() {allElements[1].style.height = "100px";})}, +{origCount:1353, fun:(function anonymous() {allElements[5].style['float'] = "none";})}, +{origCount:1354, fun:(function anonymous() {allElements[9].style['float'] = "none";})}, +{origCount:1355, fun:(function anonymous() {allElements[5].style.display = "table-footer-group";})}, +{origCount:1356, fun:(function anonymous() {allElements[0].style.clear = "both";})}, +{origCount:1357, fun:(function anonymous() {allElements[11].style.clear = "none";})}, +{origCount:1358, fun:(function anonymous() {allElements[5].style.color = "green";})}, +{origCount:1359, fun:(function anonymous() {allElements[1].style['float'] = "left";})}, +{origCount:1360, fun:(function anonymous() {allElements[3].style.background = "#fcd";})}, +{origCount:1361, fun:(function anonymous() {allElements[5].style.display = "block";})}, +{origCount:1362, fun:(function anonymous() {allElements[11].style.width = "1px";})}, +{origCount:1363, fun:(function anonymous() {allElements[2].style['float'] = "right";})}, +{origCount:1364, fun:(function anonymous() {allElements[8].style.display = "table-column";})}, +{origCount:1365, fun:(function anonymous() {allElements[9].style.width = "20em";})}, +{origCount:1366, fun:(function anonymous() {allElements[10].style.visibility = "visible";})}, +{origCount:1367, fun:(function anonymous() {allElements[4].style['float'] = "none";})}, +{origCount:1368, fun:(function anonymous() {allElements[9].style.visibility = "hidden";})}, +{origCount:1369, fun:(function anonymous() {allElements[5].style.width = "200%";})}, +{origCount:1370, fun:(function anonymous() {allElements[9].style.background = "transparent";})}, +{origCount:1371, fun:(function anonymous() {allElements[2].style.color = "red";})}, +{origCount:1372, fun:(function anonymous() {allElements[2].style.width = "auto";})}, +{origCount:1373, fun:(function anonymous() {allElements[1].style.background = "#fcd";})}, +{origCount:1374, fun:(function anonymous() {allElements[5].style.width = "10%";})}, +{origCount:1375, fun:(function anonymous() {allElements[6].style.overflow = "visible";})}, +{origCount:1376, fun:(function anonymous() {allElements[10].style.display = "-moz-inline-block";})}, +{origCount:1377, fun:(function anonymous() {allElements[8].style.visibility = "collapse";})}, +{origCount:1378, fun:(function anonymous() {allElements[7].style.display = "inline";})}, +{origCount:1379, fun:(function anonymous() {allElements[11].style.position = "fixed";})}, +{origCount:1380, fun:(function anonymous() {allElements[1].style.display = "-moz-stack";})}, +{origCount:1381, fun:(function anonymous() {allElements[7].style.clear = "left";})}, +{origCount:1382, fun:(function anonymous() {allElements[9].style.overflow = "auto";})}, +{origCount:1383, fun:(function anonymous() {allElements[0].style.height = "10%";})}, +{origCount:1384, fun:(function anonymous() {allElements[10].style.overflow = "scroll";})}, +{origCount:1385, fun:(function anonymous() {allElements[7].style.height = "100px";})}, +{origCount:1386, fun:(function anonymous() {allElements[8].style.overflow = "auto";})}, +{origCount:1387, fun:(function anonymous() {allElements[6].style.background = "#fcd";})}, +{origCount:1388, fun:(function anonymous() {allElements[7].style.width = "auto";})}, +{origCount:1389, fun:(function anonymous() {allElements[3].style.position = "relative";})}, +{origCount:1390, fun:(function anonymous() {allElements[12].style.width = "10%";})}, +{origCount:1391, fun:(function anonymous() {allElements[1].style.position = "absolute";})}, +{origCount:1392, fun:(function anonymous() {allElements[1].style.background = "url(http://www.google.com/images/logo_sm.gif)";})}, +{origCount:1393, fun:(function anonymous() {allElements[5].style.clear = "left";})}, +{origCount:1394, fun:(function anonymous() {allElements[4].style['float'] = "left";})}, +{origCount:1395, fun:(function anonymous() {allElements[6].style.width = "20em";})}, +{origCount:1396, fun:(function anonymous() {allElements[0].style.height = "200%";})}, +{origCount:1397, fun:(function anonymous() {allElements[8].style.width = "200%";})}, +{origCount:1398, fun:(function anonymous() {allElements[6].style.height = "auto";})}, +{origCount:1399, fun:(function anonymous() {allElements[2].style.overflow = "scroll";})}, +{origCount:1400, fun:(function anonymous() {allElements[1].style.clear = "left";})}, +{origCount:1401, fun:(function anonymous() {allElements[7].style.display = "-moz-box";})}, +{origCount:1402, fun:(function anonymous() {allElements[0].style['float'] = "none";})}, +{origCount:1403, fun:(function anonymous() {allElements[0].style.clear = "none";})}, +{origCount:1404, fun:(function anonymous() {allElements[10].style.height = "100px";})}, +{origCount:1405, fun:(function anonymous() {allElements[11].style.width = "20em";})}, +{origCount:1406, fun:(function anonymous() {allElements[9].style.clear = "both";})}, +{origCount:1407, fun:(function anonymous() {allElements[7].style.position = "static";})}, +{origCount:1408, fun:(function anonymous() {allElements[12].style['float'] = "none";})}, +{origCount:1409, fun:(function anonymous() {allElements[4].style.position = "static";})}, +{origCount:1410, fun:(function anonymous() {allElements[0].style.height = "200%";})}, +{origCount:1411, fun:(function anonymous() {allElements[7].style['float'] = "none";})}, +{origCount:1412, fun:(function anonymous() {allElements[3].style.clear = "none";})}, +{origCount:1413, fun:(function anonymous() {allElements[6].style.color = "green";})}, +{origCount:1414, fun:(function anonymous() {allElements[10].style.height = "200%";})}, +{origCount:1415, fun:(function anonymous() {allElements[7].style.overflow = "visible";})} + + ]; + + +var output = eval(commands.toSource().replace(/anonymous/g,"")).toSource().replace( /\)\},/g , ")},\n"); + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/non262/extensions/regress-311792-01.js b/js/src/tests/non262/extensions/regress-311792-01.js new file mode 100644 index 0000000000..8579b7c933 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-311792-01.js @@ -0,0 +1,26 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 311792; +var summary = 'Root Array.prototype methods'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +function index_getter() +{ + gc(); + return 100; +} + +var a = [0, 1]; +a.__defineGetter__(0, index_getter); + +a.slice(0, 1).join(); + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/non262/extensions/regress-311792-02.js b/js/src/tests/non262/extensions/regress-311792-02.js new file mode 100644 index 0000000000..3b01415598 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-311792-02.js @@ -0,0 +1,40 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 311792; +var summary = 'Root Array.prototype methods'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +var subverted = 0; + +function index_getter() +{ + delete a[0]; + gc(); + for (var i = 0; i != 1 << 14; ++i) { + var tmp = new String("test"); + tmp = null; + } + return 1; +} + +function index_setter(value) +{ + subverted = value; +} + +var a = [ Math.sqrt(2), 0 ]; +a.__defineGetter__(1, index_getter); +a.__defineSetter__(1, index_setter); + +a.reverse(); +printStatus(subverted) + + reportCompare(expect, actual, summary); diff --git a/js/src/tests/non262/extensions/regress-313763.js b/js/src/tests/non262/extensions/regress-313763.js new file mode 100644 index 0000000000..c5ecfb2d8e --- /dev/null +++ b/js/src/tests/non262/extensions/regress-313763.js @@ -0,0 +1,46 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 313763; +var summary = 'Root jsarray.c creatures'; +var actual = ''; +var expect = ''; + +printBugNumber(BUGNUMBER); +printStatus (summary); +printStatus ('This bug requires TOO_MUCH_GC'); + +var N = 0x80000002; +var array = Array(N); +array[N - 1] = 1; +array[N - 2] = 2; + +// Set getter not to wait until engine loops through 2^31 holes in the array. +var LOOP_TERMINATOR = "stop_long_loop"; +array.__defineGetter__(N - 2, function() { + throw "stop_long_loop"; + }); + +var prepared_string = String(1); +array.__defineGetter__(N - 1, function() { + var tmp = prepared_string; + prepared_string = null; + return tmp; + }) + + + try { + array.unshift(1); + } catch (e) { + if (e !== LOOP_TERMINATOR) + throw e; + } + +var expect = "1"; +var actual = array[N]; +printStatus(expect === actual); + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/non262/extensions/regress-314874.js b/js/src/tests/non262/extensions/regress-314874.js new file mode 100644 index 0000000000..867e127044 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-314874.js @@ -0,0 +1,35 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 314874; +var summary = 'Function.call/apply with non-primitive argument'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + var thisArg = { valueOf: function() { return {a: 'a', b: 'b'}; } }; + + var f = function () { return (this); }; + + expect = f.call(thisArg); + + thisArg.f = f; + + actual = thisArg.f(); + + delete thisArg.f; + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-315509-02.js b/js/src/tests/non262/extensions/regress-315509-02.js new file mode 100644 index 0000000000..40e64b7ea4 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-315509-02.js @@ -0,0 +1,42 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 315509; +var summary = 'Array.prototype.unshift do not crash on Arrays with holes'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +function x1() { + var a = new Array(1); + a.unshift(1); +} +function x2() { + var a = new Array(1); + a.unshift.call(a, 1); +} +function x3() { + var a = new Array(1); + a.x = a.unshift; + a.x(1); +} +function x4() { + var a = new Array(1); + a.__defineSetter__("x", a.unshift); + a.x = 1; +} + +for (var i = 0; i < 10; i++) +{ + x1(); + x2(); + x3(); + x4(); +} + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/non262/extensions/regress-319683.js b/js/src/tests/non262/extensions/regress-319683.js new file mode 100644 index 0000000000..47e0e8042d --- /dev/null +++ b/js/src/tests/non262/extensions/regress-319683.js @@ -0,0 +1,31 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 319683; +var summary = 'Do not crash in call_enumerate'; +var actual = 'No Crash'; +var expect = 'No Crash'; +printBugNumber(BUGNUMBER); +printStatus (summary); + +function crash(){ + function f(){ + var x; + function g(){ + x=1; //reference anything here or will not crash. + } + } + + //apply an object to the __proto__ attribute + f.__proto__={}; + + //the following call will cause crash + f(); +} + +crash(); + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/non262/extensions/regress-320854.js b/js/src/tests/non262/extensions/regress-320854.js new file mode 100644 index 0000000000..8486924d60 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-320854.js @@ -0,0 +1,20 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 320854; +var summary = 'o.hasOwnProperty("length") should not lie when o has function in proto chain'; +var actual = ''; +var expect = ''; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +var o = {__proto__:function(){}}; + +expect = false; +actual = o.hasOwnProperty('length') + + reportCompare(expect, actual, summary); diff --git a/js/src/tests/non262/extensions/regress-327170.js b/js/src/tests/non262/extensions/regress-327170.js new file mode 100644 index 0000000000..f9f63be4b2 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-327170.js @@ -0,0 +1,25 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 327170; +var summary = 'Reuse of RegExp in string.replace(rx.compile(...), function() { rx.compile(...); }) causes a crash'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +var g_rx = /(?:)/; + +"this is a test-string".replace(g_rx.compile("test", "g"), + function() + { + // re-use of the g_rx RegExp object, + // that's currently in use by the replace fn. + g_rx.compile("string", "g"); + }); + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/non262/extensions/regress-327608.js b/js/src/tests/non262/extensions/regress-327608.js new file mode 100644 index 0000000000..64162d6741 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-327608.js @@ -0,0 +1,42 @@ +// |reftest| skip-if(xulRuntime.shell) +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 327608; +var summary = 'Do not assume we will find the prototype property'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +printBugNumber(BUGNUMBER); +printStatus (summary); +print('This test runs only in the browser'); + +function countProps(obj) +{ + var c; + for (var prop in obj) + ++c; + return c; +} + +function init() +{ + var inp = document.getElementsByTagName("input")[0]; + countProps(inp); + gc(); + var blurfun = inp.blur; + blurfun.__proto__ = null; + countProps(blurfun); + reportCompare(expect, actual, summary); + gDelayTestDriverEnd = false; + jsTestDriverEnd(); +} + +// delay test driver end +gDelayTestDriverEnd = true; + +document.write('<input>'); +window.addEventListener("load", init, false); diff --git a/js/src/tests/non262/extensions/regress-328443.js b/js/src/tests/non262/extensions/regress-328443.js new file mode 100644 index 0000000000..897ee8fc1b --- /dev/null +++ b/js/src/tests/non262/extensions/regress-328443.js @@ -0,0 +1,32 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 328443; +var summary = 'Uncatchable exception with |new (G.call) (F);| when F proto is null'; +var actual = ''; +var expect = 'Exception caught'; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +var F = (function(){}); +F.__proto__ = null; + +var G = (function(){}); + +var z; + +z = "uncatchable exception!!!"; +try { + new (G.call) (F); + + actual = "No exception"; +} catch (er) { + actual = "Exception caught"; + printStatus("Exception was caught: " + er); +} + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/non262/extensions/regress-330569.js b/js/src/tests/non262/extensions/regress-330569.js new file mode 100644 index 0000000000..57114781a6 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-330569.js @@ -0,0 +1,91 @@ +// |reftest| slow +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 330569; +var summary = 'RegExp - throw InternalError on too complex regular expressions'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + var s; + expect = 'InternalError: regular expression too complex'; + + s = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">' + + '<html>\n' + + '<head>\n' + + '<meta http-equiv="content-type" content="text/html; charset=windows-1250">\n' + + '<meta name="generator" content="PSPad editor, www.pspad.com">\n' + + '<title></title>\n'+ + '</head>\n' + + '<body>\n' + + '<!-- hello -->\n' + + '<script language="JavaScript">\n' + + 'var s = document. body. innerHTML;\n' + + 'var d = s. replace (/<!--(.*|\n)*-->/, "");\n' + + 'alert (d);\n' + + '</script>\n' + + '</body>\n' + + '</html>\n'; + + try + { + /<!--(.*|\n)*-->/.exec(s); + } + catch(ex) + { + actual = ex + ''; + } + + reportCompare(expect, actual, summary + ': /<!--(.*|\\n)*-->/.exec(s)'); + + function testre( re, n ) { + for ( var i= 0; i <= n; ++i ) { + re.test( Array( i+1 ).join() ); + } + } + + try + { + testre( /(?:,*)*x/, 22 ); + } + catch(ex) + { + actual = ex + ''; + } + + reportCompare(expect, actual, summary + ': testre( /(?:,*)*x/, 22 )'); + + try + { + testre( /(?:,|,)*x/, 22 ); + } + catch(ex) + { + actual = ex + ''; + } + + reportCompare(expect, actual, summary + ': testre( /(?:,|,)*x/, 22 )'); + + try + { + testre( /(?:,|,|,|,|,)*x/, 10 ); + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, summary + ': testre( /(?:,|,|,|,|,)*x/, 10 )'); +} diff --git a/js/src/tests/non262/extensions/regress-333541.js b/js/src/tests/non262/extensions/regress-333541.js new file mode 100644 index 0000000000..d577ad9124 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-333541.js @@ -0,0 +1,59 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 333541; +var summary = '1..toSource()'; +var actual = ''; +var expect = ''; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +function a(){ + return 1..toSource(); +} + +try +{ + expect = 'function a(){\n return 1..toSource();\n}'; + actual = a.toString(); + compareSource(expect, actual, summary + ': 1'); +} +catch(ex) +{ + actual = ex + ''; + reportCompare(expect, actual, summary + ': 1'); +} + +if (Function.prototype.toSource) { + try + { + expect = 'function a(){\n return 1..toSource();\n}'; + actual = a.toSource(); + compareSource(expect, actual, summary + ': 2'); + } + catch(ex) + { + actual = ex + ''; + reportCompare(expect, actual, summary + ': 2'); + } +} + +expect = a; +actual = a.valueOf(); +reportCompare(expect, actual, summary + ': 3'); + +try +{ + expect = 'function a(){\n return 1..toSource();\n}'; + actual = "" + a; + compareSource(expect, actual, summary + ': 4'); +} +catch(ex) +{ + actual = ex + ''; + reportCompare(expect, actual, summary + ': 4'); +} diff --git a/js/src/tests/non262/extensions/regress-336409-1.js b/js/src/tests/non262/extensions/regress-336409-1.js new file mode 100644 index 0000000000..1f03dfd2b6 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-336409-1.js @@ -0,0 +1,50 @@ +// |reftest| skip-if(!Object.prototype.toSource||!xulRuntime.shell||Android) slow -- no results reported. +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 336409; +var summary = 'Integer overflow in js_obj_toSource'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +expectExitCode(0); +expectExitCode(5); + +function createString(n) +{ + var l = n*1024*1024; + var r = 'r'; + + while (r.length < l) + { + r = r + r; + } + return r; +} + +try +{ + var n = 64; + printStatus('Creating ' + n + 'MB string'); + var r = createString(n); + printStatus('Done. length = ' + r.length); + printStatus('Creating object'); + var o = {f1: r, f2: r, f3: r,f4: r,f5: r, f6: r, f7: r, f8: r,f9: r}; + printStatus('object.toSource()'); + var rr = o.toSource(); + printStatus('Done.'); +} +catch(ex) +{ + expect = 'InternalError: allocation size overflow'; + actual = ex + ''; + print(actual); +} + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/non262/extensions/regress-336409-2.js b/js/src/tests/non262/extensions/regress-336409-2.js new file mode 100644 index 0000000000..545350150b --- /dev/null +++ b/js/src/tests/non262/extensions/regress-336409-2.js @@ -0,0 +1,49 @@ +// |reftest| skip-if(!Object.prototype.toSource||(!xulRuntime.shell&&((Android||(isDebugBuild&&xulRuntime.OS=="Linux")||xulRuntime.XPCOMABI.match(/x86_64/))))) slow -- can fail silently due to out of memory, bug 615011 - timeouts on slow debug Linux +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 336409; +var summary = 'Integer overflow in js_obj_toSource'; +var actual = 'No Crash'; +var expect = /(No Crash|InternalError: allocation size overflow|out of memory)/; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +expectExitCode(0); +expectExitCode(5); + +function createString(n) +{ + var l = n*1024*1024; + var r = 'r'; + + while (r.length < l) + { + r = r + r; + } + return r; +} + +try +{ + var n = 128; + printStatus('Creating ' + n + 'MB string'); + var r = createString(n); + printStatus('Done. length = ' + r.length); + printStatus('Creating object'); + var o = {f1: r, f2: r, f3: r,f4: r,f5: r, f6: r, f7: r, f8: r,f9: r}; + printStatus('object.toSource()'); + var rr = o.toSource(); + printStatus('Done.'); +} +catch(ex) +{ + actual = ex + ''; + print(actual); +} + +reportMatch(expect, actual, summary); diff --git a/js/src/tests/non262/extensions/regress-336410-1.js b/js/src/tests/non262/extensions/regress-336410-1.js new file mode 100644 index 0000000000..869a7b9429 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-336410-1.js @@ -0,0 +1,50 @@ +// |reftest| skip-if(!Object.prototype.toSource||!xulRuntime.shell||Android) slow -- can fail silently due to out of memory +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 336410; +var summary = 'Integer overflow in array_toSource'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +expectExitCode(0); +expectExitCode(5); + +function createString(n) +{ + var l = n*1024*1024; + var r = 'r'; + + while (r.length < l) + { + r = r + r; + } + return r; +} + +try +{ + var n = 64; + printStatus('Creating ' + n + 'M length string'); + var r = createString(n); + printStatus('Done. length = ' + r.length); + printStatus('Creating array'); + var o=[r, r, r, r, r, r, r, r, r]; + printStatus('object.toSource()'); + var rr = o.toSource(); + printStatus('Done.'); +} +catch(ex) +{ + expect = '\(InternalError: allocation size overflow|out of memory\)'; + actual = ex + ''; + print(actual); +} + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/non262/extensions/regress-336410-2.js b/js/src/tests/non262/extensions/regress-336410-2.js new file mode 100644 index 0000000000..bd0952e9e6 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-336410-2.js @@ -0,0 +1,49 @@ +// |reftest| skip-if(!Object.prototype.toSource||(!xulRuntime.shell&&((isDebugBuild&&xulRuntime.OS=="Linux")||Android||xulRuntime.XPCOMABI.match(/x86_64/)||xulRuntime.OS=="WINNT"))) slow -- can fail silently due to out of memory, bug 621348 - timeouts on slow debug Linux +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 336410; +var summary = 'Integer overflow in array_toSource'; +var actual = 'No Crash'; +var expect = /(No Crash|InternalError: allocation size overflow|out of memory)/; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +expectExitCode(0); +expectExitCode(5); + +function createString(n) +{ + var l = n*1024*1024; + var r = 'r'; + + while (r.length < l) + { + r = r + r; + } + return r; +} + +try +{ + var n = 128; + printStatus('Creating ' + n + 'M length string'); + var r = createString(n); + printStatus('Done. length = ' + r.length); + printStatus('Creating array'); + var o=[r, r, r, r, r, r, r, r, r]; + printStatus('object.toSource()'); + var rr = o.toSource(); + printStatus('Done.'); +} +catch(ex) +{ + actual = ex + ''; + print(actual); +} + +reportMatch(expect, actual, summary); diff --git a/js/src/tests/non262/extensions/regress-339685.js b/js/src/tests/non262/extensions/regress-339685.js new file mode 100644 index 0000000000..295a080686 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-339685.js @@ -0,0 +1,27 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 339685; +var summary = 'Setting __proto__ null should not affect __iterator__'; +var actual = ''; +var expect = 'No Error'; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +var d = { a:2, b:3 }; + +d.__proto__ = null; + +try { + for (var p in d) + ; + actual = 'No Error'; +} catch(e) { + actual = e + ''; +} + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/non262/extensions/regress-341956-01.js b/js/src/tests/non262/extensions/regress-341956-01.js new file mode 100644 index 0000000000..2e40bd9350 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-341956-01.js @@ -0,0 +1,65 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 341956; +var summary = 'GC Hazards in jsarray.c - unshift'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + var N = 0xFFFFFFFF; + + var a = []; + a[N - 1] = 1; + a.__defineGetter__(N - 1, function() { + var tmp = []; + tmp[N - 2] = 0; + if (typeof gc == 'function') + gc(); + for (var i = 0; i != 50000; ++i) { + var tmp = 1 / 3; + tmp /= 10; + } + for (var i = 0; i != 1000; ++i) { + // Make string with 11 characters that would take + // (11 + 1) * 2 bytes or sizeof(JSAtom) so eventually + // malloc will ovewrite just freed atoms. + var tmp2 = Array(12).join(' '); + } + return 10; + }); + + +// The following always-throw getter is to stop unshift from doing +// 2^32 iterations. + var toStop = "stringToStop"; + a[N - 3] = 0; + a.__defineGetter__(N - 3, function() { throw toStop; }); + + var good = false; + + try { + a.unshift(1); + } catch (e) { + if (e === toStop) + good = true; + } + + expect = true; + actual = good; + + reportCompare(expect, actual, summary); + + print('Done'); +} diff --git a/js/src/tests/non262/extensions/regress-341956-02.js b/js/src/tests/non262/extensions/regress-341956-02.js new file mode 100644 index 0000000000..0957c03ae5 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-341956-02.js @@ -0,0 +1,52 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 341956; +var summary = 'GC Hazards in jsarray.c - pop'; +var actual = ''; +var expect = 'GETTER RESULT'; + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + var N = 0xFFFFFFFF; + var a = []; + a[N - 1] = 0; + + var expected = "GETTER RESULT"; + + a.__defineGetter__(N - 1, function() { + delete a[N - 1]; + var tmp = []; + tmp[N - 2] = 1; + + if (typeof gc == 'function') + gc(); + for (var i = 0; i != 50000; ++i) { + var tmp = 1 / 3; + tmp /= 10; + } + for (var i = 0; i != 1000; ++i) { + // Make string with 11 characters that would take + // (11 + 1) * 2 bytes or sizeof(JSAtom) so eventually + // malloc will ovewrite just freed atoms. + var tmp2 = Array(12).join(' '); + } + return expected; + }); + + actual = a.pop(); + + reportCompare(expect, actual, summary); + + print('Done'); +} diff --git a/js/src/tests/non262/extensions/regress-341956-03.js b/js/src/tests/non262/extensions/regress-341956-03.js new file mode 100644 index 0000000000..2985dfb2bc --- /dev/null +++ b/js/src/tests/non262/extensions/regress-341956-03.js @@ -0,0 +1,69 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 341956; +var summary = 'GC Hazards in jsarray.c - reverse'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + var N = 0xFFFFFFFF; + var a = []; + a[N - 1] = 0; + + var expected = "GETTER RESULT"; + + a.__defineGetter__(N - 1, function() { + delete a[N - 1]; + var tmp = []; + tmp[N - 2] = 1; + + if (typeof gc == 'function') + gc(); + for (var i = 0; i != 50000; ++i) { + var tmp = 1 / 3; + tmp /= 10; + } + for (var i = 0; i != 1000; ++i) { + // Make string with 11 characters that would take + // (11 + 1) * 2 bytes or sizeof(JSAtom) so eventually + // malloc will ovewrite just freed atoms. + var tmp2 = Array(12).join(' '); + } + return expected; + }); + +// The following always-throw getter is to stop unshift from doing +// 2^32 iterations. + var toStop = "stringToStop"; + a[N - 3] = 0; + a.__defineGetter__(N - 3, function() { throw toStop; }); + + + var good = false; + + try { + a.reverse(); + } catch (e) { + if (e === toStop) + good = true; + } + + expect = true; + actual = good; + + reportCompare(expect, actual, summary); + + print('Done'); +} diff --git a/js/src/tests/non262/extensions/regress-342960.js b/js/src/tests/non262/extensions/regress-342960.js new file mode 100644 index 0000000000..d7d8f8a0c1 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-342960.js @@ -0,0 +1,43 @@ +// |reftest| skip-if(!Object.prototype.toSource||(!xulRuntime.shell&&(Android||xulRuntime.OS=="WINNT"||xulRuntime.OS=="Linux"))) silentfail slow -- bug 528464 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 342960; +var summary = 'Do not crash on large string toSource'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + expectExitCode(0); + expectExitCode(5); + + function v() + { + var meg=""; + var r=""; + var i; + print("don't interrupt the script. let it go."); + for(i=0;i<1024*1024;i++) meg += "v"; + for(i=0;i<1024/8;i++) r += meg; + var o={f1: r, f2: r, f3: r,f4: r,f5: r, f6: r, f7: r, f8: r,f9: r}; + print('done obj'); + var rr=r.toSource(); + print('done toSource()'); + } + + v(); + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-345967.js b/js/src/tests/non262/extensions/regress-345967.js new file mode 100644 index 0000000000..0ca7f71c91 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-345967.js @@ -0,0 +1,65 @@ +// |reftest| slow +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 345967; +var summary = 'Yet another unrooted atom in jsarray.c'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + expectExitCode(0); + expectExitCode(3); + + print('This test will probably run out of memory'); + print('This test really should only fail on 64 bit machines'); + + var JSVAL_INT_MAX = (1 << 30) - 1; + + var a = new Array(JSVAL_INT_MAX + 2); + a[JSVAL_INT_MAX] = 0; + a[JSVAL_INT_MAX + 1] = 1; + + a.__defineGetter__(JSVAL_INT_MAX, function() { return 0; }); + + a.__defineSetter__(JSVAL_INT_MAX, function(value) { + delete a[JSVAL_INT_MAX + 1]; + var tmp = []; + tmp[JSVAL_INT_MAX + 2] = 2; + + if (typeof gc == 'function') + gc(); + for (var i = 0; i != 50000; ++i) { + var tmp = 1 / 3; + tmp /= 10; + } + for (var i = 0; i != 1000; ++i) { + // Make string with 11 characters that would take + // (11 + 1) * 2 bytes or sizeof(JSAtom) so eventually + // malloc will ovewrite just freed atoms. + var tmp2 = Array(12).join(' '); + } + }); + + + a.shift(); + + expect = 0; + actual = a[JSVAL_INT_MAX]; + if (expect !== actual) + print("BAD"); + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-346642-06.js b/js/src/tests/non262/extensions/regress-346642-06.js new file mode 100644 index 0000000000..e2617038f8 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-346642-06.js @@ -0,0 +1,59 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 346642; +var summary = 'decompilation of destructuring assignment'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = 3; + actual = ''; + "" + function() { [] = 3 }; actual = 3; + actual = 3; + reportCompare(expect, actual, summary + ': 1'); + + try + { + var z = 6; + var f = eval('(function (){for(let [] = []; false;) let z; return z})'); + expect = f(); + actual = eval("("+f+")")() + reportCompare(expect, actual, summary + ': 2'); + } + catch(ex) + { + // See https://bugzilla.mozilla.org/show_bug.cgi?id=408957 + var summarytrunk = 'let declaration must be direct child of block or top-level implicit block'; + expect = 'SyntaxError'; + actual = ex.name; + reportCompare(expect, actual, summarytrunk); + } + + expect = 3; + actual = ''; + "" + function () { for(;; [[a]] = [5]) { } }; actual = 3; + reportCompare(expect, actual, summary + ': 3'); + + expect = 3; + actual = ''; + "" + function () { for(;; ([[,]] = p)) { } }; actual = 3; + reportCompare(expect, actual, summary + ': 4'); + + expect = 3; + actual = ''; + actual = 1; try {for(x in (function ([y]) { })() ) { }}catch(ex){} actual = 3; + reportCompare(expect, actual, summary + ': 5'); +} diff --git a/js/src/tests/non262/extensions/regress-346773.js b/js/src/tests/non262/extensions/regress-346773.js new file mode 100644 index 0000000000..024da5c720 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-346773.js @@ -0,0 +1,49 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 346773; +var summary = 'Do not crash compiling with misplaced branches in function'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + try + { + var src = + ' var it = {foo:"5"};' + + ' it.__iterator__ =' + + ' function(valsOnly)' + + ' {' + + ' var gen =' + + ' function()' + + ' {' + + ' for (var i = 0; i < keys.length; i++)' + + ' {' + + ' if (valsOnly)' + + ' yield vals[i];' + + ' else' + + ' yield [keys[i], vals[i]];' + + ' }' + + ' return gen();' + + ' }' + + ' }'; + eval(src); + } + catch(ex) + { + } + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-350312-01.js b/js/src/tests/non262/extensions/regress-350312-01.js new file mode 100644 index 0000000000..84ee0cd4a3 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-350312-01.js @@ -0,0 +1,43 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 350312; +var summary = 'Accessing wrong stack slot with nested catch/finally'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + var tmp; + + function f() + { + try { + try { + throw 1; + } catch (e) { + throw e; + } finally { + tmp = true; + } + } catch (e) { + return e; + } + } + + var ex = f(); + + var passed = ex === 1; + reportCompare(true, passed, summary); +} diff --git a/js/src/tests/non262/extensions/regress-350312.js b/js/src/tests/non262/extensions/regress-350312.js new file mode 100644 index 0000000000..c10d849018 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-350312.js @@ -0,0 +1,66 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 350312; +var summary = 'Accessing wrong stack slot with nested catch/finally'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + var iter; + function* gen() + { + try { + yield iter; + } catch (e) { + if (e != null) + throw e; + actual += 'CATCH,'; + print("CATCH"); + } finally { + actual += 'FINALLY'; + print("FINALLY"); + } + } + + expect = 'FINALLY'; + actual = ''; + (iter = gen()).next().value.return(); + reportCompare(expect, actual, summary); + + expect = 'FINALLY'; + actual = ''; + try + { + (iter = gen()).next().value.throw(1); + } + catch(ex) + { + } + reportCompare(expect, actual, summary); + + expect = 'CATCH,FINALLY'; + actual = ''; + try + { + (iter = gen()).next().value.throw(null); + } + catch(ex) + { + } + reportCompare(expect, actual, summary); + + reportCompare((iter = gen()).next().value.next().value, undefined, summary); +} diff --git a/js/src/tests/non262/extensions/regress-351070-02.js b/js/src/tests/non262/extensions/regress-351070-02.js new file mode 100644 index 0000000000..ec288d859d --- /dev/null +++ b/js/src/tests/non262/extensions/regress-351070-02.js @@ -0,0 +1,65 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 351070; +var summary = 'decompilation of let declaration should not change scope'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + try + { + var pfx = "(function f() { var n = 2, a = 2; ", + decl = " let a = 3;", + end = " return a; })"; + + var table = [ + ["if (!!true)", ""], + ["if (!!true)", " else foopy();"], + ["if (!true); else", ""], + ["do ", " while (false);"], + ["while (--n)", ""], + ["for (--n;n;--n)", ""], + ["for (a in this)", ""], + ["with (this)", ""], + ]; + + expect = 3; + + for (i = 0; i < table.length; i++) { + var src = pfx + table[i][0] + decl + table[i][1] + end; + print('src: ' + src); + var fun = eval(src); + var testval = fun(); + reportCompare(expect, testval, summary + ': ' + src); + if (testval != expect) { + break; + } + var declsrc = '(' + + src.slice(1, -1).replace('function f', 'function f' + i) + ')'; + print('declsrc: ' + declsrc); + this['f' + i] = eval(declsrc); + print('f' + i + ': ' + this['f' + i]); + } + } + catch(ex) + { + // See https://bugzilla.mozilla.org/show_bug.cgi?id=408957 + summary = 'let declaration must be direct child of block or top-level implicit block'; + expect = 'SyntaxError'; + actual = ex.name; + reportCompare(expect, actual, summary); + } +} diff --git a/js/src/tests/non262/extensions/regress-351448.js b/js/src/tests/non262/extensions/regress-351448.js new file mode 100644 index 0000000000..9384d21b17 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-351448.js @@ -0,0 +1,59 @@ +// |reftest| slow +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 351448; +var summary = 'RegExp - throw InternalError on too complex regular expressions'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + var strings = [ + "/.X(.+)+X/.exec('bbbbXXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')", + "/.X(.+)+X/.exec('bbbbXcXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')", + "/.X(.+)+XX/.exec('bbbbXXXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')", + "/.X(.+)+XX/.exec('bbbbXcXXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')", + "/.X(.+)+[X]/.exec('bbbbXXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')", + "/.X(.+)+[X]/.exec('bbbbXcXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')", + "/.X(.+)+[X][X]/.exec('bbbbXXXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')", + "/.X(.+)+[X][X]/.exec('bbbbXcXXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')", + "/.XX(.+)+X/.exec('bbbbXXXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')", + "/.XX(.+)+X/.exec('bbbbXXcXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')", + "/.XX(.+)+X/.exec('bbbbXXcXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')", + "/.XX(.+)+[X]/.exec('bbbbXXXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')", + "/.XX(.+)+[X]/.exec('bbbbXXcXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')", + "/.[X](.+)+[X]/.exec('bbbbXXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')", + "/.[X](.+)+[X]/.exec('bbbbXcXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')", + "/.[X](.+)+[X][X]/.exec('bbbbXXXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')", + "/.[X](.+)+[X][X]/.exec('bbbbXcXXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')", + "/.[X][X](.+)+[X]/.exec('bbbbXXXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')", + "/.[X][X](.+)+[X]/.exec('bbbbXXcXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')" + ]; + + expect = 'InternalError: regular expression too complex'; + + for (var i = 0; i < strings.length; i++) + { + try + { + eval(strings[i]); + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, summary + ': ' + strings[i]); + } +} diff --git a/js/src/tests/non262/extensions/regress-351463-01.js b/js/src/tests/non262/extensions/regress-351463-01.js new file mode 100644 index 0000000000..e7a9ce7ce7 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-351463-01.js @@ -0,0 +1,250 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 351463; +var summary = 'Treat hyphens as not special adjacent to CharacterClassEscapes in character classes'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + var r; + var s = 'a0- z'; + + r = '([\\d-\\s]+)'; + expect = ['0- ', '0- '] + ''; + actual = null; + + try + { + actual = new RegExp(r).exec(s) + ''; + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")'); + + r = '([\\s-\\d]+)'; + expect = ['0- ', '0- '] + ''; + actual = null; + + try + { + actual = new RegExp(r).exec(s) + ''; + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")'); + + r = '([\\D-\\s]+)'; + expect = ['a', 'a'] + ''; + actual = null; + + try + { + actual = new RegExp(r).exec(s) + ''; + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")'); + + r = '([\\s-\\D]+)'; + expect = ['a', 'a'] + ''; + actual = null; + + try + { + actual = new RegExp(r).exec(s) + ''; + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")'); + + r = '([\\d-\\S]+)'; + expect = ['a0-', 'a0-'] + ''; + actual = null; + + try + { + actual = new RegExp(r).exec(s) + ''; + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")'); + + r = '([\\S-\\d]+)'; + expect = ['a0-', 'a0-'] + ''; + actual = null; + + try + { + actual = new RegExp(r).exec(s) + ''; + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")'); + + r = '([\\D-\\S]+)'; + expect = ['a0- z', 'a0- z'] + ''; + actual = null; + + try + { + actual = new RegExp(r).exec(s) + ''; + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")'); + + r = '([\\S-\\D]+)'; + expect = ['a0- z', 'a0- z'] + ''; + actual = null; + + try + { + actual = new RegExp(r).exec(s) + ''; + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")'); + +// -- + + r = '([\\w-\\s]+)'; + expect = ['a0- z', 'a0- z'] + ''; + actual = null; + + try + { + actual = new RegExp(r).exec(s) + ''; + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")'); + + r = '([\\s-\\w]+)'; + expect = ['a0- z', 'a0- z'] + ''; + actual = null; + + try + { + actual = new RegExp(r).exec(s) + ''; + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")'); + + r = '([\\W-\\s]+)'; + expect = ['- ', '- '] + ''; + actual = null; + + try + { + actual = new RegExp(r).exec(s) + ''; + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")'); + + r = '([\\s-\\W]+)'; + expect = ['- ', '- '] + ''; + actual = null; + + try + { + actual = new RegExp(r).exec(s) + ''; + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")'); + + r = '([\\w-\\S]+)'; + expect = ['a0-', 'a0-'] + ''; + actual = null; + + try + { + actual = new RegExp(r).exec(s) + ''; + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")'); + + r = '([\\S-\\w]+)'; + expect = ['a0-', 'a0-'] + ''; + actual = null; + + try + { + actual = new RegExp(r).exec(s) + ''; + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")'); + + r = '([\\W-\\S]+)'; + expect = ['a0- z', 'a0- z'] + ''; + actual = null; + + try + { + actual = new RegExp(r).exec(s) + ''; + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")'); + + r = '([\\S-\\W]+)'; + expect = ['a0- z', 'a0- z'] + ''; + actual = null; + + try + { + actual = new RegExp(r).exec(s) + ''; + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")'); +} diff --git a/js/src/tests/non262/extensions/regress-351973.js b/js/src/tests/non262/extensions/regress-351973.js new file mode 100644 index 0000000000..a24c3ab6f6 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-351973.js @@ -0,0 +1,50 @@ +// |reftest| skip-if(!Object.prototype.toSource) + +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 351973; +var summary = 'GC hazard with unrooted ids in Object.toSource'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + function removeAllProperties(o) + { + for (var prop in o) + delete o[prop]; + for (var i = 0; i != 50*1000; ++i) { + var tmp = Math.sqrt(i+0.2); + tmp = 0; + } + if (typeof gc == "function") + gc(); + } + + function run_test() + { + + var o = {}; + o.first = { toSource: function() { removeAllProperties(o); } }; + for (var i = 0; i != 10; ++i) { + o[Math.sqrt(i + 0.1)] = 1; + } + return o.toSource(); + } + + print(run_test()); + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-352291.js b/js/src/tests/non262/extensions/regress-352291.js new file mode 100644 index 0000000000..f3c19b06c8 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-352291.js @@ -0,0 +1,38 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 352291; +var summary = 'disassembly of regular expression'; +var actual = ''; +var expect = 'TypeError: /g/g is not a function'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + if (typeof dis != 'function') + { + actual = expect = 'disassembly not supported, test skipped.'; + } + else + { + try + { + dis(/g/g) + } + catch(ex) + { + actual = ex + ''; + } + } + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-352372.js b/js/src/tests/non262/extensions/regress-352372.js new file mode 100644 index 0000000000..106d8673ca --- /dev/null +++ b/js/src/tests/non262/extensions/regress-352372.js @@ -0,0 +1,62 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 352372; +var summary = 'Do not assert eval("setter/*...")'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = 'ReferenceError: setter is not defined'; + try + { + eval("setter/*\n*/;"); + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, 'eval("setter/*\n*/;")'); + + try + { + eval("setter/*\n*/g"); + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, 'eval("setter/*\n*/g")'); + + try + { + eval("setter/*\n*/ ;"); + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, 'eval("setter/*\n*/ ;")'); + + try + { + eval("setter/*\n*/ g"); + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, 'eval("setter/*\n*/ g")'); +} diff --git a/js/src/tests/non262/extensions/regress-352604.js b/js/src/tests/non262/extensions/regress-352604.js new file mode 100644 index 0000000000..106c04e97b --- /dev/null +++ b/js/src/tests/non262/extensions/regress-352604.js @@ -0,0 +1,30 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 352604; +var summary = 'Do not assert: !OBJ_GET_PROTO(cx, ctor)'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + function f() {} + delete Function; + var g = function () {}; + + expect = f.__proto__; + actual = g.__proto__; + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-353116.js b/js/src/tests/non262/extensions/regress-353116.js new file mode 100644 index 0000000000..cdb19bff32 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-353116.js @@ -0,0 +1,75 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 353116; +var summary = 'Improve errors messages for null, undefined properties'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = /TypeError: (undefined has no properties|can't access property "y" of undefined)/; + actual = 'No Error'; + + try + { + undefined.y; + } + catch(ex) + { + actual = ex + ''; + } + reportMatch(expect, actual, summary); + + expect = /TypeError: (null has no properties|can't access property "y" of null)/; + actual = 'No Error'; + + try + { + null.y; + } + catch(ex) + { + actual = ex + ''; + } + reportMatch(expect, actual, summary); + + expect = /TypeError: .*x is undefined/; + actual = 'No Error'; + + try + { + x = undefined; + x.y; + } + catch(ex) + { + actual = ex + ''; + } + reportMatch(expect, actual, summary); + + expect = /TypeError: .*x is null/; + actual = 'No Error'; + + try + { + x = null; + x.y; + } + catch(ex) + { + actual = ex + ''; + } + reportMatch(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-353214-02.js b/js/src/tests/non262/extensions/regress-353214-02.js new file mode 100644 index 0000000000..9a6317a066 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-353214-02.js @@ -0,0 +1,27 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 353214; +var summary = 'bug 353214'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + var f = function ([x]) { let y; } + expect = 'function ([x]) { let y; }'; + actual = f + ''; + + compareSource(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-354297.js b/js/src/tests/non262/extensions/regress-354297.js new file mode 100644 index 0000000000..a0cdbdc6aa --- /dev/null +++ b/js/src/tests/non262/extensions/regress-354297.js @@ -0,0 +1,27 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 354297; +var summary = 'getter/setter can be on index'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + print('This test requires GC_MARK_DEBUG'); + + var o = {}; o.__defineGetter__(1, Math.sin); gc() + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-355052-01.js b/js/src/tests/non262/extensions/regress-355052-01.js new file mode 100644 index 0000000000..73bcb5125a --- /dev/null +++ b/js/src/tests/non262/extensions/regress-355052-01.js @@ -0,0 +1,34 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 355052; +var summary = 'Do not crash with valueOf:gc and __iterator__'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = /TypeError: .+ is not a function/; + actual = 'No Error'; + try + { + ( {valueOf: gc} - [function(){}].__iterator__ )(); + } + catch(ex) + { + actual = ex + ''; + } + + reportMatch(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-355052-02.js b/js/src/tests/non262/extensions/regress-355052-02.js new file mode 100644 index 0000000000..a6e0a9816e --- /dev/null +++ b/js/src/tests/non262/extensions/regress-355052-02.js @@ -0,0 +1,34 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 355052; +var summary = 'Do not crash with valueOf:gc and __iterator__'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = /TypeError: .+ is not a function/; + actual = 'No Error'; + try + { + ( {valueOf: gc} - [].a )(); + } + catch(ex) + { + actual = ex + ''; + } + + reportMatch(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-355052-03.js b/js/src/tests/non262/extensions/regress-355052-03.js new file mode 100644 index 0000000000..6393a7441a --- /dev/null +++ b/js/src/tests/non262/extensions/regress-355052-03.js @@ -0,0 +1,40 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 355052; +var summary = 'Do not crash with valueOf:gc and __iterator__'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = /TypeError: .+ is not a function/; + actual = 'No Error'; + try + { + var obj = {valueOf: gc }; + + function f() { + ( obj * [].a )(); + } + + f(); + } + catch(ex) + { + actual = ex + ''; + } + + reportMatch(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-355410.js b/js/src/tests/non262/extensions/regress-355410.js new file mode 100644 index 0000000000..38eb133964 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-355410.js @@ -0,0 +1,37 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 355410; +var summary = 'GC hazard in for([k,v] in o){...}'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + var address = 0xbadf00d0, basket = { food: {} }; + var AP = Array.prototype, rooter = {}; + AP.__defineGetter__(0, function() { return this[-1]; }); + AP.__defineSetter__(0, function(v) { + basket.food = null; + for(var i = 0; i < 8 * 1024; i++) { + rooter[i] = 0x10000000000000 + address; // IEEE754! + } + return this[-1] = v; + }); + for(var [key, value] in basket) { value.trigger; } + + delete Array.prototype[0]; + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-355497.js b/js/src/tests/non262/extensions/regress-355497.js new file mode 100644 index 0000000000..efaf280d66 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-355497.js @@ -0,0 +1,58 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 355497; +var summary = 'Do not overflow stack with Array.slice, getter'; +var actual = ''; +var expect = ''; + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = 'InternalError: too much recursion'; + + try + { + var a = { length: 1 }; + a.__defineGetter__(0, [].slice); + a[0]; + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, summary + ': 1'); + + try + { + var b = { length: 1 }; + b.__defineGetter__(0, function () { return Array.prototype.slice.call(b); }); + b[0]; + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, summary + ': 2'); + + try + { + var c = []; + c.__defineSetter__(0, c.unshift); + c[0] = 1; + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, summary + ': 3'); +} diff --git a/js/src/tests/non262/extensions/regress-363040-01.js b/js/src/tests/non262/extensions/regress-363040-01.js new file mode 100644 index 0000000000..f8a382d3be --- /dev/null +++ b/js/src/tests/non262/extensions/regress-363040-01.js @@ -0,0 +1,62 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 363040; +var summary = 'Array.prototype.reduce application in continued fraction'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + +// Print x as a continued fraction in compact abbreviated notation and return +// the convergent [n, d] such that x - (n / d) <= epsilon. + function contfrac(x, epsilon) { + let i = Math.floor(x); + let a = [i]; + x = x - i; + let maxerr = x; + while (maxerr > epsilon) { + x = 1 / x; + i = Math.floor(x); + a.push(i); + x = x - i; + maxerr = x * maxerr / i; + } + print(a); + a.push([1, 0]); + a.reverse(); + return a.reduce(function (x, y) {return [x[0] * y + x[1], x[0]];}); + } + + if (!Array.prototype.reduce) + { + print('Test skipped. Array.prototype.reduce not implemented'); + } + else + { +// Show contfrac in action. + for (num of [Math.PI, Math.sqrt(2), 1 / (Math.sqrt(Math.E) - 1)]) { + print('Continued fractions for', num); + for (eps of [1e-2, 1e-3, 1e-5, 1e-7, 1e-10]) { + let frac = contfrac(num, eps); + let est = frac[0] / frac[1]; + let err = num - est; + print(frac, est, err); + } + print(); + } + } + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-363040-02.js b/js/src/tests/non262/extensions/regress-363040-02.js new file mode 100644 index 0000000000..8309d8c6be --- /dev/null +++ b/js/src/tests/non262/extensions/regress-363040-02.js @@ -0,0 +1,61 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 363040; +var summary = 'Array.prototype.reduce application in continued fraction'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + +// Print x as a continued fraction in compact abbreviated notation and return +// the convergent [n, d] such that x - (n / d) <= epsilon. + function contfrac(x, epsilon) { + let i = Math.floor(x); + let a = [i]; + x = x - i; + let maxerr = x; + while (maxerr > epsilon) { + x = 1 / x; + i = Math.floor(x); + a.push(i); + x = x - i; + maxerr = x * maxerr / i; + } + print(a); + return a.reduceRight(function (x, y) {return [x[0] * y + x[1], x[0]];}, [1, 0]); + } + + if (!Array.prototype.reduceRight) + { + print('Test skipped. Array.prototype.reduceRight not implemented'); + } + else + { +// Show contfrac in action on some interesting numbers. + for (num of [Math.PI, Math.sqrt(2), 1 / (Math.sqrt(Math.E) - 1)]) { + print('Continued fractions for', num); + for (eps of [1e-2, 1e-3, 1e-5, 1e-7, 1e-10]) { + let frac = contfrac(num, eps); + let est = frac[0] / frac[1]; + let err = num - est; + print(frac, est, err); + } + print(); + } + } + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-363258.js b/js/src/tests/non262/extensions/regress-363258.js new file mode 100644 index 0000000000..fe01008aae --- /dev/null +++ b/js/src/tests/non262/extensions/regress-363258.js @@ -0,0 +1,45 @@ +// |reftest| random -- bug 524788 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +//----------------------------------------------------------------------------- +var BUGNUMBER = 363258; +var summary = 'Timer resolution'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + var start = 0; + var stop = 0; + var i; + var limit = 0; + var incr = 10; + var resolution = 5; + + while (stop - start == 0) + { + limit += incr; + start = Date.now(); + for (i = 0; i < limit; i++) {} + stop = Date.now(); + } + + print('limit=' + limit + ', resolution=' + resolution + ', time=' + (stop - start)); + + expect = true; + actual = (stop - start <= resolution); + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-363988.js b/js/src/tests/non262/extensions/regress-363988.js new file mode 100644 index 0000000000..372bd92914 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-363988.js @@ -0,0 +1,44 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 363988; +var summary = 'Do not crash at JS::GetPrivate with large script'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + function crash() { + var town = new Array; + + for (var i = 0; i < 0x4001; ++i) { + var si = String(i); + town[i] = [ si, "x" + si, "y" + si, "z" + si ]; + } + + return "town=" + JSON.stringify(town) + ";function f() {}"; + } + + if (typeof document != "undefined") + { + // this is required to reproduce the crash. + document.write("<script>", crash(), "<\/script>"); + } + else + { + crash(); + } + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-365527.js b/js/src/tests/non262/extensions/regress-365527.js new file mode 100644 index 0000000000..29357b6266 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-365527.js @@ -0,0 +1,63 @@ +// |reftest| slow +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 365527; +var summary = 'JSOP_ARGUMENTS should set obj register'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + + counter = 500*1000; + + var obj; + + function getter() + { + obj = { get x() { + return getter(); + }, counter: counter}; + return obj; + } + + + var x; + + function g() + { + x += this.counter; + if (--counter == 0) + throw "Done"; + } + + + function f() + { + arguments=g; + try { + for (;;) { + arguments(); + obj.x; + } + } catch (e) { + } + } + + + getter(); + f(); + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-365692.js b/js/src/tests/non262/extensions/regress-365692.js new file mode 100644 index 0000000000..106b8071a5 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-365692.js @@ -0,0 +1,40 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 365692; +var summary = 'getter/setter bytecodes should support atoms over 64k'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +printBugNumber(BUGNUMBER); +printStatus (summary); + +function g() +{ + return 10; +} + +try +{ + var N = 100*1000; + var src = 'var x = ["'; + var array = Array(N); + for (var i = 0; i != N; ++i) + array[i] = i; + src += array.join('","')+'"]; x.a getter = g; return x.a;'; + var f = Function(src); + if (f() != 10) + throw "Unexpected result"; +} +catch(ex) +{ + if (ex == "Unexpected result") + { + actual = ex; + } +} +reportCompare(expect, actual, summary); diff --git a/js/src/tests/non262/extensions/regress-365869.js b/js/src/tests/non262/extensions/regress-365869.js new file mode 100644 index 0000000000..6ec88e7970 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-365869.js @@ -0,0 +1,35 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 365869; +var summary = 'strict warning for object literal with duplicate propery names'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + print('test crash from bug 371292 Comment 9'); + + try + { + expect = "TypeError: can't redefine non-configurable property 5"; + "012345".__defineSetter__(5, function(){}); + } + catch(ex) + { + actual = ex + ''; + } + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-366288.js b/js/src/tests/non262/extensions/regress-366288.js new file mode 100644 index 0000000000..05f0d2565d --- /dev/null +++ b/js/src/tests/non262/extensions/regress-366288.js @@ -0,0 +1,18 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 366288; +var summary = 'Do not assert !SPROP_HAS_STUB_GETTER with __defineSetter__'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +this.__defineSetter__("x", function(){}); +x = 3; + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/non262/extensions/regress-366292.js b/js/src/tests/non262/extensions/regress-366292.js new file mode 100644 index 0000000000..19879769cc --- /dev/null +++ b/js/src/tests/non262/extensions/regress-366292.js @@ -0,0 +1,19 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 366292; +var summary = '__defineSetter__ and JSPROP_SHARED regression'; +var actual = ''; +var expect = ''; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +expect = 'undefined'; +this.__defineSetter__("x", function(){}); +actual = String(x); + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/non262/extensions/regress-366396.js b/js/src/tests/non262/extensions/regress-366396.js new file mode 100644 index 0000000000..4369be821b --- /dev/null +++ b/js/src/tests/non262/extensions/regress-366396.js @@ -0,0 +1,17 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 366396; +var summary = 'Do not assert !SPROP_HAS_STUB_GETTER on Setter with %='; +var actual = 'No Crash'; +var expect = 'No Crash'; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +this.__defineSetter__("x", function() {}); x %= 5; + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/non262/extensions/regress-366668-01.js b/js/src/tests/non262/extensions/regress-366668-01.js new file mode 100644 index 0000000000..e4d8db6168 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-366668-01.js @@ -0,0 +1,28 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 366668; +var summary = 'decompilation of "for (let x in x.p)" '; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + var f; + + f = function() { for(let x in x.p) { } }; + expect = 'function() { for(let x in x.p) { } }'; + actual = f + ''; + compareSource(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-367501-01.js b/js/src/tests/non262/extensions/regress-367501-01.js new file mode 100644 index 0000000000..7446c13999 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-367501-01.js @@ -0,0 +1,32 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 367501; +var summary = 'getter/setter issues'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + try + { + expect = 'undefined'; + var a = { set x(v) {} }; + actual = a.x + ''; + } + catch(ex) + { + } + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-367501-02.js b/js/src/tests/non262/extensions/regress-367501-02.js new file mode 100644 index 0000000000..033ef777e7 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-367501-02.js @@ -0,0 +1,34 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 367501; +var summary = 'getter/setter crashes'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + try + { + expect = 'undefined'; + var a = { set x(v) {} }; + for (var i = 0; i < 92169 - 3; ++i) a[i] = 1; + actual = a.x + ''; + actual = a.x + ''; + } + catch(ex) + { + } + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-367501-03.js b/js/src/tests/non262/extensions/regress-367501-03.js new file mode 100644 index 0000000000..c1f9433712 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-367501-03.js @@ -0,0 +1,35 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 367501; +var summary = 'getter/setter crashes'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + try + { + expect = actual = 'No Crash'; + var a = { set x(v) {} }; + for (var i = 0; i < 0x4bf20 - 3; ++i) a[i] = 1; + a.x; + a.x.x; + } + catch(ex) + { + } + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-367501-04.js b/js/src/tests/non262/extensions/regress-367501-04.js new file mode 100644 index 0000000000..e88b3e1fa6 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-367501-04.js @@ -0,0 +1,35 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 367501; +var summary = 'getter/setter crashes'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + try + { + expect = actual = 'No Crash'; + var a = { set x(v) {} }; + for (var i = 0; i < 0x10050c - 3; ++i) a[i] = 1; + a.x; + typeof a.x; + } + catch(ex) + { + } + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-367589.js b/js/src/tests/non262/extensions/regress-367589.js new file mode 100644 index 0000000000..29aa1b61b6 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-367589.js @@ -0,0 +1,39 @@ +// |reftest| skip-if(xulRuntime.shell||(xulRuntime.OS=="WINNT"&&isDebugBuild)) slow +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 367589; +var summary = 'Do not assert !SPROP_HAS_STUB_SETTER(sprop) || (sprop->attrs & JSPROP_GETTER)'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + gDelayTestDriverEnd = true; + document.write('<button id="button" onclick="document.getElementsByTagName(\'button\')[0] = \'wtf\';">Crash</button>'); + window.addEventListener('load', crash, false); +} + +function crash() +{ + document.getElementById('button').click(); + setTimeout(checkCrash, 0); +} + +function checkCrash() +{ + gDelayTestDriverEnd = false; + reportCompare(expect, actual, summary); + jsTestDriverEnd(); +} diff --git a/js/src/tests/non262/extensions/regress-368213.js b/js/src/tests/non262/extensions/regress-368213.js new file mode 100644 index 0000000000..c1f9be735a --- /dev/null +++ b/js/src/tests/non262/extensions/regress-368213.js @@ -0,0 +1,17 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 368213; +var summary = 'Do not crash with group assignment and sharp variable defn'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +(function() { [] = [] }); + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/non262/extensions/regress-368224.js b/js/src/tests/non262/extensions/regress-368224.js new file mode 100644 index 0000000000..c6b394e0ea --- /dev/null +++ b/js/src/tests/non262/extensions/regress-368224.js @@ -0,0 +1,25 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 368224; +var summary = 'Do not assert: pnprop->pn_type == TOK_COLON'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + ({ x: a } = {}); + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-368516.js b/js/src/tests/non262/extensions/regress-368516.js new file mode 100644 index 0000000000..667b5c1535 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-368516.js @@ -0,0 +1,41 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 368516; +var summary = 'Treat unicode BOM characters as whitespace'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + var bomchars = ['\uFEFF']; + + for (var i = 0; i < bomchars.length; i++) + { + expect = 'howdie'; + actual = ''; + + try + { + eval("var" + bomchars[i] + "hithere = 'howdie';"); + actual = hithere; + } + catch(ex) + { + actual = ex + ''; + } + + reportCompare(expect, actual, summary + ': ' + i); + } +} diff --git a/js/src/tests/non262/extensions/regress-369404.js b/js/src/tests/non262/extensions/regress-369404.js new file mode 100644 index 0000000000..d1e25f8c4f --- /dev/null +++ b/js/src/tests/non262/extensions/regress-369404.js @@ -0,0 +1,39 @@ +// |reftest| skip-if(xulRuntime.shell) +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 369404; +var summary = 'Do not assert: !SPROP_HAS_STUB_SETTER(sprop) || (sprop->attrs & JSPROP_GETTER) '; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + gDelayTestDriverEnd = true; + document.write('<span id="r"> </span>' + + '<script>' + + 'f = function(){};' + + 'f.prototype = document.getElementById("r").childNodes;' + + 'j = new f();' + + 'j[0] = null;' + + '</script>'); + window.addEventListener('load', crash, false); +} + +function crash() +{ + gDelayTestDriverEnd = false; + reportCompare(expect, actual, summary); + jsTestDriverEnd(); +} diff --git a/js/src/tests/non262/extensions/regress-369696-01.js b/js/src/tests/non262/extensions/regress-369696-01.js new file mode 100644 index 0000000000..5b2f12cc98 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-369696-01.js @@ -0,0 +1,30 @@ +// |reftest| skip-if(!Object.prototype.toSource) + +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 369696; +var summary = 'Do not assert: map->depth > 0" in js_LeaveSharpObject'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + q = []; + q.__defineGetter__("0", q.toString); + q[2] = q; + assertEq(q.toSource(), "[\"\", , []]", "wrong string"); + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-369696-02.js b/js/src/tests/non262/extensions/regress-369696-02.js new file mode 100644 index 0000000000..5cc18edf7c --- /dev/null +++ b/js/src/tests/non262/extensions/regress-369696-02.js @@ -0,0 +1,57 @@ +// |reftest| skip-if(!Object.prototype.toSource) + +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 369696; +var summary = 'Do not assert: map->depth > 0" in js_LeaveSharpObject'; +var actual = ''; +var expect = ''; + +// Bug 762908 requires us to set sp=null; +if (this.window) window.SpecialPowers = null; + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + function fun() {} + n = fun.prototype; + n.__defineGetter__("prototype", n.toSource); + p = n.__lookupGetter__("prototype"); + n = p; + + assertEq(n, Object.prototype.toSource); + assertEq(p, Object.prototype.toSource); + + n["prototype"] = [n]; + n = p; + + assertEq(n, Object.prototype.toSource); + assertEq(p, Object.prototype.toSource); + + p2 = n["prototype"]; + + assertEq(Array.isArray(p2), true); + assertEq(p2[0], Object.prototype.toSource); + + n = p2; + + assertEq(n.toString, Array.prototype.toString); + n.__defineGetter__("0", n.toString); + n = p; + + assertEq(n, Object.prototype.toSource); + + n.call(this); + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-369696-03.js b/js/src/tests/non262/extensions/regress-369696-03.js new file mode 100644 index 0000000000..3d02428b67 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-369696-03.js @@ -0,0 +1,46 @@ +// |reftest| skip-if(!Object.prototype.toSource) + +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 369696; +var summary = 'Do not assert: map->depth > 0" in js_LeaveSharpObject'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + var x = [[[ { toSource: function() { gc(); }}]]]; + + var a = []; + a[0] = a; + a.toSource = a.toString; + Array.prototype.toSource.call(a); + +//cx->sharpObjectMap.depth == -2 + + (function() { + var tmp = []; + for (var i = 0; i != 30*1000; ++i) { + var tmp2 = []; + tmp.push(tmp2); + tmp2.toSource(); + } + })(); + + gc(); + x.toSource(); + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-372309.js b/js/src/tests/non262/extensions/regress-372309.js new file mode 100644 index 0000000000..950c0a5461 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-372309.js @@ -0,0 +1,37 @@ +// |reftest| skip-if(xulRuntime.shell) +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 372309; +var summary = 'Root new array objects'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + var width = 600; + var height = 600; + + var img1canvas = document.createElement("canvas"); + var img2canvas = document.createElement("canvas"); + + img1canvas.width = img2canvas.width = width; + img1canvas.height = img2canvas.height = height; + img1canvas.getContext("2d").getImageData(0, 0, width, height).data; + img2canvas.getContext("2d").getImageData(0, 0, width, height).data; + + reportCompare(expect, actual, summary); + gDelayTestDriverEnd = false; + jsTestDriverEnd(); +} + +// delay test driver end +gDelayTestDriverEnd = true; + +window.addEventListener("load", test, false); diff --git a/js/src/tests/non262/extensions/regress-375183.js b/js/src/tests/non262/extensions/regress-375183.js new file mode 100644 index 0000000000..6c351c8c79 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-375183.js @@ -0,0 +1,59 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 375183; +var summary = '__noSuchMethod__ should not allocate beyond fp->script->depth'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + var obj = { get __noSuchMethod__() { + print("Executed"); + return new Object(); + }}; + + try + { + obj.x(); + } + catch(ex) + { + } + + reportCompare(expect, actual, summary + ':1'); + + obj = { __noSuchMethod__: {} }; + try + { + obj.x(); + } + catch(ex) + { + } + + reportCompare(expect, actual, summary + ':2'); + + obj = { } + obj.__noSuchMethod__ = {}; + try + { + obj.x(); + } + catch(ex) + { + } + + reportCompare(expect, actual, summary + ':3'); +} diff --git a/js/src/tests/non262/extensions/regress-375344.js b/js/src/tests/non262/extensions/regress-375344.js new file mode 100644 index 0000000000..41d9eeb15a --- /dev/null +++ b/js/src/tests/non262/extensions/regress-375344.js @@ -0,0 +1,34 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 375344; +var summary = 'accessing prototype of DOM objects should throw catchable error'; +var actual = ''; +var expect = ''; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +if (typeof HTMLElement != 'undefined') +{ + expect = /TypeError/; + try + { + print(HTMLElement.prototype.nodeName); + } + catch(ex) + { + actual = ex + ''; + print(actual); + } + reportMatch(expect, actual, summary); +} +else +{ + expect = actual = 'Test can only run in a Gecko 1.9 browser or later.'; + print(actual); + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-379566.js b/js/src/tests/non262/extensions/regress-379566.js new file mode 100644 index 0000000000..17461a49e9 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-379566.js @@ -0,0 +1,44 @@ +// |reftest| skip-if(!Object.prototype.toSource) + +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +//----------------------------------------------------------------------------- +var BUGNUMBER = 379566; +var summary = 'Keywords after get|set'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = '({' + + 'get in() { return this.for; }, ' + + 'set in(value) { this.for = value; }' + + '})'; + try + { + var obj = eval('({ ' + + 'get in() { return this.for; }, ' + + 'set in(value) { this.for = value; } ' + + '})'); + actual = obj.toSource(); + + } + catch(ex) + { + actual = ex + ''; + } + + compareSource(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-380889.js b/js/src/tests/non262/extensions/regress-380889.js new file mode 100644 index 0000000000..fedd51f01f --- /dev/null +++ b/js/src/tests/non262/extensions/regress-380889.js @@ -0,0 +1,37 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +//----------------------------------------------------------------------------- +var BUGNUMBER = 380889; +var summary = 'Source disassembler assumes SRC_SWITCH has jump table'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + function f(i) + { + switch(i){ + case 1: + case xyzzy: + } + } + + if (typeof dis != 'undefined') + { + dis(f); + } + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-381303.js b/js/src/tests/non262/extensions/regress-381303.js new file mode 100644 index 0000000000..7d113ac293 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-381303.js @@ -0,0 +1,34 @@ +// |reftest| skip-if(!Object.prototype.toSource) + +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +//----------------------------------------------------------------------------- +var BUGNUMBER = 381303; +var summary = 'object toSource when a property has both a getter and a setter'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + var obj = {set inn(value) {this.for = value;}, get inn() {return this.for;}}; + expect = '({' + + 'get inn() {return this.for;}' + + ', ' + + 'set inn(value) {this.for = value;}' + + '})'; + actual = obj.toSource(); + + compareSource(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-381304.js b/js/src/tests/non262/extensions/regress-381304.js new file mode 100644 index 0000000000..168da0866c --- /dev/null +++ b/js/src/tests/non262/extensions/regress-381304.js @@ -0,0 +1,69 @@ +// |reftest| skip-if(!Object.prototype.toSource) + +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 381304; +var summary = 'getter/setter with keywords'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + var obj; + + print('1'); + + obj = { + set inn(value) {this.for = value;}, + get inn() {return this.for;} + }; + + expect = '({get inn() {return this.for;}, set inn(value) {this.for = value;}})'; + actual = obj.toSource(); + compareSource(expect, actual, summary + ': 1'); + + print('2'); + + obj = { + set in(value) {this.for = value;}, + get in() {return this.for;} + }; + + expect = '({get in() {return this.for;}, set in(value) {this.for = value;}})'; + actual = obj.toSource(); + compareSource(expect, actual, summary + ': 2'); + + print('3'); + + obj = { + set inn(value) {this.for = value;}, + get in() {return this.for;} + }; + + expect = '({set inn(value) {this.for = value;}, get in() {return this.for;}})'; + actual = obj.toSource(); + compareSource(expect, actual, summary + ': 4'); + + print('4'); + + obj = { + set in(value) {this.for = value;}, + get inn() {return this.for;} + }; + + expect = '({set in(value) {this.for = value;}, get inn() {return this.for;}})'; + actual = obj.toSource(); + compareSource(expect, actual, summary + ': 5'); +} diff --git a/js/src/tests/non262/extensions/regress-385393-02.js b/js/src/tests/non262/extensions/regress-385393-02.js new file mode 100644 index 0000000000..cb6d0c94cd --- /dev/null +++ b/js/src/tests/non262/extensions/regress-385393-02.js @@ -0,0 +1,31 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +//----------------------------------------------------------------------------- +var BUGNUMBER = 385393; +var summary = 'Regression test for bug 385393'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + try + { + (4).__lookupGetter__("w"); + } + catch(ex) + { + } + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-385393-08.js b/js/src/tests/non262/extensions/regress-385393-08.js new file mode 100644 index 0000000000..b00cafde9c --- /dev/null +++ b/js/src/tests/non262/extensions/regress-385393-08.js @@ -0,0 +1,25 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +//----------------------------------------------------------------------------- +var BUGNUMBER = 385393; +var summary = 'Regression test for bug 385393'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +try +{ + this.__proto__ = []; + [1,2,3,4].map.call(); +} +catch(ex) +{ +} + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/non262/extensions/regress-390598.js b/js/src/tests/non262/extensions/regress-390598.js new file mode 100644 index 0000000000..d190615a18 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-390598.js @@ -0,0 +1,31 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +//----------------------------------------------------------------------------- +var BUGNUMBER = 390598; +var summary = 'array_length_setter is exploitable'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + function exploit() { + var fun = function () {}; + fun.__proto__ = []; + fun.length = 0x50505050 >> 1; + fun(); + } + exploit(); + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-394967.js b/js/src/tests/non262/extensions/regress-394967.js new file mode 100644 index 0000000000..a82f1f5424 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-394967.js @@ -0,0 +1,39 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 394967; +var summary = 'Do not assert: !vp[1].isPrimitive()'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + if (typeof evalcx == 'undefined') + { + print('Skipping. This test requires evalcx.'); + } + else + { + var sandbox = evalcx(""); + try + { + evalcx("(1)()", sandbox); + } + catch(ex) + { + } + } + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-396326-01.js b/js/src/tests/non262/extensions/regress-396326-01.js new file mode 100644 index 0000000000..60913f4a42 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-396326-01.js @@ -0,0 +1,34 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 396326; +var summary = 'Do not assert trying to disassemble get(var|arg) prop'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + if (typeof dis == 'undefined') + { + print('disassembly not supported. test skipped.'); + reportCompare(expect, actual, summary); + } + else + { + function f4() { let local; return local.prop }; + dis(f4); + reportCompare(expect, actual, summary + + ': function f4() { let local; return local.prop };'); + } +} diff --git a/js/src/tests/non262/extensions/regress-396326.js b/js/src/tests/non262/extensions/regress-396326.js new file mode 100644 index 0000000000..45f3170bbb --- /dev/null +++ b/js/src/tests/non262/extensions/regress-396326.js @@ -0,0 +1,45 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +//----------------------------------------------------------------------------- +var BUGNUMBER = 396326; +var summary = 'Do not assert trying to disassemble get(var|arg) prop'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + if (typeof dis == 'undefined') + { + print('disassembly not supported. test skipped.'); + reportCompare(expect, actual, summary); + } + else + { + function f1() { var v; return v.prop }; + dis(f1); + reportCompare(expect, actual, summary + + ': function f1() { var v; return v.prop };'); + + function f2(arg) { return arg.prop }; + dis(f2); + reportCompare(expect, actual, summary + + ': function f2(arg) { return arg.prop };'); + + function f3() { return this.prop }; + dis(f3); + reportCompare(expect, actual, summary + + ': function f3() { return this.prop };'); + } +} diff --git a/js/src/tests/non262/extensions/regress-406572.js b/js/src/tests/non262/extensions/regress-406572.js new file mode 100644 index 0000000000..4911d05bc7 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-406572.js @@ -0,0 +1,47 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 406572; +var summary = 'JSOP_CLOSURE unconditionally replaces properties of the variable object - Browser only'; +var actual = ''; +var expect = ''; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +if (typeof window != 'undefined') +{ + try { + actual = "FAIL: Unexpected exception thrown"; + + var win = window; + var windowString = String(window); + window = 1; + reportCompare(windowString, String(window), "window should be readonly"); + + if (1) + function window() { return 1; } + + // We should reach this line without throwing. Annex B means the + // block-scoped function above gets an assignment to 'window' in the + // nearest 'var' environment, but since 'window' is read-only, the + // assignment silently fails. + actual = ""; + + // The test harness might rely on window having its original value: + // restore it. + window = win; + } catch (e) { + } +} +else +{ + expect = actual = 'Test can only run in a Gecko 1.9 browser or later.'; + print(actual); +} +reportCompare(expect, actual, summary); + + diff --git a/js/src/tests/non262/extensions/regress-407501.js b/js/src/tests/non262/extensions/regress-407501.js new file mode 100644 index 0000000000..267497464f --- /dev/null +++ b/js/src/tests/non262/extensions/regress-407501.js @@ -0,0 +1,39 @@ +// |reftest| skip-if(Android) +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 407501; +var summary = 'JSOP_NEWINIT lacks SAVE_SP_AND_PC '; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + if (typeof gczeal == 'function') + { + gczeal(2); + } + + var a = [[[[[[[0]]]]]]]; + if (a.toString() !== "0") + throw "Unexpected result"; + + if (typeof gczeal == 'function') + { + gczeal(0); + } + + reportCompare(expect, actual, summary); +} + diff --git a/js/src/tests/non262/extensions/regress-407720.js b/js/src/tests/non262/extensions/regress-407720.js new file mode 100644 index 0000000000..f5b4cf0f83 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-407720.js @@ -0,0 +1,44 @@ +// |reftest| skip slow +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 407720; +var summary = 'js_FindClassObject causes crashes with getter/setter - Browser only'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +// stop the test after 60 seconds +var start = new Date(); + +// delay test driver end +gDelayTestDriverEnd = true; +document.write('<iframe onload="onLoad()"><\/iframe>'); + +function onLoad() +{ + + if ( (new Date() - start) < 60*1000) + { + var x = frames[0].Window.prototype; + x.a = x.b = x.c = 1; + x.__defineGetter__("HTML document.all class", function() {}); + frames[0].document.all; + + // retry + frames[0].location = "about:blank"; + } + else + { + actual = 'No Crash'; + + reportCompare(expect, actual, summary); + gDelayTestDriverEnd = false; + jsTestDriverEnd(); + } +} diff --git a/js/src/tests/non262/extensions/regress-412926.js b/js/src/tests/non262/extensions/regress-412926.js new file mode 100644 index 0000000000..ffb356a5f8 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-412926.js @@ -0,0 +1,54 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 412926; +var summary = 'JS_ValueToId(cx, JSVAL_NULL) should return atom for "null" string'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + actual = expect = 'No Errors'; + + var obj = { 'null': 1 }; + + var errors = []; + + if (!obj.hasOwnProperty(null)) + errors.push('null property is not owned'); + + if (!obj.propertyIsEnumerable(null)) + errors.push('null property is not enumerable'); + + var getter_was_called = false; + obj.__defineGetter__(null, function() { getter_was_called = true; return 1; }); + obj['null']; + + if (!getter_was_called) + errors.push('getter was not assigned to the null property'); + + var setter_was_called = false; + obj.__defineSetter__(null, function() { setter_was_called = true; }); + obj['null'] = 2; + + if (!setter_was_called) + errors.push('setter was not assigned to the null property'); + + if (errors.length) + actual = errors.join('; '); + + gc(); + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-414098.js b/js/src/tests/non262/extensions/regress-414098.js new file mode 100644 index 0000000000..aa2b6e9de8 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-414098.js @@ -0,0 +1,34 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 414098; +var summary = 'Getter behavior on arrays'; +var actual = ''; +var expect = ''; + +var a=[1,2,3]; +var foo = 44; +a.__defineGetter__(1, function() { return foo + 10; }); +actual = String(a); +reportCompare("1,54,3", actual, "getter 1"); + +actual = String(a.reverse()); +reportCompare("3,54,1", actual, "reverse"); + +var s = ""; +a.forEach(function(e) { s += e + "|"; }); +actual = s; +reportCompare("3|54|1|", actual, "forEach"); + +actual = a.join(' - '); +reportCompare("3 - 54 - 1", actual, "join"); + +a[2]=3; +actual = a.pop(); +reportCompare(actual, 3, "pop"); + +actual = a.pop(); +reportCompare(actual, 54, "pop 2"); diff --git a/js/src/tests/non262/extensions/regress-414755.js b/js/src/tests/non262/extensions/regress-414755.js new file mode 100644 index 0000000000..6d8057ceba --- /dev/null +++ b/js/src/tests/non262/extensions/regress-414755.js @@ -0,0 +1,51 @@ +// |reftest| skip-if(Android) +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 414755; +var summary = 'GC hazard due to missing SAVE_SP_AND_PC'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + function f() + { + var a = 1e10; + var b = 2e10; + var c = 3e10; + + return (a*2) * ((b*2) * c); + } + + if (typeof gczeal == 'function') + { + expect = f(); + + gczeal(2); + + actual = f(); + } + else + { + expect = actual = 'Test requires gczeal, skipped.'; + } + + if (typeof gczeal == 'function') + { + gczeal(0); + } + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-416354.js b/js/src/tests/non262/extensions/regress-416354.js new file mode 100644 index 0000000000..e697776a9d --- /dev/null +++ b/js/src/tests/non262/extensions/regress-416354.js @@ -0,0 +1,45 @@ +// |reftest| skip-if(Android) +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 416354; +var summary = 'GC hazard due to missing SAVE_SP_AND_PC'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + function f(a, b, c) + { + return (-a) * ((-b) * (-c)); + } + + if (typeof gczeal == 'function') + { + expect = f(1.5, 1.25, 1.125); + gczeal(2); + actual = f(1.5, 1.25, 1.125); + } + else + { + expect = actual = 'Test requires gczeal, skipped.'; + } + + if (typeof gczeal == 'function') + { + gczeal(0); + } + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-416460.js b/js/src/tests/non262/extensions/regress-416460.js new file mode 100644 index 0000000000..63ac875719 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-416460.js @@ -0,0 +1,27 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 416460; +var summary = 'Do not assert: SCOPE_GET_PROPERTY(OBJ_SCOPE(pobj), ATOM_TO_JSID(atom))'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + /a/.__proto__.__proto__ = { "2": 3 }; + var b = /b/; + b["2"]; + b["2"]; + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-416834.js b/js/src/tests/non262/extensions/regress-416834.js new file mode 100644 index 0000000000..ffd145cf39 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-416834.js @@ -0,0 +1,20 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 416834; +var summary = 'Do not assert: !entry || entry->kpc == ((PCVCAP_TAG(entry->vcap) > 1) ? (jsbytecode *) JSID_TO_ATOM(id) : cx->fp->pc)'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +this.__proto__.x = eval; +for (i = 0; i < 16; ++i) + delete eval; +(function w() { x = 1; })(); + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/non262/extensions/regress-420869-01.js b/js/src/tests/non262/extensions/regress-420869-01.js new file mode 100644 index 0000000000..48c3ffecdc --- /dev/null +++ b/js/src/tests/non262/extensions/regress-420869-01.js @@ -0,0 +1,37 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 420869; +var summary = 'Throw too much recursion instead of script stack space quota'; +var actual = 'No Error'; +var expect = 'InternalError: too much recursion'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + function f(i) { + if (i == 0) + return 1; + return i*f(i-1); + } + + try + { + f(); + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-422592.js b/js/src/tests/non262/extensions/regress-422592.js new file mode 100644 index 0000000000..48964ad250 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-422592.js @@ -0,0 +1,65 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 422592; +var summary = 'js.c dis/dissrc should not kill script execution'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + if (typeof dis == 'undefined') + { + expect = actual = 'Test requires function dis. Not tested'; + print(expect); + } + else + { + expect = 'Completed'; + actual = 'Not Completed'; + print('Before dis'); + try + { + dis(print); + } + catch(ex) + { + } + print('After dis'); + actual = 'Completed'; + } + reportCompare(expect, actual, summary); + + if (typeof dissrc == 'undefined') + { + expect = actual = 'Test requires function dissrc. Not tested'; + print(expect); + } + else + { + print('Before dissrc'); + expect = 'Completed'; + actual = 'Not Completed'; + try + { + dissrc(print); + } + catch(ex) + { + } + print('After dissrc'); + actual = 'Completed'; + } + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-424683-01.js b/js/src/tests/non262/extensions/regress-424683-01.js new file mode 100644 index 0000000000..80595f070c --- /dev/null +++ b/js/src/tests/non262/extensions/regress-424683-01.js @@ -0,0 +1,33 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 424683; +var summary = 'Throw too much recursion instead of script stack space quota'; +var actual = 'No Error'; +var expect = 'InternalError: too much recursion'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + function f() { f(); } + + try + { + f(); + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-426711.js b/js/src/tests/non262/extensions/regress-426711.js new file mode 100644 index 0000000000..8bc3e5854a --- /dev/null +++ b/js/src/tests/non262/extensions/regress-426711.js @@ -0,0 +1,31 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 426711; +var summary = 'Setting window.__count__ causes a crash'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + if (typeof window != 'undefined' && '__count__' in window) + { + window.__count__ = 0; + } + else + { + expect = actual = 'Test skipped. Requires window.__count__'; + } + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-427196-01.js b/js/src/tests/non262/extensions/regress-427196-01.js new file mode 100644 index 0000000000..7b6f359e89 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-427196-01.js @@ -0,0 +1,37 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 427196; +var summary = 'Do not assert: OBJ_SCOPE(pobj)->object == pobj'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + function boom() + { + var b = {}; + Array.__proto__ = b; + b.__proto__ = {}; + var c = {}; + c.__proto__ = []; + try { c.__defineSetter__("t", undefined); } catch(e) { } + c.__proto__ = Array; + try { c.__defineSetter__("v", undefined); } catch(e) { } + } + + boom(); + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-427196-02.js b/js/src/tests/non262/extensions/regress-427196-02.js new file mode 100644 index 0000000000..c41c431383 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-427196-02.js @@ -0,0 +1,34 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 427196; +var summary = 'Do not assert: OBJ_SCOPE(pobj)->object == pobj'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + function boom() + { + var c = {__proto__: []}; + var a = {__proto__: {__proto__: {}}}; + c.hasOwnProperty("t"); + c.__proto__ = a; + c.hasOwnProperty("v"); + } + + boom(); + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-427196-03.js b/js/src/tests/non262/extensions/regress-427196-03.js new file mode 100644 index 0000000000..6d8a14aeb3 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-427196-03.js @@ -0,0 +1,28 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 427196; +var summary = 'Do not assert: OBJ_SCOPE(pobj)->object == pobj'; +var actual = ''; +var expect = ''; + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + var c = {__proto__: []}; + var a = {__proto__: {__proto__: {}}}; + c.hasOwnProperty; + c.__proto__ = a; + c.hasOwnProperty; + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-429739.js b/js/src/tests/non262/extensions/regress-429739.js new file mode 100644 index 0000000000..5c164a2947 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-429739.js @@ -0,0 +1,33 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 429739; +var summary = 'Do not assert: OBJ_GET_CLASS(cx, obj)->flags & JSCLASS_HAS_PRIVATE'; + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + var actual; + try + { + var o = { __noSuchMethod__: Function }; + actual = (new o.y) + ''; + throw new Error("didn't throw, produced a value"); + } + catch(ex) + { + actual = ex; + } + + reportCompare("TypeError", actual.name, "bad error name"); + reportCompare(true, /is not a constructor/.test(actual), summary); +} diff --git a/js/src/tests/non262/extensions/regress-430740.js b/js/src/tests/non262/extensions/regress-430740.js new file mode 100644 index 0000000000..d6d6e32d04 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-430740.js @@ -0,0 +1,36 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 430740; +var summary = 'Do not strip format-control characters from string literals'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + function doevil() { + print('evildone'); + return 'evildone'; + } + + expect = 'a%E2%80%8D,+doevil()%5D)//'; + actual += eval("(['a\\\u200d', '+doevil()])//'])"); + actual = encodeURI(actual); + reportCompare(expect, actual, summary); + + expect = 'a%EF%BF%BE,+doevil()%5D)//'; + actual = eval("(['a\\\ufffe', '+doevil()])//'])"); + actual = encodeURI(actual); + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-434837-01.js b/js/src/tests/non262/extensions/regress-434837-01.js new file mode 100644 index 0000000000..16f9450601 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-434837-01.js @@ -0,0 +1,87 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 434837; +var summary = '|this| in accessors in prototype chain of array'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + try + { + expect = true; + actual = null; + x = [ "one", "two" ]; + Array.prototype.__defineGetter__('test1', function() { actual = (this === x); }); + x.test1; + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, summary + ': x.test1'); + + try + { + expect = false; + actual = null; + Array.prototype.__defineGetter__('test2', function() { actual = (this === Array.prototype) }); + x.test2; + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, summary + ': x.test2'); + + Array.prototype.__defineGetter__('test3', function() { actual = (this === x) }); + Array.prototype.__defineSetter__('test3', function() { actual = (this === x) }); + + try + { + expect = true; + actual = null; + x.test3; + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, summary + ': x.test3 (1)'); + + try + { + expect = true; + actual = null; + x.test3 = 5; + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, summary + ': x.test3 = 5'); + + try + { + expect = true; + actual = null; + x.test3; + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, summary + ': x.test3 (2)'); +} diff --git a/js/src/tests/non262/extensions/regress-435497-01.js b/js/src/tests/non262/extensions/regress-435497-01.js new file mode 100644 index 0000000000..87b8914413 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-435497-01.js @@ -0,0 +1,31 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 435497; +var summary = 'Do not assert op2 == JSOP_INITELEM'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + try + { + eval('(function() { x, x setter = 0, y; const x; })();'); + } + catch(ex) + { + } + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-435497-02.js b/js/src/tests/non262/extensions/regress-435497-02.js new file mode 100644 index 0000000000..ac107687ea --- /dev/null +++ b/js/src/tests/non262/extensions/regress-435497-02.js @@ -0,0 +1,31 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 435497; +var summary = 'Do not assert op2 == JSOP_INITELEM'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + try + { + eval('(function() { x setter = 0, y; const x; })();'); + } + catch(ex) + { + } + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-435497-03.js b/js/src/tests/non262/extensions/regress-435497-03.js new file mode 100644 index 0000000000..9ea783510f --- /dev/null +++ b/js/src/tests/non262/extensions/regress-435497-03.js @@ -0,0 +1,31 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 435497; +var summary = 'Do not assert op2 == JSOP_INITELEM'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + try + { + eval('(function() { x getter= function(){} ; var x5, x = 0x99; })();'); + } + catch(ex) + { + } + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-436741.js b/js/src/tests/non262/extensions/regress-436741.js new file mode 100644 index 0000000000..8e85138cf0 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-436741.js @@ -0,0 +1,32 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 436741; +var summary = 'Do not assert: OBJ_IS_NATIVE(obj)'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + if (typeof window == 'undefined') + { + print('This test is only meaningful in the browser.'); + } + else + { + try { window.__proto__.__proto__ = [{}]; } catch (e) {} + for (var j in window); + } + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-437288-01.js b/js/src/tests/non262/extensions/regress-437288-01.js new file mode 100644 index 0000000000..725554dd52 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-437288-01.js @@ -0,0 +1,32 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 437288; +var summary = 'for loop turning into a while loop'; +var actual = 'No Hang'; +var expect = 'No Hang'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + try + { + eval('(function() { const x = 1; for (x in null); })();'); + } + catch(ex) + { + actual = ex + ''; + } + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-44009.js b/js/src/tests/non262/extensions/regress-44009.js new file mode 100644 index 0000000000..253262fe78 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-44009.js @@ -0,0 +1,51 @@ +// |reftest| skip-if(!Object.prototype.toSource) + +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * Date: 26 Feb 2001 + * See http://bugzilla.mozilla.org/show_bug.cgi?id=44009 + * + * SUMMARY: Testing that we don't crash on obj.toSource() + */ +//----------------------------------------------------------------------------- +var BUGNUMBER = 44009; +var summary = "Testing that we don't crash on obj.toSource()"; +var obj1 = {}; +var sToSource = ''; +var self = this; //capture a reference to the global JS object - + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + var obj2 = {}; + + // test various objects and scopes - + testThis(self); + testThis(this); + testThis(obj1); + testThis(obj2); + + reportCompare('No Crash', 'No Crash', ''); +} + + +// We're just testing that we don't crash by doing this - +function testThis(obj) +{ + sToSource = obj.toSource(); + obj.prop = obj; + sToSource = obj.toSource(); +} diff --git a/js/src/tests/non262/extensions/regress-443569.js b/js/src/tests/non262/extensions/regress-443569.js new file mode 100644 index 0000000000..dbfc1d8114 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-443569.js @@ -0,0 +1,35 @@ +// |reftest| skip-if(xulRuntime.shell) +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 443569; +var summary = 'Do not assert: OBJ_IS_NATIVE(obj)'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +printBugNumber(BUGNUMBER); +printStatus (summary); + +// delay test driver end +gDelayTestDriverEnd = true; + +window.addEventListener("load", boom, false); + +function boom() +{ + var r = RegExp.prototype; + r["-1"] = 0; + Array.prototype.__proto__ = r; + []["-1"]; + + reportCompare(expect, actual, summary); + + gDelayTestDriverEnd = false; + jsTestDriverEnd(); +} + + diff --git a/js/src/tests/non262/extensions/regress-446386.js b/js/src/tests/non262/extensions/regress-446386.js new file mode 100644 index 0000000000..25359054f5 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-446386.js @@ -0,0 +1,44 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 446386; +var summary = 'Do not crash throwing error without compiler pseudo-frame'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + if (typeof evalcx == 'undefined') + { + print(expect = actual = 'Test skipped. evalcx required.'); + } + else { + try + { + try { + evalcx("."); + throw "must throw"; + } catch (e) { + if (e.name != "SyntaxError") + throw e; + } + } + catch(ex) + { + actual = ex + ''; + } + } + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-452168.js b/js/src/tests/non262/extensions/regress-452168.js new file mode 100644 index 0000000000..998ceca951 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-452168.js @@ -0,0 +1,39 @@ +// |reftest| skip-if(Android) +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 452168; +var summary = 'Do not crash with gczeal 2, JIT: @ avmplus::List or @ nanojit::LirBuffer::validate'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + if (typeof gczeal == 'undefined') + { + expect = actual = 'Test requires gczeal, skipped.'; + } + else + { + // Enumerate the global once before we turn on gczeal, so we're not + // trying to do all the enumerate hook object creation with a gc on + // every object, because that makes tests time out. + for (z in this); + gczeal(2); + + var a, b; gczeal(2); (function() { for (var p in this) { } })(); + + gczeal(0); + } + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-452178.js b/js/src/tests/non262/extensions/regress-452178.js new file mode 100644 index 0000000000..360bc273b9 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-452178.js @@ -0,0 +1,27 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 452178; +var summary = 'Do not assert with JIT: !(sprop->attrs & JSPROP_SHARED)'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + + Object.defineProperty(this, "q", { get: function(){}, enumerable: true, configurable: true }); + for (var j = 0; j < 4; ++j) q = 1; + + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-452329.js b/js/src/tests/non262/extensions/regress-452329.js new file mode 100644 index 0000000000..e2d94944c6 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-452329.js @@ -0,0 +1,24 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 452329; +var summary = 'Do not assert: *data->pc == JSOP_CALL || *data->pc == JSOP_NEW'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + this.__defineGetter__("x", "".match); if (x) 3; + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-452338.js b/js/src/tests/non262/extensions/regress-452338.js new file mode 100644 index 0000000000..2b6842fe5e --- /dev/null +++ b/js/src/tests/non262/extensions/regress-452338.js @@ -0,0 +1,26 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 452338; +var summary = 'Do not assert with JIT: obj2 == obj'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + + for (var j = 0; j < 4; ++j) __count__ = 3; + + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-452498-162.js b/js/src/tests/non262/extensions/regress-452498-162.js new file mode 100644 index 0000000000..543c9a1b06 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-452498-162.js @@ -0,0 +1,24 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 452498; +var summary = 'TM: upvar2 regression tests'; +var actual = ''; +var expect = ''; + +//------- Comment #162 From Gary Kwong + +printBugNumber(BUGNUMBER); +printStatus (summary); + +// Assertion failure: !OBJ_GET_CLASS(cx, proto)->getObjectOps, at ../jsobj.cpp:2030 + +this.__defineGetter__("x3", Function); +parseInt = x3; +parseInt.prototype = []; +for (var z = 0; z < 4; ++z) { new parseInt() } + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/non262/extensions/regress-452498-196.js b/js/src/tests/non262/extensions/regress-452498-196.js new file mode 100644 index 0000000000..5429b04384 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-452498-196.js @@ -0,0 +1,32 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 452498; +var summary = 'TM: upvar2 regression tests'; +var actual = ''; +var expect = ''; + +//------- Comment #196 From Gary Kwong + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + +// Assertion failure: lexdep->isLet(), at ../jsparse.cpp:1900 + + (function (){ + var x; + eval("var x; (function () { return x; })"); + } + )(); + + reportCompare(expect, actual, summary + ': 2'); +} diff --git a/js/src/tests/non262/extensions/regress-452565.js b/js/src/tests/non262/extensions/regress-452565.js new file mode 100644 index 0000000000..6ca0e87c4e --- /dev/null +++ b/js/src/tests/non262/extensions/regress-452565.js @@ -0,0 +1,19 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 452565; +var summary = 'Do not assert with JIT: !(sprop->attrs & JSPROP_READONLY)'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +printBugNumber(BUGNUMBER); +printStatus (summary); + + +var c = undefined; (function() { for (var j=0;j<5;++j) { c = 1; } })(); + + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/non262/extensions/regress-452913.js b/js/src/tests/non262/extensions/regress-452913.js new file mode 100644 index 0000000000..464d403ddf --- /dev/null +++ b/js/src/tests/non262/extensions/regress-452913.js @@ -0,0 +1,18 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 452913; +var summary = 'Do not crash with defined getter and for (let)'; +var actual = ''; +var expect = ''; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +(this.__defineGetter__("x", function (x) { return 'foo'.replace(/o/g, [1].push); })); +for(let y in [,,,]) for(let y in [,,,]) x = x; + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/non262/extensions/regress-453249.js b/js/src/tests/non262/extensions/regress-453249.js new file mode 100644 index 0000000000..910353da9a --- /dev/null +++ b/js/src/tests/non262/extensions/regress-453249.js @@ -0,0 +1,21 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 453249; +var summary = 'Do not assert with JIT: s0->isQuad()'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +printBugNumber(BUGNUMBER); +printStatus (summary); + + +this.__proto__.a = 3; for (var j = 0; j < 4; ++j) { [a]; } + +this.a = 3; for (var j = 0; j < 4; ++j) { [a]; } + + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/non262/extensions/regress-454744.js b/js/src/tests/non262/extensions/regress-454744.js new file mode 100644 index 0000000000..a686889d63 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-454744.js @@ -0,0 +1,32 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 454744; +var summary = 'Do not assert with JIT: PCVAL_IS_SPROP(entry->vword)'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + + try + { + this.__defineGetter__('x', function() { return 2; }); for (var j=0;j<4;++j) { x=1; } + } + catch(ex) + { + } + + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-455380.js b/js/src/tests/non262/extensions/regress-455380.js new file mode 100644 index 0000000000..f0405621da --- /dev/null +++ b/js/src/tests/non262/extensions/regress-455380.js @@ -0,0 +1,60 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + * Contributor: Robert Sayre + */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 455380; +var summary = 'Do not assert with JIT: !lhs->isQuad() && !rhs->isQuad()'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +printBugNumber(BUGNUMBER); +printStatus (summary); + + +const IS_TOKEN_ARRAY = + [0, 0, 0, 0, 0, 0, 0, 0, // 0 + 0, 0, 0, 0, 0, 0, 0, 0, // 8 + 0, 0, 0, 0, 0, 0, 0, 0, // 16 + 0, 0, 0, 0, 0, 0, 0, 0, // 24 + + 0, 1, 0, 1, 1, 1, 1, 1, // 32 + 0, 0, 1, 1, 0, 1, 1, 0, // 40 + 1, 1, 1, 1, 1, 1, 1, 1, // 48 + 1, 1, 0, 0, 0, 0, 0, 0, // 56 + + 0, 1, 1, 1, 1, 1, 1, 1, // 64 + 1, 1, 1, 1, 1, 1, 1, 1, // 72 + 1, 1, 1, 1, 1, 1, 1, 1, // 80 + 1, 1, 1, 0, 0, 0, 1, 1, // 88 + + 1, 1, 1, 1, 1, 1, 1, 1, // 96 + 1, 1, 1, 1, 1, 1, 1, 1, // 104 + 1, 1, 1, 1, 1, 1, 1, 1, // 112 + 1, 1, 1, 0, 1, 0, 1]; // 120 + +const headerUtils = { +normalizeFieldName: function(fieldName) +{ + if (fieldName == "") + throw "error: empty string"; + + for (var i = 0, sz = fieldName.length; i < sz; i++) + { + if (!IS_TOKEN_ARRAY[fieldName.charCodeAt(i)]) + { + throw (fieldName + " is not a valid header field name!"); + } + } + + return fieldName.toLowerCase(); +} +}; + +headerUtils.normalizeFieldName("Host"); + + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/non262/extensions/regress-455408.js b/js/src/tests/non262/extensions/regress-455408.js new file mode 100644 index 0000000000..2f3796c1eb --- /dev/null +++ b/js/src/tests/non262/extensions/regress-455408.js @@ -0,0 +1,26 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 455408; +var summary = 'Do not assert with JIT: "Should not move data from GPR to XMM": false'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + + for (var j = 0; j < 5; ++j) { if (({}).__proto__ = 1) { } } + + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-456826.js b/js/src/tests/non262/extensions/regress-456826.js new file mode 100644 index 0000000000..009e29790b --- /dev/null +++ b/js/src/tests/non262/extensions/regress-456826.js @@ -0,0 +1,126 @@ +// |reftest| skip-if(!xulRuntime.shell||Android) slow -- bug 504632 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 456826; +var summary = 'Do not assert with JIT during OOM'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + + if (typeof gcparam != 'undefined') + { + gc(); + gc(); + gcparam("maxBytes", gcparam("gcBytes") + 4*1024); + expectExitCode(5); + expectExitCode(3); + } + + const numRows = 600; + const numCols = 600; + var scratch = {}; + var scratchZ = {}; + + function complexMult(a, b) { + var newr = a.r * b.r - a.i * b.i; + var newi = a.r * b.i + a.i * b.r; + scratch.r = newr; + scratch.i = newi; + return scratch; + } + + function complexAdd(a, b) { + scratch.r = a.r + b.r; + scratch.i = a.i + b.i; + return scratch; + } + + function abs(a) { + return Math.sqrt(a.r * a.r + a.i * a.i); + } + + function computeEscapeSpeed(c) { + scratchZ.r = scratchZ.i = 0; + const scaler = 5; + const threshold = (colors.length - 1) * scaler + 1; + for (var i = 1; i < threshold; ++i) { + scratchZ = complexAdd(c, complexMult(scratchZ, scratchZ)); + if (scratchZ.r * scratchZ.r + scratchZ.i * scratchZ.i > 4) { + return Math.floor((i - 1) / scaler) + 1; + } + } + return 0; + } + + const colorStrings = [ + "black", + "green", + "blue", + "red", + "purple", + "orange", + "cyan", + "yellow", + "magenta", + "brown", + "pink", + "chartreuse", + "darkorange", + "crimson", + "gray", + "deeppink", + "firebrick", + "lavender", + "lawngreen", + "lightsalmon", + "lime", + "goldenrod" + ]; + + var colors = []; + + function createMandelSet(realRange, imagRange) { + var start = new Date(); + + // Set up our colors + for (var color of colorStrings) { + var [r, g, b] = [0, 0, 0]; + colors.push([r, g, b, 0xff]); + } + + var realStep = (realRange.max - realRange.min)/numCols; + var imagStep = (imagRange.min - imagRange.max)/numRows; + for (var i = 0, curReal = realRange.min; + i < numCols; + ++i, curReal += realStep) { + for (var j = 0, curImag = imagRange.max; + j < numRows; + ++j, curImag += imagStep) { + var c = { r: curReal, i: curImag } + var n = computeEscapeSpeed(c); + } + } + print(Date.now() - start); + } + + var realRange = { min: -2.1, max: 2 }; + var imagRange = { min: -2, max: 2 }; + createMandelSet(realRange, imagRange); + + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-459606.js b/js/src/tests/non262/extensions/regress-459606.js new file mode 100644 index 0000000000..5d7e868133 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-459606.js @@ -0,0 +1,26 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 459606; +var summary = '(0.1).toFixed()'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = "0"; + actual = (0.1).toFixed(); + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-462734-02.js b/js/src/tests/non262/extensions/regress-462734-02.js new file mode 100644 index 0000000000..f7ccb5977d --- /dev/null +++ b/js/src/tests/non262/extensions/regress-462734-02.js @@ -0,0 +1,26 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 462734; +var summary = 'Do not assert: pobj_ == obj2'; +var actual = ''; +var expect = ''; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +try +{ + for (x in function(){}) ([]); + this.__defineGetter__("x", Function); + var obj = Object.create(x); + obj.prototype += []; +} +catch(ex) +{ +} + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/non262/extensions/regress-462734-03.js b/js/src/tests/non262/extensions/regress-462734-03.js new file mode 100644 index 0000000000..c350154fc8 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-462734-03.js @@ -0,0 +1,25 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 462734; +var summary = 'Do not assert: pobj_ == obj2'; +var actual = ''; +var expect = ''; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +try +{ + Function.prototype.prototype; + var obj = Object.create(Function()); + obj.prototype = obj.prototype; +} +catch(ex) +{ +} + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/non262/extensions/regress-462734-04.js b/js/src/tests/non262/extensions/regress-462734-04.js new file mode 100644 index 0000000000..a7fbe8f07d --- /dev/null +++ b/js/src/tests/non262/extensions/regress-462734-04.js @@ -0,0 +1,29 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 462734; +var summary = 'Do not assert: pobj_ == obj2'; +var actual = ''; +var expect = ''; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +var obj; +try +{ + Function.prototype.prototype = function() { return 42; } + obj = Object.create(Function()); + obj.prototype = obj.prototype; +} +catch(ex) +{ +} + +expect = 'object'; +actual = typeof obj.prototype; + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/non262/extensions/regress-465276.js b/js/src/tests/non262/extensions/regress-465276.js new file mode 100644 index 0000000000..7eb90f91ab --- /dev/null +++ b/js/src/tests/non262/extensions/regress-465276.js @@ -0,0 +1,29 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 465276; +var summary = '((1 * (1))|""'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + empty = []; + out = []; + for (var j=0;j<10;++j) { empty[42]; out.push((1 * (1)) | ""); } + + assertEqArray(out, [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]); + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-465337.js b/js/src/tests/non262/extensions/regress-465337.js new file mode 100644 index 0000000000..f5167cb42a --- /dev/null +++ b/js/src/tests/non262/extensions/regress-465337.js @@ -0,0 +1,28 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 465337; +var summary = 'Do not assert: (m != JSVAL_INT) || isInt32(*vp)'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + var out = []; + for (let j = 0; j < 5; ++j) { out.push(6 - ((void 0) ^ 0x80000005)); } + + assertEqArray(out, [2147483649, 2147483649, 2147483649, 2147483649, 2147483649]); + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-465443.js b/js/src/tests/non262/extensions/regress-465443.js new file mode 100644 index 0000000000..4d0e9c13eb --- /dev/null +++ b/js/src/tests/non262/extensions/regress-465443.js @@ -0,0 +1,36 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 465443; +var summary = ''; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = 'TypeError: invalid assignment to const \'b\''; + + + try + { + eval('(function () { const b = 16; var out = []; for (b of [true, "", true, "", true, ""]) out.push(b >> 1) })();'); + } + catch(ex) + { + actual = ex + ''; + } + + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-465453.js b/js/src/tests/non262/extensions/regress-465453.js new file mode 100644 index 0000000000..084276f202 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-465453.js @@ -0,0 +1,38 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 465453; +var summary = 'Do not convert (undefined) to "undefined"'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = "true,,true,true,,,,,"; + + var out = []; + for (var e of [(new Boolean(true)), + (void 0), + (new Boolean(true)), + (new Boolean(true)), + (void 0), + (void 0), + "", + "", + (void 0)]) + out.push(e); + print(actual = out.toString()); + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-466905-04.js b/js/src/tests/non262/extensions/regress-466905-04.js new file mode 100644 index 0000000000..c724d0ce00 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-466905-04.js @@ -0,0 +1,46 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 466905; +var summary = 'Prototypes of sandboxed arrays'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + if (typeof evalcx != 'function') + { + expect = actual = 'Test skipped: requires evalcx support'; + } + else + { + expect = true; + + function createArray() + { + var a; + for (var i = 0; i < 10; i++) + a = [1, 2, 3, 4, 5]; + return a; + } + + var sandbox = evalcx("lazy"); + sandbox.createArray = createArray; + var p1 = Object.getPrototypeOf(createArray()); + var p2 = Object.getPrototypeOf(evalcx("createArray()", sandbox)); + print(actual = (p1 === p2)); + } + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-469234.js b/js/src/tests/non262/extensions/regress-469234.js new file mode 100644 index 0000000000..2ed0475c62 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-469234.js @@ -0,0 +1,27 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 469234; +var summary = 'TM: Do not assert: !JS_ON_TRACE(cx)'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + + for(var j=0;j<3;++j)({__proto__:[]}).__defineSetter__('x',function(){}); + + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-469405-01.js b/js/src/tests/non262/extensions/regress-469405-01.js new file mode 100644 index 0000000000..b1113d9b57 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-469405-01.js @@ -0,0 +1,27 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 469405; +var summary = 'Do not assert: !regs.sp[-2].isPrimitive()'; +var actual = ''; +var expect = ''; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +try +{ + (function() { + var a, b; + for (a of [{}, {__iterator__: function(){}}]) for (b in a) { } + })(); +} +catch(ex) +{ + print('caught ' + ex); +} + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/non262/extensions/regress-469405-02.js b/js/src/tests/non262/extensions/regress-469405-02.js new file mode 100644 index 0000000000..196557e699 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-469405-02.js @@ -0,0 +1,25 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 469405; +var summary = 'Do not assert: !regs.sp[-2].isPrimitive()'; +var actual = ''; +var expect = ''; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +try +{ + eval("__proto__.__iterator__ = [].toString"); + for (var z = 0; z < 3; ++z) { if (z % 3 == 2) { for(let y in []); } } +} +catch(ex) +{ + print('caught ' + ex); +} + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/non262/extensions/regress-469625-01.js b/js/src/tests/non262/extensions/regress-469625-01.js new file mode 100644 index 0000000000..aa4d5bbc7d --- /dev/null +++ b/js/src/tests/non262/extensions/regress-469625-01.js @@ -0,0 +1,39 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + * Contributor: Jason Orendorff + */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 469625; +var summary = 'TM: Array prototype and expression closures'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = 'TypeError: [].__proto__ is not a function'; + + + Array.prototype.__proto__ = function () { return 3; }; + + try + { + [].__proto__(); + } + catch(ex) + { + print(actual = ex + ''); + } + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-469625.js b/js/src/tests/non262/extensions/regress-469625.js new file mode 100644 index 0000000000..84610b4889 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-469625.js @@ -0,0 +1,28 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 469625; +var summary = 'TM: Do not crash @ js_String_getelem'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + + [].__proto__[0] = 'a'; + for (var j = 0; j < 3; ++j) [[, ]] = [,]; + + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-469761.js b/js/src/tests/non262/extensions/regress-469761.js new file mode 100644 index 0000000000..2866d18935 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-469761.js @@ -0,0 +1,28 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 469761; +var summary = 'TM: Do not assert: STOBJ_GET_SLOT(callee_obj, JSSLOT_PRIVATE).isInt32()'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + + var o = { __proto__: function(){} }; + for (var j = 0; j < 3; ++j) { try { o.call(3); } catch (e) { } } + + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-470300-01.js b/js/src/tests/non262/extensions/regress-470300-01.js new file mode 100644 index 0000000000..59e10868bf --- /dev/null +++ b/js/src/tests/non262/extensions/regress-470300-01.js @@ -0,0 +1,27 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 470300; +var summary = 'TM: Do not assert: StackBase(fp) + blockDepth == regs.sp'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + + for (let a = 0; a < 3; ++a) { let b = '' + []; } + + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-470300-02.js b/js/src/tests/non262/extensions/regress-470300-02.js new file mode 100644 index 0000000000..6e760e091c --- /dev/null +++ b/js/src/tests/non262/extensions/regress-470300-02.js @@ -0,0 +1,27 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 470300; +var summary = 'TM: Do not assert: !fp->blockChain || OBJ_GET_PARENT(cx, obj) == fp->blockChain'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + + for (let a = 0; a < 7; ++a) { let e = 8; if (a > 3) { let x; } } + + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-470310.js b/js/src/tests/non262/extensions/regress-470310.js new file mode 100644 index 0000000000..460a60cc80 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-470310.js @@ -0,0 +1,30 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 470310; +var summary = 'Do not assert: (uint32_t)((atoms - script->atomMap.vector + ' + + '((uintN)(((regs.pc + 0)[1] << 8) | (regs.pc + 0)[2])))) < objects_->length'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = 'TypeError: 6 is not a function'; + + this.__defineSetter__('m', [].map); + function f() { for (var j = 0; j < 4; ++j) if (j == 3) m = 6; } + try { f(); } catch(e) { print(actual = e + ''); } + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-472450-03.js b/js/src/tests/non262/extensions/regress-472450-03.js new file mode 100644 index 0000000000..72609e4d23 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-472450-03.js @@ -0,0 +1,31 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 472450; +var summary = 'TM: Do not assert: StackBase(fp) + blockDepth == regs.sp'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + + var cyclic = []; + cyclic[0] = cyclic; + ({__proto__: cyclic}) + for (var y = 0; y < 3; ++y) { for (let z of ['', function(){}]) { let x = + 1, c = []; } } + + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-472450-04.js b/js/src/tests/non262/extensions/regress-472450-04.js new file mode 100644 index 0000000000..56c7e5597c --- /dev/null +++ b/js/src/tests/non262/extensions/regress-472450-04.js @@ -0,0 +1,33 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 472450; +var summary = 'TM: Do not assert: StackBase(fp) + blockDepth == regs.sp'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + + var cyclic = []; + cyclic[0] = cyclic; + ({__proto__: cyclic}); + function f(){ + eval("for (var y = 0; y < 1; ++y) { for (let z of [null, function(){}, null, '', null, '', null]) { let x = 1, c = []; } }"); + } + f(); + + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-472599.js b/js/src/tests/non262/extensions/regress-472599.js new file mode 100644 index 0000000000..474e0b6336 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-472599.js @@ -0,0 +1,29 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 472599; +var summary = 'Do not assert: STOBJ_GET_SLOT(callee_obj, JSSLOT_PRIVATE).isInt32()'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + + var a = (function(){}).prototype; + a.__proto__ = a.toString; + for (var i = 0; i < 4; ++i) { try{ a.call({}); } catch(e) { } } + + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-473040.js b/js/src/tests/non262/extensions/regress-473040.js new file mode 100644 index 0000000000..95eb543e6a --- /dev/null +++ b/js/src/tests/non262/extensions/regress-473040.js @@ -0,0 +1,25 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 473040; +var summary = 'Do not assert: tm->reservedDoublePoolPtr > tm->reservedDoublePool'; +var actual = ''; +var expect = ''; + +printBugNumber(BUGNUMBER); +printStatus (summary); + + +Object.defineProperty(__proto__, "functional", +{ + enumerable: true, configurable: true, + get: new Function("gc()") +}); +for (let x of [new Boolean(true), new Boolean(true), -0, new + Boolean(true), -0]) { undefined; } + + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/non262/extensions/regress-474771-01.js b/js/src/tests/non262/extensions/regress-474771-01.js new file mode 100644 index 0000000000..b9905947b1 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-474771-01.js @@ -0,0 +1,29 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 474771; +var summary = 'TM: do not assert: jumpTable == interruptJumpTable'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + + var o = {}; + o.__defineSetter__('x', function(){}); + for (let j = 0; j < 4; ++j) o.x = 3; + + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-474771-02.js b/js/src/tests/non262/extensions/regress-474771-02.js new file mode 100644 index 0000000000..127351858a --- /dev/null +++ b/js/src/tests/non262/extensions/regress-474771-02.js @@ -0,0 +1,20 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 474771; +var summary = 'TM: do not assert: jumpTable == interruptJumpTable'; +var actual = ''; +var expect = ''; + +printBugNumber(BUGNUMBER); +printStatus (summary); + + +this.__defineSetter__('x', function(){}); +for (var j = 0; j < 5; ++j) { x = 3; } + + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/non262/extensions/regress-476414-01.js b/js/src/tests/non262/extensions/regress-476414-01.js new file mode 100644 index 0000000000..2b0db43ab5 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-476414-01.js @@ -0,0 +1,61 @@ +// |reftest| skip-if(!xulRuntime.shell) slow +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 476414; +var summary = 'Do not crash @ GetGCThingFlags'; +var actual = ''; +var expect = ''; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +function whatToTestSpidermonkeyTrunk(code) +{ + return { + allowExec: true + }; +} +whatToTest = whatToTestSpidermonkeyTrunk; +function tryItOut(code) +{ + var wtt = whatToTest(code.replace(/\n/g, " ").replace(/\r/g, " ")); + var f = new Function(code); + if (wtt.allowExec && f) { + rv = tryRunning(f, code); + } +} +function tryRunning(f, code) +{ + try { + var rv = f(); + } catch(runError) {} +} +var realFunction = Function; +var realToString = toString; +function tryEnsureSanity() +{ + delete Function; + delete toString; + Function = realFunction; + toString = realToString; +} +for (let iters = 0; iters < 2000; ++iters) { + count=27745; tryItOut("with({x: (c) = (x2 = [])})false;"); + tryEnsureSanity(); + count=35594; tryItOut("switch(null) { case this.__defineSetter__(\"window\", function* () { yield \"\" } ): break; }"); + tryEnsureSanity(); + count=45020; tryItOut("with({}) { (this.__defineGetter__(\"x\", function (y){ return this; })); } "); + tryEnsureSanity(); + count=45197; tryItOut("M:with((p={}, (p.z = false )()))/*TUUL*/for (let y of [true, {}, {}, (void 0), true, true, true, (void 0), true, (void 0)]) { return; }"); + tryEnsureSanity(); + gc(); + tryEnsureSanity(); + count=45254; tryItOut("for (NaN in this);"); + tryEnsureSanity(); +} + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/non262/extensions/regress-476414-02.js b/js/src/tests/non262/extensions/regress-476414-02.js new file mode 100644 index 0000000000..5a1cb1fe91 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-476414-02.js @@ -0,0 +1,61 @@ +// |reftest| skip-if(!xulRuntime.shell) slow +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 476414; +var summary = 'Do not crash @ js_NativeSet'; +var actual = ''; +var expect = ''; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +function whatToTestSpidermonkeyTrunk(code) +{ + return { + allowExec: true + }; +} +whatToTest = whatToTestSpidermonkeyTrunk; +function tryItOut(code) +{ + var wtt = whatToTest(code.replace(/\n/g, " ").replace(/\r/g, " ")); + var f = new Function(code); + if (wtt.allowExec && f) { + rv = tryRunning(f, code); + } +} +function tryRunning(f, code) +{ + try { + var rv = f(); + } catch(runError) {} +} +var realFunction = Function; +var realToString = toString; +function tryEnsureSanity() +{ + delete Function; + delete toString; + Function = realFunction; + toString = realToString; +} +for (let iters = 0; iters < 2000; ++iters) { + count=27745; tryItOut("with({x: (c) = (x2 = [])})false;"); + tryEnsureSanity(); + count=35594; tryItOut("switch(null) { case this.__defineSetter__(\"window\", function* () { yield \"\" } ): break; }"); + tryEnsureSanity(); + count=45020; tryItOut("with({}) { (this.__defineGetter__(\"x\", function (y) { return this; })); } "); + tryEnsureSanity(); + count=45197; tryItOut("M:with((p={}, (p.z = false )()))/*TUUL*/for (let y of [true, {}, {}, (void 0), true, true, true, (void 0), true, (void 0)]) { return; }"); + tryEnsureSanity(); + gc(); + tryEnsureSanity(); + count=45254; tryItOut("for (NaN in this);"); + tryEnsureSanity(); +} + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/non262/extensions/regress-476447.js b/js/src/tests/non262/extensions/regress-476447.js new file mode 100644 index 0000000000..ccac0b3019 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-476447.js @@ -0,0 +1,30 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 476447; +var summary = 'Array getter/setter'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + Array.prototype.__defineGetter__('lastElement',(function() { return this[this.length-1]})); + Array.prototype.__defineSetter__('lastElement',(function(num){this[this.length-1]=num})); + var testArr=[1,2,3,4]; + + expect = 4; + actual = testArr.lastElement; + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-476653.js b/js/src/tests/non262/extensions/regress-476653.js new file mode 100644 index 0000000000..f0d27713e0 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-476653.js @@ -0,0 +1,33 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 476653; +var summary = 'Do not crash @ QuoteString'; +var actual = ''; +var expect = ''; + + +printBugNumber(BUGNUMBER); +printStatus (summary); + + +for (let x1 of ['']) +for (i = 0; i < 1; ++i) {} +for (i = 0; i < 1; ++i) {} +for (let x of [new String('q'), '', /x/, '', /x/]) { + for (var y = 0; y < 7; ++y) { if (y == 2 || y == 6) { setter = x; } } +} +try +{ + this.f(z); +} +catch(ex) +{ +} + + +reportCompare(expect, actual, summary); + diff --git a/js/src/tests/non262/extensions/regress-476869.js b/js/src/tests/non262/extensions/regress-476869.js new file mode 100644 index 0000000000..39f3dcd3dd --- /dev/null +++ b/js/src/tests/non262/extensions/regress-476869.js @@ -0,0 +1,42 @@ +// |reftest| skip-if(Android) +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 476869; +var summary = 'Do not assert: v != JSVAL_ERROR_COOKIE'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + if (typeof gczeal == 'undefined') + { + gczeal = (function (){}); + } + + + function f() + { + (new Function("gczeal(1); for (let y of [/x/,'',new Boolean(false),new Boolean(false),new Boolean(false),'',/x/,new Boolean(false),new Boolean(false)]){}"))(); + } + __proto__.__iterator__ = this.__defineGetter__("", function(){}) + f(); + + + delete __proto__.__iterator__; + + gczeal(0); + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-477158.js b/js/src/tests/non262/extensions/regress-477158.js new file mode 100644 index 0000000000..d3696813ef --- /dev/null +++ b/js/src/tests/non262/extensions/regress-477158.js @@ -0,0 +1,28 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 477158; +var summary = 'Do not assert: v == JSVAL_TRUE || v == JSVAL_FALSE'; +var actual = ''; +var expect = ''; + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + + x = 0; + x = x.prop; + for (let [] of ['', '']) { switch(x) { default: (function(){}); } }; + + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-477187.js b/js/src/tests/non262/extensions/regress-477187.js new file mode 100644 index 0000000000..031ddd83dd --- /dev/null +++ b/js/src/tests/non262/extensions/regress-477187.js @@ -0,0 +1,38 @@ +// |reftest| skip-if(Android) +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 477187; +var summary = 'timeout script'; +var actual = ''; +var expect = ''; + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + if (typeof window != 'undefined' || typeof timeout != 'function') + { + print(expect = actual = 'Test skipped due to lack of timeout function'); + reportCompare(expect, actual, summary); + } + else + { + expectExitCode(6); + timeout(0.01); + // Call reportCompare early here to get a result. The test will fail if + // the timeout doesn't work and the test framework is forced to terminate + // the test. + reportCompare(expect, actual, summary); + + while(1); + } +} diff --git a/js/src/tests/non262/extensions/regress-479487.js b/js/src/tests/non262/extensions/regress-479487.js new file mode 100644 index 0000000000..357c33d435 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-479487.js @@ -0,0 +1,41 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 479487; +var summary = 'js_Array_dense_setelem can call arbitrary JS code'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + + Array.prototype[1] = 2; + + Array.prototype.__defineSetter__(32, function() { print("Hello from arbitrary JS");}); + Array.prototype.__defineGetter__(32, function() { return 11; }); + + function f() + { + var a = []; + for (var i = 0; i != 10; ++i) { + a[1 << i] = 9999; + } + return a; + } + + f(); + + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-479551.js b/js/src/tests/non262/extensions/regress-479551.js new file mode 100644 index 0000000000..a08f941f22 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-479551.js @@ -0,0 +1,39 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 479551; +var summary = 'Do not assert: (cx)->requestDepth || (cx)->thread == (cx)->runtime->gcThread'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + if (typeof shapeOf != 'function') + { + print(expect = actual = 'Test skipped: requires shell'); + } + else + { + + var o = {a:3, b:2}; + shapeOf(o); + var p = {}; + p.a =3; + p.b=2; + shapeOf(p); + + + } + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-480579.js b/js/src/tests/non262/extensions/regress-480579.js new file mode 100644 index 0000000000..f28fe3a1fa --- /dev/null +++ b/js/src/tests/non262/extensions/regress-480579.js @@ -0,0 +1,35 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + * Contributor: Jason Orendorff + */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 480579; +var summary = 'Do not assert: pobj_ == obj2'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = '12'; + + a = {x: 1}; + b = {__proto__: a}; + c = {__proto__: b}; + for (i = 0; i < 2; i++) { + print(actual += c.x); + b.x = 2; + } + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-481516.js b/js/src/tests/non262/extensions/regress-481516.js new file mode 100644 index 0000000000..e6bf1007f4 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-481516.js @@ -0,0 +1,38 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + * Contributor: Jason Orendorff + */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 481516; +var summary = 'TM: pobj_ == obj2'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = '1111222'; + + a = {x: 1}; + b = {__proto__: a}; + c = {__proto__: b}; + objs = [{__proto__: a}, {__proto__: a}, {__proto__: a}, b, {__proto__: a}, + {__proto__: a}]; + for (i = 0; i < 6; i++) { + print(actual += ""+c.x); + objs[i].x = 2; + } + print(actual += c.x); + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/regress-482263.js b/js/src/tests/non262/extensions/regress-482263.js new file mode 100644 index 0000000000..57159dc999 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-482263.js @@ -0,0 +1,26 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 482263; +var summary = 'TM: Do not assert: x->oprnd2() == lirbuf->sp || x->oprnd2() == gp_ins'; +var actual = ''; +var expect = ''; + +printBugNumber(BUGNUMBER); +printStatus (summary); + + +Object.defineProperty(__proto__, "x", +{ + enumerable: true, configurable: true, + get: function () { return ([]) } +}); +for (let x of []) { for (let x of ['', '']) { } } + + +reportCompare(expect, actual, summary); + +delete __proto__.x; diff --git a/js/src/tests/non262/extensions/regress-50447-1.js b/js/src/tests/non262/extensions/regress-50447-1.js new file mode 100644 index 0000000000..6af94b9a19 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-50447-1.js @@ -0,0 +1,179 @@ +/* -*- tab-width: 8; indent-tabs-mode: nil; js-indent-level: 4 -*- + * vim: set ts=8 sts=4 et sw=4 tw=99: + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/* + * SUMMARY: New properties fileName, lineNumber have been added to Error objects + * in SpiderMonkey. These are non-ECMA extensions and do not exist in Rhino. + * + * See http://bugzilla.mozilla.org/show_bug.cgi?id=50447 + * + * 2005-04-05 Modified by bclary to support changes to error reporting + * which set default values for the error's fileName and + * lineNumber properties. + */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 50447; +var summary = 'Test (non-ECMA) Error object properties fileName, lineNumber'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + +function test() +{ + + printBugNumber(BUGNUMBER); + printStatus (summary); + + testRealError(); + test1(); + test2(); + test3(); + test4(); + + +} + +// Normalize filenames so this test can work on Windows. This +// function is also used on strings that contain filenames. +function normalize(filename) +{ + // Also convert double-backslash to single-slash to handle + // escaped filenames in string literals. + return filename.replace(/\\{1,2}/g, '/'); +} + +function testRealError() +{ + /* throw a real error, and see what it looks like */ + + + try + { + blabla; + } + catch (e) + { + if (e.fileName.search (/-50447-1\.js$/i) == -1) + reportCompare('PASS', 'FAIL', "expected fileName to end with '-50447-1.js'"); + + reportCompare(60, e.lineNumber, + "lineNumber property returned unexpected value."); + } + + +} + + +function test1() +{ + /* generate an error with msg, file, and lineno properties */ + + + var e = new InternalError ("msg", "file", 2); + if (Error.prototype.toSource) { + reportCompare ("(new InternalError(\"msg\", \"file\", 2))", + e.toSource(), + "toSource() returned unexpected result."); + } + reportCompare ("file", e.fileName, + "fileName property returned unexpected value."); + reportCompare (2, e.lineNumber, + "lineNumber property returned unexpected value."); + + +} + + +function test2() +{ + /* generate an error with only msg property */ + + + /* note this test incorporates the path to the + test file and assumes the path to the test case + is a subdirectory of the directory containing jsDriver.pl + */ + var expectedLine = 108; + var expectedFileName = 'non262/extensions/regress-50447-1.js'; + var expectedSource = /\(new InternalError\("msg", "([^"]+)", ([0-9]+)\)\)/; + + var e = new InternalError ("msg"); + + if (Error.prototype.toSource) { + var actual = expectedSource.exec(e.toSource()); + reportCompare (normalize(actual[1]).endsWith(expectedFileName), true, + "toSource() returned unexpected result (filename)."); + reportCompare (actual[2], String(expectedLine), + "toSource() returned unexpected result (line)."); + } + reportCompare (normalize(e.fileName).endsWith(expectedFileName), true, + "fileName property returned unexpected value."); + reportCompare (expectedLine, e.lineNumber, + "lineNumber property returned unexpected value."); + + +} + + +function test3() +{ + /* generate an error with only msg and lineNo properties */ + + /* note this test incorporates the path to the + test file and assumes the path to the test case + is a subdirectory of the directory containing jsDriver.pl + */ + + + + var expectedLine = 10; + var expectedFileName = 'non262/extensions/regress-50447-1.js'; + var expectedSource = /\(new InternalError\("msg", "([^"]+)", ([0-9]+)\)\)/; + + var e = new InternalError ("msg"); + e.lineNumber = expectedLine; + + if (Error.prototype.toSource) { + var actual = expectedSource.exec(e.toSource()); + reportCompare (normalize(actual[1]).endsWith(expectedFileName), true, + "toSource() returned unexpected result (filename)."); + reportCompare (actual[2], String(expectedLine), + "toSource() returned unexpected result (line)."); + } + reportCompare (normalize(e.fileName).endsWith(expectedFileName), true, + "fileName property returned unexpected value."); + reportCompare (expectedLine, e.lineNumber, + "lineNumber property returned unexpected value."); + + +} + + +function test4() +{ + /* generate an error with only msg and filename properties */ + + + var expectedLine = 167; + + var e = new InternalError ("msg", "file"); + if (Error.prototype.toSource) { + reportCompare ("(new InternalError(\"msg\", \"file\", " + expectedLine + "))", + e.toSource(), + "toSource() returned unexpected result."); + } + reportCompare ("file", e.fileName, + "fileName property returned unexpected value."); + reportCompare (expectedLine, e.lineNumber, + "lineNumber property returned unexpected value."); + + +} diff --git a/js/src/tests/non262/extensions/regress-543839.js b/js/src/tests/non262/extensions/regress-543839.js new file mode 100644 index 0000000000..ce968bfba7 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-543839.js @@ -0,0 +1,36 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 4 -*- */ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + * Contributor: Igor Bukanov + */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 543839; +var summary = 'js_GetMutableScope caller must lock the object'; +var actual; +var expect = 1; + +printBugNumber(BUGNUMBER); +printStatus (summary); + + +function test() +{ + for (var i = 0; i != 100; ++i) + var tmp = { a: 1 }; + return 1; +} + +if (typeof evalcx == 'undefined') +{ + print('Skipping. This test requires evalcx.'); + actual = expect; +} else { + test(); + test(); + test(); + actual = evalcx("test()", this); +} + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/non262/extensions/regress-591450.js b/js/src/tests/non262/extensions/regress-591450.js new file mode 100644 index 0000000000..f1ebcf6758 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-591450.js @@ -0,0 +1,12 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +/* + * This was causing the parser to assert at one point. Now it's not. Yay! + */ +function f(a,[x,y],b,[w,z],c) { function b() { } } + +reportCompare(0, 0, "don't crash"); diff --git a/js/src/tests/non262/extensions/regress-636818.js b/js/src/tests/non262/extensions/regress-636818.js new file mode 100644 index 0000000000..9fa1bc3798 --- /dev/null +++ b/js/src/tests/non262/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/non262/extensions/regress-645160.js b/js/src/tests/non262/extensions/regress-645160.js new file mode 100644 index 0000000000..933d3e2614 --- /dev/null +++ b/js/src/tests/non262/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/non262/extensions/regress-650753.js b/js/src/tests/non262/extensions/regress-650753.js new file mode 100644 index 0000000000..a518ec52a3 --- /dev/null +++ b/js/src/tests/non262/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/non262/extensions/regress-696109.js b/js/src/tests/non262/extensions/regress-696109.js new file mode 100644 index 0000000000..4a56340d36 --- /dev/null +++ b/js/src/tests/non262/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/non262/extensions/regress-90596-001.js b/js/src/tests/non262/extensions/regress-90596-001.js new file mode 100644 index 0000000000..7a22ec8b37 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-90596-001.js @@ -0,0 +1,264 @@ +// |reftest| skip-if(!Object.prototype.toSource) + +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * Date: 28 August 2001 + * + * SUMMARY: A [DontEnum] prop, if overridden, should appear in toSource(). + * See http://bugzilla.mozilla.org/show_bug.cgi?id=90596 + * + * NOTE: some inefficiencies in the test are made for the sake of readability. + * Sorting properties alphabetically is done for definiteness in comparisons. + */ +//----------------------------------------------------------------------------- +var UBound = 0; +var BUGNUMBER = 90596; +var summary = 'A [DontEnum] prop, if overridden, should appear in toSource()'; +var cnCOMMA = ','; +var cnLBRACE = '{'; +var cnRBRACE = '}'; +var cnLPAREN = '('; +var cnRPAREN = ')'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; +var obj = {}; + + +status = inSection(1); +obj = {toString:9}; +actual = obj.toSource(); +expect = '({toString:9})'; +addThis(); + +status = inSection(2); +obj = {hasOwnProperty:"Hi"}; +actual = obj.toSource(); +expect = '({hasOwnProperty:"Hi"})'; +addThis(); + +status = inSection(3); +obj = {toString:9, hasOwnProperty:"Hi"}; +actual = obj.toSource(); +expect = '({toString:9, hasOwnProperty:"Hi"})'; +addThis(); + +status = inSection(4); +obj = {prop1:1, toString:9, hasOwnProperty:"Hi"}; +actual = obj.toSource(); +expect = '({prop1:1, toString:9, hasOwnProperty:"Hi"})'; +addThis(); + + +// TRY THE SAME THING IN EVAL CODE +var s = ''; + +status = inSection(5); +s = 'obj = {toString:9}'; +eval(s); +actual = obj.toSource(); +expect = '({toString:9})'; +addThis(); + +status = inSection(6); +s = 'obj = {hasOwnProperty:"Hi"}'; +eval(s); +actual = obj.toSource(); +expect = '({hasOwnProperty:"Hi"})'; +addThis(); + +status = inSection(7); +s = 'obj = {toString:9, hasOwnProperty:"Hi"}'; +eval(s); +actual = obj.toSource(); +expect = '({toString:9, hasOwnProperty:"Hi"})'; +addThis(); + +status = inSection(8); +s = 'obj = {prop1:1, toString:9, hasOwnProperty:"Hi"}'; +eval(s); +actual = obj.toSource(); +expect = '({prop1:1, toString:9, hasOwnProperty:"Hi"})'; +addThis(); + + +// TRY THE SAME THING IN FUNCTION CODE +function A() +{ + status = inSection(9); + var s = 'obj = {toString:9}'; + eval(s); + actual = obj.toSource(); + expect = '({toString:9})'; + addThis(); +} +A(); + +function B() +{ + status = inSection(10); + var s = 'obj = {hasOwnProperty:"Hi"}'; + eval(s); + actual = obj.toSource(); + expect = '({hasOwnProperty:"Hi"})'; + addThis(); +} +B(); + +function C() +{ + status = inSection(11); + var s = 'obj = {toString:9, hasOwnProperty:"Hi"}'; + eval(s); + actual = obj.toSource(); + expect = '({toString:9, hasOwnProperty:"Hi"})'; + addThis(); +} +C(); + +function D() +{ + status = inSection(12); + var s = 'obj = {prop1:1, toString:9, hasOwnProperty:"Hi"}'; + eval(s); + actual = obj.toSource(); + expect = '({prop1:1, toString:9, hasOwnProperty:"Hi"})'; + addThis(); +} +D(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +/* + * Sort properties alphabetically - + */ +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = sortThis(actual); + expectedvalues[UBound] = sortThis(expect); + UBound++; +} + + +/* + * Takes string of form '({"c", "b", "a", 2})' and returns '({"a","b","c",2})' + */ +function sortThis(sList) +{ + sList = compactThis(sList); + sList = stripParens(sList); + sList = stripBraces(sList); + var arr = sList.split(cnCOMMA); + arr = arr.sort(); + var ret = String(arr); + ret = addBraces(ret); + ret = addParens(ret); + return ret; +} + + +/* + * Strips out any whitespace from the text - + */ +function compactThis(text) +{ + var charCode = 0; + var ret = ''; + + for (var i=0; i<text.length; i++) + { + charCode = text.charCodeAt(i); + + if (!isWhiteSpace(charCode)) + ret += text.charAt(i); + } + + return ret; +} + + +function isWhiteSpace(charCode) +{ + switch (charCode) + { + case (0x0009): + case (0x000B): + case (0x000C): + case (0x0020): + case (0x000A): // '\n' + case (0x000D): // '\r' + return true; + break; + + default: + return false; + } +} + + +/* + * strips off parens at beginning and end of text - + */ +function stripParens(text) +{ + // remember to escape the parens... + var arr = text.match(/^\((.*)\)$/); + + // defend against a null match... + if (arr != null && arr[1] != null) + return arr[1]; + return text; +} + + +/* + * strips off braces at beginning and end of text - + */ +function stripBraces(text) +{ + // remember to escape the braces... + var arr = text.match(/^\{(.*)\}$/); + + // defend against a null match... + if (arr != null && arr[1] != null) + return arr[1]; + return text; +} + + +function addBraces(text) +{ + return cnLBRACE + text + cnRBRACE; +} + + +function addParens(text) +{ + return cnLPAREN + text + cnRPAREN; +} + + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + for (var i=0; i<UBound; i++) + { + reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); + } +} diff --git a/js/src/tests/non262/extensions/regress-96284-001.js b/js/src/tests/non262/extensions/regress-96284-001.js new file mode 100644 index 0000000000..ec0992f6a4 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-96284-001.js @@ -0,0 +1,147 @@ +// |reftest| skip-if(!Error.prototype.toSource) + +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * Date: 03 September 2001 + * + * SUMMARY: Double quotes should be escaped in Error.prototype.toSource() + * See http://bugzilla.mozilla.org/show_bug.cgi?id=96284 + * + * The real point here is this: we should be able to reconstruct an object + * from its toSource() property. We'll test this on various types of objects. + * + * Method: define obj2 = eval(obj1.toSource()) and verify that + * obj2.toSource() == obj1.toSource(). + */ +//----------------------------------------------------------------------------- +var UBound = 0; +var BUGNUMBER = 96284; +var summary = 'Double quotes should be escaped in Error.prototype.toSource()'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; +var obj1 = {}; +var obj2 = {}; +var cnTestString = '"This is a \" STUPID \" test string!!!"\\'; + + +// various NativeError objects - +status = inSection(1); +obj1 = Error(cnTestString); +obj2 = eval(obj1.toSource()); +actual = obj2.toSource(); +expect = obj1.toSource(); +addThis(); + +status = inSection(2); +obj1 = EvalError(cnTestString); +obj2 = eval(obj1.toSource()); +actual = obj2.toSource(); +expect = obj1.toSource(); +addThis(); + +status = inSection(3); +obj1 = RangeError(cnTestString); +obj2 = eval(obj1.toSource()); +actual = obj2.toSource(); +expect = obj1.toSource(); +addThis(); + +status = inSection(4); +obj1 = ReferenceError(cnTestString); +obj2 = eval(obj1.toSource()); +actual = obj2.toSource(); +expect = obj1.toSource(); +addThis(); + +status = inSection(5); +obj1 = SyntaxError(cnTestString); +obj2 = eval(obj1.toSource()); +actual = obj2.toSource(); +expect = obj1.toSource(); +addThis(); + +status = inSection(6); +obj1 = TypeError(cnTestString); +obj2 = eval(obj1.toSource()); +actual = obj2.toSource(); +expect = obj1.toSource(); +addThis(); + +status = inSection(7); +obj1 = URIError(cnTestString); +obj2 = eval(obj1.toSource()); +actual = obj2.toSource(); +expect = obj1.toSource(); +addThis(); + + +// other types of objects - +status = inSection(8); +obj1 = new String(cnTestString); +obj2 = eval(obj1.toSource()); +actual = obj2.toSource(); +expect = obj1.toSource(); +addThis(); + +status = inSection(9); +obj1 = {color:'red', texture:cnTestString, hasOwnProperty:42}; +obj2 = eval(obj1.toSource()); +actual = obj2.toSource(); +expect = obj1.toSource(); +addThis(); + +status = inSection(10); +obj1 = function(x) {function g(y){return y+1;} return g(x);}; +obj2 = eval(obj1.toSource()); +actual = obj2.toSource(); +expect = obj1.toSource(); +addThis(); + +status = inSection(11); +obj1 = new Number(eval('6')); +obj2 = eval(obj1.toSource()); +actual = obj2.toSource(); +expect = obj1.toSource(); +addThis(); + +status = inSection(12); +obj1 = /ad;(lf)kj(2309\/\/)\/\//; +obj2 = eval(obj1.toSource()); +actual = obj2.toSource(); +expect = obj1.toSource(); +addThis(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + for (var i = 0; i < UBound; i++) + { + reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); + } +} diff --git a/js/src/tests/non262/extensions/regress-bug607284.js b/js/src/tests/non262/extensions/regress-bug607284.js new file mode 100644 index 0000000000..7d2c4921d2 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-bug607284.js @@ -0,0 +1,16 @@ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +if ("evalcx" in this) { + var sandbox = evalcx(""); + var obj = { get foo() { throw("FAIL"); } }; + var getter = obj.__lookupGetter__("foo"); + var desc = sandbox.Object.getOwnPropertyDescriptor(obj, "foo"); + reportCompare(desc.get, getter, "getter is correct"); + reportCompare(desc.set, undefined, "setter is correct"); +} +else { + reportCompare(true, true); +} diff --git a/js/src/tests/non262/extensions/regress-bug629723.js b/js/src/tests/non262/extensions/regress-bug629723.js new file mode 100644 index 0000000000..6c826e0c20 --- /dev/null +++ b/js/src/tests/non262/extensions/regress-bug629723.js @@ -0,0 +1,16 @@ +function f(foo) { + "use strict"; + foo.bar; +} + +var actual; +try { + f(); + actual = "no error"; +} catch (x) { + actual = (x instanceof TypeError) ? "type error" : "some other error"; + actual += (/use strict/.test(x)) ? " with directive" : " without directive"; +} + +reportCompare("type error without directive", actual, + "decompiled expressions in error messages should not include directive prologues"); diff --git a/js/src/tests/non262/extensions/reviver-mutates-holder-array-ccw.js b/js/src/tests/non262/extensions/reviver-mutates-holder-array-ccw.js new file mode 100644 index 0000000000..e51e199033 --- /dev/null +++ b/js/src/tests/non262/extensions/reviver-mutates-holder-array-ccw.js @@ -0,0 +1,39 @@ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + * Contributor: + * Jeff Walden <jwalden+code@mit.edu> + */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 901351; +var summary = "Behavior when the JSON.parse reviver mutates the holder array"; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +var proxyObj = null; + +var arr = JSON.parse('[0, 1]', function(prop, v) { + if (prop === "0") + { + proxyObj = newGlobal().evaluate("({ c: 17, d: 42 })"); + this[1] = proxyObj; + } + return v; +}); + +assertEq(arr[0], 0); +assertEq(arr[1], proxyObj); +assertEq(arr[1].c, 17); +assertEq(arr[1].d, 42); + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete"); diff --git a/js/src/tests/non262/extensions/reviver-mutates-holder-array-nonnative.js b/js/src/tests/non262/extensions/reviver-mutates-holder-array-nonnative.js new file mode 100644 index 0000000000..de4ad7032e --- /dev/null +++ b/js/src/tests/non262/extensions/reviver-mutates-holder-array-nonnative.js @@ -0,0 +1,46 @@ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + * Contributor: + * Jeff Walden <jwalden+code@mit.edu> + */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 901380; +var summary = "Behavior when JSON.parse walks over a non-native object"; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +var typedArray = null; + +var observedTypedArrayElementCount = 0; + +var arr = JSON.parse('[0, 1]', function(prop, v) { + if (prop === "0" && Array.isArray(this)) // exclude typedArray[0] + { + typedArray = new Int8Array(1); + this[1] = typedArray; + } + if (this instanceof Int8Array) + { + assertEq(prop, "0"); + observedTypedArrayElementCount++; + } + return v; +}); + +assertEq(arr[0], 0); +assertEq(arr[1], typedArray); + +assertEq(observedTypedArrayElementCount, 1); + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete"); diff --git a/js/src/tests/non262/extensions/reviver-mutates-holder-array.js b/js/src/tests/non262/extensions/reviver-mutates-holder-array.js new file mode 100644 index 0000000000..f4f89ac0ab --- /dev/null +++ b/js/src/tests/non262/extensions/reviver-mutates-holder-array.js @@ -0,0 +1,39 @@ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + * Contributor: + * Jeff Walden <jwalden+code@mit.edu> + */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 901351; +var summary = "Behavior when the JSON.parse reviver mutates the holder array"; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +var proxyObj = null; + +var arr = JSON.parse('[0, 1]', function(prop, v) { + if (prop === "0") + { + proxyObj = new Proxy({ c: 17, d: 42 }, {}); + this[1] = proxyObj; + } + return v; +}); + +assertEq(arr[0], 0); +assertEq(arr[1], proxyObj); +assertEq(arr[1].c, 17); +assertEq(arr[1].d, 42); + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete"); diff --git a/js/src/tests/non262/extensions/reviver-mutates-holder-object-ccw.js b/js/src/tests/non262/extensions/reviver-mutates-holder-object-ccw.js new file mode 100644 index 0000000000..546a57e916 --- /dev/null +++ b/js/src/tests/non262/extensions/reviver-mutates-holder-object-ccw.js @@ -0,0 +1,56 @@ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + * Contributor: + * Jeff Walden <jwalden+code@mit.edu> + */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 901351; +var summary = "Behavior when the JSON.parse reviver mutates the holder object"; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +// A little trickiness to account for the undefined-ness of property +// enumeration order. +var first = "unset"; + +var proxyObj = null; + +var obj = JSON.parse('{ "a": 0, "b": 1 }', function(prop, v) { + if (first === "unset") + { + first = prop; + var second = (prop === "a") ? "b" : "a"; + + proxyObj = newGlobal().evaluate("({ c: 42, d: 17 })"); + Object.defineProperty(this, second, { value: proxyObj }); + } + return v; +}); + +if (first === "a") +{ + assertEq(obj.a, 0); + assertEq(obj.b, proxyObj); + assertEq(obj.b.c, 42); + assertEq(obj.b.d, 17); +} +else +{ + assertEq(obj.a, proxyObj); + assertEq(obj.a.c, 42); + assertEq(obj.a.d, 17); + assertEq(obj.b, 1); +} + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete"); diff --git a/js/src/tests/non262/extensions/reviver-mutates-holder-object-nonnative.js b/js/src/tests/non262/extensions/reviver-mutates-holder-object-nonnative.js new file mode 100644 index 0000000000..1300f8dd0d --- /dev/null +++ b/js/src/tests/non262/extensions/reviver-mutates-holder-object-nonnative.js @@ -0,0 +1,60 @@ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + * Contributor: + * Jeff Walden <jwalden+code@mit.edu> + */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 901380; +var summary = "Behavior when JSON.parse walks over a non-native object"; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +// A little trickiness to account for the undefined-ness of property +// enumeration order. +var first = "unset"; + +var observedTypedArrayElementCount = 0; + +var typedArray = null; + +var obj = JSON.parse('{ "a": 0, "b": 1 }', function(prop, v) { + if (first === "unset") + { + first = prop; + var second = (prop === "a") ? "b" : "a"; + typedArray = new Int8Array(1); + Object.defineProperty(this, second, { value: typedArray }); + } + if (this instanceof Int8Array) + { + assertEq(prop, "0"); + observedTypedArrayElementCount++; + } + return v; +}); + +if (first === "a") +{ + assertEq(obj.a, 0); + assertEq(obj.b, typedArray); +} +else +{ + assertEq(obj.a, typedArray); + assertEq(obj.b, 1); +} + +assertEq(observedTypedArrayElementCount, 1); + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete"); diff --git a/js/src/tests/non262/extensions/reviver-mutates-holder-object.js b/js/src/tests/non262/extensions/reviver-mutates-holder-object.js new file mode 100644 index 0000000000..973766e9ae --- /dev/null +++ b/js/src/tests/non262/extensions/reviver-mutates-holder-object.js @@ -0,0 +1,56 @@ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + * Contributor: + * Jeff Walden <jwalden+code@mit.edu> + */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 901351; +var summary = "Behavior when the JSON.parse reviver mutates the holder object"; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +// A little trickiness to account for the undefined-ness of property +// enumeration order. +var first = "unset"; + +var proxyObj = null; + +var obj = JSON.parse('{ "a": 0, "b": 1 }', function(prop, v) { + if (first === "unset") + { + first = prop; + var second = (prop === "a") ? "b" : "a"; + + proxyObj = new Proxy({ c: 42, d: 17 }, {}); + Object.defineProperty(this, second, { value: proxyObj }); + } + return v; +}); + +if (first === "a") +{ + assertEq(obj.a, 0); + assertEq(obj.b, proxyObj); + assertEq(obj.b.c, 42); + assertEq(obj.b.d, 17); +} +else +{ + assertEq(obj.a, proxyObj); + assertEq(obj.a.c, 42); + assertEq(obj.a.d, 17); + assertEq(obj.b, 1); +} + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete"); diff --git a/js/src/tests/non262/extensions/scope-001.js b/js/src/tests/non262/extensions/scope-001.js new file mode 100644 index 0000000000..f3157af01c --- /dev/null +++ b/js/src/tests/non262/extensions/scope-001.js @@ -0,0 +1,84 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = '53268'; +var status = 'Testing scope after changing obj.__proto__'; +var expect= ''; +var actual = ''; +var obj = {}; + +Object.defineProperty(this, "five", { + value: 5, + enumerable: true, + writable: false +}); + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (status); + + + status= 'Step 1: setting obj.__proto__ = global object'; + obj.__proto__ = this; + + actual = obj.five; + expect=5; + reportCompare (expect, actual, status); + + obj.five=1; + actual = obj.five; + expect=5; + reportCompare (expect, actual, status); + + + + status= 'Step 2: setting obj.__proto__ = null'; + obj.__proto__ = null; + + actual = obj.five; + expect=undefined; + reportCompare (expect, actual, status); + + obj.five=2; + actual = obj.five; + expect=2; + reportCompare (expect, actual, status); + + + + status= 'Step 3: setting obj.__proto__ to global object again'; + obj.__proto__ = this; + + actual = obj.five; + expect=2; //<--- (FROM STEP 2 ABOVE) + reportCompare (expect, actual, status); + + obj.five=3; + actual = obj.five; + expect=3; + reportCompare (expect, actual, status); + + + + status= 'Step 4: setting obj.__proto__ to null again'; + obj.__proto__ = null; + + actual = obj.five; + expect=3; //<--- (FROM STEP 3 ABOVE) + reportCompare (expect, actual, status); + + obj.five=4; + actual = obj.five; + expect=4; + reportCompare (expect, actual, status); +} diff --git a/js/src/tests/non262/extensions/set-property-non-extensible.js b/js/src/tests/non262/extensions/set-property-non-extensible.js new file mode 100644 index 0000000000..096278d726 --- /dev/null +++ b/js/src/tests/non262/extensions/set-property-non-extensible.js @@ -0,0 +1,30 @@ +// |reftest| skip-if(!xulRuntime.shell) -- preventExtensions on global +// 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/non262/extensions/setImmutablePrototype.js b/js/src/tests/non262/extensions/setImmutablePrototype.js new file mode 100644 index 0000000000..9d107472e5 --- /dev/null +++ b/js/src/tests/non262/extensions/setImmutablePrototype.js @@ -0,0 +1,196 @@ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +var gTestfile = "setImmutablePrototype.js"; +//----------------------------------------------------------------------------- +var BUGNUMBER = 1052139; +var summary = + "Implement JSAPI and a shell function to prevent modifying an extensible " + + "object's [[Prototype]]"; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +if (typeof evaluate !== "function") +{ + // Not totally faithful semantics, but approximately close enough for this + // test's purposes. + evaluate = eval; +} + +var usingRealSetImmutablePrototype = true; + +if (typeof setImmutablePrototype !== "function") +{ + usingRealSetImmutablePrototype = false; + + if (typeof SpecialPowers !== "undefined") + { + setImmutablePrototype = + SpecialPowers.Cu.getJSTestingFunctions().setImmutablePrototype; + } +} + +if (typeof wrap !== "function") +{ + // good enough + wrap = function(x) { return x; }; +} + +function setViaProtoSetter(obj, newProto) +{ + var setter = + Object.getOwnPropertyDescriptor(Object.prototype, "__proto__").set; + setter.call(obj, newProto); +} + +function checkPrototypeMutationFailure(obj, desc) +{ + var initialProto = Object.getPrototypeOf(obj); + + // disconnected from any [[Prototype]] chains for use on any object at all + var newProto = Object.create(null); + + function tryMutate(func, method) + { + try + { + func(obj, newProto); + throw new Error(desc + ": no error thrown, prototype " + + (Object.getPrototypeOf(obj) === initialProto + ? "wasn't" + : "was") + + " changed"); + } + catch (e) + { + // Note: This is always a TypeError from *this* global object, because + // Object.setPrototypeOf and the __proto__ setter come from *this* + // global object. + assertEq(e instanceof TypeError, true, + desc + ": should have thrown TypeError setting [[Prototype]] " + + "via " + method + ", got " + e); + assertEq(Object.getPrototypeOf(obj), initialProto, + desc + ": shouldn't observe [[Prototype]] change"); + } + } + + tryMutate(Object.setPrototypeOf, "Object.setPrototypeOf"); + tryMutate(setViaProtoSetter, "__proto__ setter"); +} + +function runNormalTests(global) +{ + if (typeof setImmutablePrototype !== "function") + { + print("no testable setImmutablePrototype function available, skipping tests"); + return; + } + + // regular old object, non-null [[Prototype]] + + var emptyLiteral = global.evaluate("({})"); + assertEq(setImmutablePrototype(emptyLiteral), true); + checkPrototypeMutationFailure(emptyLiteral, "empty literal"); + + // regular old object, null [[Prototype]] + + var nullProto = global.Object.create(null); + assertEq(setImmutablePrototype(nullProto), true); + checkPrototypeMutationFailure(nullProto, "nullProto"); + + // Shocker: SpecialPowers's little mind doesn't understand proxies. Abort. + if (!usingRealSetImmutablePrototype) + return; + + // direct proxies + + var emptyTarget = global.evaluate("({})"); + var directProxy = new global.Proxy(emptyTarget, {}); + assertEq(setImmutablePrototype(directProxy), true); + checkPrototypeMutationFailure(directProxy, "direct proxy to empty target"); + checkPrototypeMutationFailure(emptyTarget, "empty target"); + + var anotherTarget = global.evaluate("({})"); + var anotherDirectProxy = new global.Proxy(anotherTarget, {}); + assertEq(setImmutablePrototype(anotherTarget), true); + checkPrototypeMutationFailure(anotherDirectProxy, "another direct proxy to empty target"); + checkPrototypeMutationFailure(anotherTarget, "another empty target"); + + var nestedTarget = global.evaluate("({})"); + var nestedProxy = new global.Proxy(new Proxy(nestedTarget, {}), {}); + assertEq(setImmutablePrototype(nestedProxy), true); + checkPrototypeMutationFailure(nestedProxy, "nested proxy to empty target"); + checkPrototypeMutationFailure(nestedTarget, "nested target"); + + // revocable proxies + + var revocableTarget = global.evaluate("({})"); + var revocable = global.Proxy.revocable(revocableTarget, {}); + assertEq(setImmutablePrototype(revocable.proxy), true); + checkPrototypeMutationFailure(revocableTarget, "revocable target"); + checkPrototypeMutationFailure(revocable.proxy, "revocable proxy"); + + assertEq(revocable.revoke(), undefined); + try + { + setImmutablePrototype(revocable.proxy); + throw new Error("expected to throw on revoked proxy"); + } + catch (e) + { + // Note: In the cross-compartment case, this is a TypeError from |global|, + // because the proxy's |setImmutablePrototype| method is what actually + // throws here. That's why we check for TypeError from either global. + // (Usually the method simply sets |*succeeded| to false and the + // caller handles or throws as needed after that. But not here.) + assertEq(e instanceof global.TypeError || e instanceof TypeError, true, + "expected TypeError, instead threw " + e); + } + + var anotherRevocableTarget = global.evaluate("({})"); + assertEq(setImmutablePrototype(anotherRevocableTarget), true); + checkPrototypeMutationFailure(anotherRevocableTarget, "another revocable target"); + + var anotherRevocable = global.Proxy.revocable(anotherRevocableTarget, {}); + checkPrototypeMutationFailure(anotherRevocable.proxy, "another revocable target"); + + assertEq(anotherRevocable.revoke(), undefined); + try + { + var rv = setImmutablePrototype(anotherRevocable.proxy); + throw new Error("expected to throw on another revoked proxy, returned " + rv); + } + catch (e) + { + // NOTE: Again from |global| or |this|, as above. + assertEq(e instanceof global.TypeError || e instanceof TypeError, true, + "expected TypeError, instead threw " + e); + } +} + +var global = this; +runNormalTests(global); // same-global + +if (typeof newGlobal === "function") +{ + var otherGlobal = newGlobal(); + var subsumingNothing = newGlobal({ principal: 0 }); + var subsumingEverything = newGlobal({ principal: ~0 }); + + runNormalTests(otherGlobal); // cross-global + runNormalTests(subsumingNothing); + runNormalTests(subsumingEverything); +} + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete"); diff --git a/js/src/tests/non262/extensions/shareddataview.js b/js/src/tests/non262/extensions/shareddataview.js new file mode 100644 index 0000000000..30ec8ef68e --- /dev/null +++ b/js/src/tests/non262/extensions/shareddataview.js @@ -0,0 +1,43 @@ +// |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/ + */ + +// Test DataView on SharedArrayBuffer. + +if (this.SharedArrayBuffer) { + +var sab = new SharedArrayBuffer(4096); +var dv = new DataView(sab); + +assertEq(sab, dv.buffer); +assertEq(dv.byteLength, sab.byteLength); +assertEq(ArrayBuffer.isView(dv), true); + +var dv2 = new DataView(sab, 1075, 2048); + +assertEq(sab, dv2.buffer); +assertEq(dv2.byteLength, 2048); +assertEq(dv2.byteOffset, 1075); +assertEq(ArrayBuffer.isView(dv2), true); + +// Test that it is the same buffer memory for the two views + +dv.setInt8(1075, 37); +assertEq(dv2.getInt8(0), 37); + +// Test that range checking works + +assertThrowsInstanceOf(() => dv.setInt32(4098, -1), RangeError); +assertThrowsInstanceOf(() => dv.setInt32(4094, -1), RangeError); +assertThrowsInstanceOf(() => dv.setInt32(-1, -1), RangeError); + +assertThrowsInstanceOf(() => dv2.setInt32(2080, -1), RangeError); +assertThrowsInstanceOf(() => dv2.setInt32(2046, -1), RangeError); +assertThrowsInstanceOf(() => dv2.setInt32(-1, -1), RangeError); + +} + +reportCompare(true,true); diff --git a/js/src/tests/non262/extensions/sharedtypedarray.js b/js/src/tests/non262/extensions/sharedtypedarray.js new file mode 100644 index 0000000000..56187d29f5 --- /dev/null +++ b/js/src/tests/non262/extensions/sharedtypedarray.js @@ -0,0 +1,273 @@ +// |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. + +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, [], {SharedArrayBuffer: 'allow'}); + var sab2 = deserialize(blob, {SharedArrayBuffer: 'allow'}); + if (typeof sharedAddress != "undefined") + assertEq(sharedAddress(sab1), sharedAddress(sab2)); +} + +function testClone2() { + var sab = b; + var ia1 = new Int32Array(sab); + var blob = serialize(ia1, [], {SharedArrayBuffer: 'allow'}); + var ia2 = deserialize(blob, {SharedArrayBuffer: 'allow'}); + 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 or if the flag is not set to 'allow' explicitly + +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); + + // This tests that cloning a SharedArrayBuffer is not allowed by default + assertThrowsInstanceOf(() => serialize(b), TypeError); + + // Ditto - should succeed + assertEq(typeof serialize(b, [], {SharedArrayBuffer: 'allow'}), "object"); + + let blob = serialize(b, [], {SharedArrayBuffer: 'allow'}); + // This just tests the API in deserialize() + assertThrowsInstanceOf(() => deserialize(blob, {SharedArrayBuffer: false}), Error); + + // This tests the actual cloning functionality - should fail + assertThrowsInstanceOf(() => deserialize(blob, {SharedArrayBuffer: 'deny'}), TypeError); + + // This tests that cloning a SharedArrayBuffer is not allowed by default + assertThrowsInstanceOf(() => deserialize(blob), TypeError); + + // Ditto - should succeed + assertEq(typeof deserialize(blob, {SharedArrayBuffer: 'allow'}), "object"); +} + +function testRedundantTransfer() { + // Throws TypeError in the shell, DataCloneError in the browser. + assertThrowsInstanceOf(() => { + var sab1 = b; + var blob = serialize(sab1, [sab1], {SharedArrayBuffer: 'allow'}); + }, TypeError); +} + +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); +} + +if (this.SharedArrayBuffer) { + testSharedArrayBuffer(); + testSharedTypedArray(); + testSharedTypedArrayMethods(); + testClone1(); + testClone2(); + testNoClone(); + testRedundantTransfer(); + testApplicable(); +} + +reportCompare(0, 0, 'ok'); diff --git a/js/src/tests/non262/extensions/shell.js b/js/src/tests/non262/extensions/shell.js new file mode 100644 index 0000000000..e7381a0b93 --- /dev/null +++ b/js/src/tests/non262/extensions/shell.js @@ -0,0 +1,345 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +(function(global) { + /* + * Date: 07 February 2001 + * + * Functionality common to RegExp testing - + */ + //----------------------------------------------------------------------------- + + var MSG_PATTERN = '\nregexp = '; + var MSG_STRING = '\nstring = '; + var MSG_EXPECT = '\nExpect: '; + var MSG_ACTUAL = '\nActual: '; + var ERR_LENGTH = '\nERROR !!! match arrays have different lengths:'; + var ERR_MATCH = '\nERROR !!! regexp failed to give expected match array:'; + var ERR_NO_MATCH = '\nERROR !!! regexp FAILED to match anything !!!'; + var ERR_UNEXP_MATCH = '\nERROR !!! regexp MATCHED when we expected it to fail !!!'; + var CHAR_LBRACKET = '['; + var CHAR_RBRACKET = ']'; + var CHAR_QT_DBL = '"'; + var CHAR_QT = "'"; + var CHAR_NL = '\n'; + var CHAR_COMMA = ','; + var CHAR_SPACE = ' '; + var TYPE_STRING = typeof 'abc'; + + + + function testRegExp(statuses, patterns, strings, actualmatches, expectedmatches) + { + var status = ''; + var pattern = new RegExp(); + var string = ''; + var actualmatch = new Array(); + var expectedmatch = new Array(); + var state = ''; + var lActual = -1; + var lExpect = -1; + + + for (var i=0; i != patterns.length; i++) + { + status = statuses[i]; + pattern = patterns[i]; + string = strings[i]; + actualmatch=actualmatches[i]; + expectedmatch=expectedmatches[i]; + state = getState(status, pattern, string); + + description = status; + + if(actualmatch) + { + actual = formatArray(actualmatch); + if(expectedmatch) + { + // expectedmatch and actualmatch are arrays - + lExpect = expectedmatch.length; + lActual = actualmatch.length; + + var expected = formatArray(expectedmatch); + + if (lActual != lExpect) + { + reportCompare(lExpect, lActual, + state + ERR_LENGTH + + MSG_EXPECT + expected + + MSG_ACTUAL + actual + + CHAR_NL + ); + continue; + } + + // OK, the arrays have same length - + if (expected != actual) + { + reportCompare(expected, actual, + state + ERR_MATCH + + MSG_EXPECT + expected + + MSG_ACTUAL + actual + + CHAR_NL + ); + } + else + { + reportCompare(expected, actual, state) + } + + } + else //expectedmatch is null - that is, we did not expect a match - + { + expected = expectedmatch; + reportCompare(expected, actual, + state + ERR_UNEXP_MATCH + + MSG_EXPECT + expectedmatch + + MSG_ACTUAL + actual + + CHAR_NL + ); + } + + } + else // actualmatch is null + { + if (expectedmatch) + { + actual = actualmatch; + reportCompare(expected, actual, + state + ERR_NO_MATCH + + MSG_EXPECT + expectedmatch + + MSG_ACTUAL + actualmatch + + CHAR_NL + ); + } + else // we did not expect a match + { + // Being ultra-cautious. Presumably expectedmatch===actualmatch===null + expected = expectedmatch; + actual = actualmatch; + reportCompare (expectedmatch, actualmatch, state); + } + } + } + } + + global.testRegExp = testRegExp; + + function getState(status, pattern, string) + { + /* + * Escape \n's, etc. to make them LITERAL in the presentation string. + * We don't have to worry about this in |pattern|; such escaping is + * done automatically by pattern.toString(), invoked implicitly below. + * + * One would like to simply do: string = string.replace(/(\s)/g, '\$1'). + * However, the backreference $1 is not a literal string value, + * so this method doesn't work. + * + * Also tried string = string.replace(/(\s)/g, escape('$1')); + * but this just inserts the escape of the literal '$1', i.e. '%241'. + */ + string = string.replace(/\n/g, '\\n'); + string = string.replace(/\r/g, '\\r'); + string = string.replace(/\t/g, '\\t'); + string = string.replace(/\v/g, '\\v'); + string = string.replace(/\f/g, '\\f'); + + return (status + MSG_PATTERN + pattern + MSG_STRING + singleQuote(string)); + } + + + /* + * If available, arr.toSource() gives more detail than arr.toString() + * + * var arr = Array(1,2,'3'); + * + * arr.toSource() + * [1, 2, "3"] + * + * arr.toString() + * 1,2,3 + * + * But toSource() doesn't exist in Rhino, so use our own imitation, below - + * + */ + function formatArray(arr) + { + try + { + return arr.toSource(); + } + catch(e) + { + return toSource(arr); + } + } + + + /* + * Imitate SpiderMonkey's arr.toSource() method: + * + * a) Double-quote each array element that is of string type + * b) Represent |undefined| and |null| by empty strings + * c) Delimit elements by a comma + single space + * d) Do not add delimiter at the end UNLESS the last element is |undefined| + * e) Add square brackets to the beginning and end of the string + */ + function toSource(arr) + { + var delim = CHAR_COMMA + CHAR_SPACE; + var elt = ''; + var ret = ''; + var len = arr.length; + + for (i=0; i<len; i++) + { + elt = arr[i]; + + switch(true) + { + case (typeof elt === TYPE_STRING) : + ret += doubleQuote(elt); + break; + + case (elt === undefined || elt === null) : + break; // add nothing but the delimiter, below - + + default: + ret += elt.toString(); + } + + if ((i < len-1) || (elt === undefined)) + ret += delim; + } + + return CHAR_LBRACKET + ret + CHAR_RBRACKET; + } + + + function doubleQuote(text) + { + return CHAR_QT_DBL + text + CHAR_QT_DBL; + } + + + function singleQuote(text) + { + return CHAR_QT + text + CHAR_QT; + } + +})(this); + + +(function(global) { + + // 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 = ''; + + // 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 isArrayLength(obj, pair) { + return Array.isArray(obj) && pair[0] == "length"; + } + + function isCloneable(obj, pair) { + return isArrayLength(obj, pair) || (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 (except .length, if it's an Array). + // '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(function(element) { + return isCloneable(b, element); + }); + 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 (!isCloneable(a, pa[i])) { + throw new Error("non-cloneable clone property " + 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]; + if (!isArrayLength(a, pa[i])) { + 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 || JSON.stringify(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 + } + global.clone_object_check = clone_object_check; + +})(this); diff --git a/js/src/tests/non262/extensions/sps-generators.js b/js/src/tests/non262/extensions/sps-generators.js new file mode 100644 index 0000000000..e165649446 --- /dev/null +++ b/js/src/tests/non262/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 Gecko Profiler state"; + +print(BUGNUMBER + ": " + summary); + +function* gen() { + var x = yield turnoff(); + yield x; + yield 'bye'; +} + +function turnoff() { + print("Turning off profiler\n"); + disableGeckoProfiling(); + return 'hi'; +} + +for (var slowAsserts of [ true, false ]) { + // The slowAssertions setting is not expected to matter + if (slowAsserts) + enableGeckoProfilingWithSlowAssertions(); + else + enableGeckoProfiling(); + + g = gen(); + assertEq(g.next().value, 'hi'); + assertEq(g.next('gurgitating...').value, 'gurgitating...'); + for (var x of g) + assertEq(x, 'bye'); +} + +// This is really a crashtest +reportCompare(0, 0, 'ok'); diff --git a/js/src/tests/non262/extensions/string-literal-getter-setter-decompilation.js b/js/src/tests/non262/extensions/string-literal-getter-setter-decompilation.js new file mode 100644 index 0000000000..a0a5714053 --- /dev/null +++ b/js/src/tests/non262/extensions/string-literal-getter-setter-decompilation.js @@ -0,0 +1,34 @@ +// Any copyright is dedicated to the Public Domain. +// http://creativecommons.org/licenses/publicdomain/ + +var f; +try +{ + f = eval("(function literalInside() { return { set 'c d e'(v) { } }; })"); +} +catch (e) +{ + assertEq(true, false, + "string-literal property name in setter in object literal in " + + "function statement failed to parse: " + e); +} + +var fstr = "" + f; +assertEq(fstr.indexOf("set") < fstr.indexOf("c d e"), true, + "should be using new-style syntax with string literal in place of " + + "property identifier"); +assertEq(fstr.indexOf("setter") < 0, true, "using old-style syntax?"); + +var o = f(); +var ostr = "" + o; +assertEq("c d e" in o, true, "missing the property?"); +assertEq("set" in Object.getOwnPropertyDescriptor(o, "c d e"), true, + "'c d e' property not a setter?"); +// disabled because we still generate old-style syntax here (toSource +// decompilation is as yet unfixed) +// assertEq(ostr.indexOf("set") < ostr.indexOf("c d e"), true, +// "should be using new-style syntax when getting the source of a " + +// "getter/setter while decompiling an object"); +// assertEq(ostr.indexOf("setter") < 0, true, "using old-style syntax?"); + +reportCompare(true, true); diff --git a/js/src/tests/non262/extensions/toLength.js b/js/src/tests/non262/extensions/toLength.js new file mode 100644 index 0000000000..f2216e7b9c --- /dev/null +++ b/js/src/tests/non262/extensions/toLength.js @@ -0,0 +1,41 @@ +// |reftest| skip-if(!xulRuntime.shell) +var BUGNUMBER = 1040196; +var summary = 'ToLength'; + +print(BUGNUMBER + ": " + summary); + +var ToLength = getSelfHostedValue('ToLength'); + +// Negative operands +assertEq(ToLength(-0), 0); +assertEq(ToLength(-1), 0); +assertEq(ToLength(-2), 0); +assertEq(ToLength(-1 * Math.pow(2, 56)), 0); +assertEq(ToLength(-1 * Math.pow(2, 56) - 2), 0); +assertEq(ToLength(-1 * Math.pow(2, 56) - 2.4444), 0); +assertEq(ToLength(-Infinity), 0); + +// Small non-negative operands +assertEq(ToLength(0), 0); +assertEq(ToLength(1), 1); +assertEq(ToLength(2), 2); +assertEq(ToLength(3.3), 3); +assertEq(ToLength(10/3), 3); + +// Large non-negative operands +var maxLength = Math.pow(2, 53) - 1; +assertEq(ToLength(maxLength - 1), maxLength - 1); +assertEq(ToLength(maxLength - 0.0000001), maxLength); +assertEq(ToLength(maxLength), maxLength); +assertEq(ToLength(maxLength + 0.00000000000001), maxLength); +assertEq(ToLength(maxLength + 1), maxLength); +assertEq(ToLength(maxLength + 2), maxLength); +assertEq(ToLength(Math.pow(2,54)), maxLength); +assertEq(ToLength(Math.pow(2,64)), maxLength); +assertEq(ToLength(Infinity), maxLength); + +// NaN operand +assertEq(ToLength(NaN), 0); + + +reportCompare(0, 0, "ok"); diff --git a/js/src/tests/non262/extensions/toLocaleString-infinite-recursion.js b/js/src/tests/non262/extensions/toLocaleString-infinite-recursion.js new file mode 100644 index 0000000000..a11433ce46 --- /dev/null +++ b/js/src/tests/non262/extensions/toLocaleString-infinite-recursion.js @@ -0,0 +1,31 @@ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 653789; +var summary = 'Check for too-deep stack when calling toLocaleString'; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +try +{ + "" + { toString: Object.prototype.toLocaleString }; + throw new Error("should have thrown on over-recursion"); +} +catch (e) +{ + assertEq(e instanceof InternalError, true); +} + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("All tests passed!"); diff --git a/js/src/tests/non262/extensions/toSource-infinite-recursion.js b/js/src/tests/non262/extensions/toSource-infinite-recursion.js new file mode 100644 index 0000000000..7c5600fc82 --- /dev/null +++ b/js/src/tests/non262/extensions/toSource-infinite-recursion.js @@ -0,0 +1,36 @@ +// |reftest| skip-if(!Error.prototype.toSource) + +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 650574; +var summary = 'Check for too-deep stack when converting a value to source'; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +try +{ + var e = Error(''); + e.fileName = e; + e.toSource(); + throw new Error("should have thrown"); +} +catch (e) +{ + assertEq(e instanceof InternalError, true, + "should have thrown for over-recursion"); +} + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("All tests passed!"); diff --git a/js/src/tests/non262/extensions/too-many-arguments-constructing-bound-function.js b/js/src/tests/non262/extensions/too-many-arguments-constructing-bound-function.js new file mode 100644 index 0000000000..e108e4c0b2 --- /dev/null +++ b/js/src/tests/non262/extensions/too-many-arguments-constructing-bound-function.js @@ -0,0 +1,54 @@ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +var gTestfile = "too-many-arguments-constructing-bound-function.js"; +//----------------------------------------------------------------------------- +var BUGNUMBER = 1303678; +var summary = + "Don't assert trying to construct a bound function whose bound-target " + + "construct operation passes more than ARGS_LENGTH_MAX arguments"; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +const ARGS_LENGTH_MAX = typeof getMaxArgs === "function" + ? getMaxArgs() + : 500000; + +const halfRoundedDown = Math.floor(ARGS_LENGTH_MAX / 2); +const halfRoundedUp = Math.ceil(ARGS_LENGTH_MAX / 2); + +function boundTarget() +{ + return new Number(arguments.length); +} + +var boundArgs = Array(halfRoundedDown).fill(0); +var boundFunction = boundTarget.bind(null, ...boundArgs); + +var additionalArgs = Array(halfRoundedUp + 1).fill(0); + +try +{ + assertEq(new (boundFunction)(...additionalArgs).valueOf(), + ARGS_LENGTH_MAX + 1); + // If we reach here, that's fine -- it's okay if ARGS_LENGTH_MAX isn't + // precisely respected, because there's no specified exact limit. +} +catch (e) +{ + assertEq(e instanceof RangeError, true, + "SpiderMonkey throws RangeError for too many args"); +} + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete"); diff --git a/js/src/tests/non262/extensions/typedarray-copyWithin-arguments-detaching.js b/js/src/tests/non262/extensions/typedarray-copyWithin-arguments-detaching.js new file mode 100644 index 0000000000..34b0ab5558 --- /dev/null +++ b/js/src/tests/non262/extensions/typedarray-copyWithin-arguments-detaching.js @@ -0,0 +1,111 @@ +/* + * 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/non262/extensions/typedarray-set-neutering.js b/js/src/tests/non262/extensions/typedarray-set-neutering.js new file mode 100644 index 0000000000..23df8158c5 --- /dev/null +++ b/js/src/tests/non262/extensions/typedarray-set-neutering.js @@ -0,0 +1,45 @@ +// 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); + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete"); diff --git a/js/src/tests/non262/extensions/typedarray-subarray-of-subarray.js b/js/src/tests/non262/extensions/typedarray-subarray-of-subarray.js new file mode 100644 index 0000000000..fcfb031cb5 --- /dev/null +++ b/js/src/tests/non262/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/non262/extensions/typedarray.js b/js/src/tests/non262/extensions/typedarray.js new file mode 100644 index 0000000000..02aaf7956e --- /dev/null +++ b/js/src/tests/non262/extensions/typedarray.js @@ -0,0 +1,657 @@ +// |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 = ''; + +//----------------------------------------------------------------------------- +if (typeof gczeal !== 'undefined') + gczeal(0) + +if (typeof numberToDouble !== 'function') { + var numberToDouble = SpecialPowers.Cu.getJSTestingFunctions().numberToDouble; +} + +test(); +//----------------------------------------------------------------------------- + +function 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)); + } + } + + if (typeof setMarkStackLimit === 'function') { + setMarkStackLimit(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)); + + check(() => new Float32Array(null).length === 0); + + 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; numberToDouble(2) is used to ensure that the + // function gets a double, and not a demoted int + check(() => (new Float32Array(numberToDouble(2))).length == 2); + check(() => (new Float32Array({ length: 10 })).length == 10); + check(() => (new Float32Array({})).length == 0); + check(() => new Float32Array("3").length === 3); + check(() => new Float32Array(null).length === 0); + check(() => new Float32Array(undefined).length === 0); + + // 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({newCompartment: true}); + + 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 in the cross-compartment + // case. + if (isProxy(alien)) { + check(() => isProxy(alien_view)); + check(() => isProxy(alien_buffer)); + check(() => isProxy(view)); // the real test + } + + // cross-realm 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"); +} diff --git a/js/src/tests/non262/extensions/uneval/bug496985.js b/js/src/tests/non262/extensions/uneval/bug496985.js new file mode 100644 index 0000000000..0f68288cc5 --- /dev/null +++ b/js/src/tests/non262/extensions/uneval/bug496985.js @@ -0,0 +1,14 @@ +// |reftest| skip-if(!this.uneval) + +var a = function() { + return function ({x: arguments}) { + return arguments; + } +} +var b = eval(uneval(a)); + +assertEq(a()({x: 1}), 1); +assertEq(b()({x: 1}), 1); + +if (typeof reportCompare === "function") + reportCompare(true, true); diff --git a/js/src/tests/non262/extensions/uneval/bug566661.js b/js/src/tests/non262/extensions/uneval/bug566661.js new file mode 100644 index 0000000000..51e142351e --- /dev/null +++ b/js/src/tests/non262/extensions/uneval/bug566661.js @@ -0,0 +1,8 @@ +// |reftest| skip-if(!this.uneval) + +var f = function (q) { return q['\xC7']; } +var d = eval(uneval(f)); +assertEq(d({'\xC7': 'good'}), 'good'); + +if (typeof reportCompare === "function") + reportCompare(true, true); diff --git a/js/src/tests/non262/extensions/uneval/function-bind.js b/js/src/tests/non262/extensions/uneval/function-bind.js new file mode 100644 index 0000000000..263099cf07 --- /dev/null +++ b/js/src/tests/non262/extensions/uneval/function-bind.js @@ -0,0 +1,32 @@ +// |reftest| skip-if(!this.uneval) + +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +var gTestfile = 'function-bind.js'; +var BUGNUMBER = 429507; +var summary = "ES5: Function.prototype.bind"; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +assertEq((function unbound(){"body"}).bind().toSource(), `function bound() { + [native code] +}`); + +assertEq(uneval((function unbound(){"body"}).bind()), `function bound() { + [native code] +}`); + + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("All tests passed!"); diff --git a/js/src/tests/non262/extensions/uneval/regress-231518.js b/js/src/tests/non262/extensions/uneval/regress-231518.js new file mode 100644 index 0000000000..fc360f0870 --- /dev/null +++ b/js/src/tests/non262/extensions/uneval/regress-231518.js @@ -0,0 +1,99 @@ +// |reftest| skip-if(!this.uneval) + +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 231518; +var summary = 'decompiler must quote keywords and non-identifier property names'; +var actual = ''; +var expect = 'no error'; +var status; +var object; +var result; + +printBugNumber(BUGNUMBER); +printStatus (summary); + + status = inSection(1) + ' eval(uneval({"if": false}))'; + + try + { + object = {'if': false }; + result = uneval(object); + printStatus('uneval returns ' + result); + eval(result); + actual = 'no error'; + } + catch(e) + { + actual = 'error'; + } + + reportCompare(expect, actual, status); + + status = inSection(2) + ' eval(uneval({"if": "then"}))'; + + try + { + object = {'if': "then" }; + result = uneval(object); + printStatus('uneval returns ' + result); + eval(result); + actual = 'no error'; + } + catch(e) + { + actual = 'error'; + } + + reportCompare(expect, actual, status); + + status = inSection(3) + ' eval(uneval(f))'; + + try + { + result = uneval(f); + printStatus('uneval returns ' + result); + eval(result); + actual = 'no error'; + } + catch(e) + { + actual = 'error'; + } + + reportCompare(expect, actual, status); + + status = inSection(2) + ' eval(uneval(g))'; + + try + { + result = uneval(g); + printStatus('uneval returns ' + result); + eval(result); + actual = 'no error'; + } + catch(e) + { + actual = 'error'; + } + + reportCompare(expect, actual, status); + +function f() +{ + var obj = new Object(); + + obj['name'] = 'Just a name'; + obj['if'] = false; + obj['some text'] = 'correct'; +} + +function g() +{ + return {'if': "then"}; +} + diff --git a/js/src/tests/non262/extensions/uneval/regress-245795.js b/js/src/tests/non262/extensions/uneval/regress-245795.js new file mode 100644 index 0000000000..bb5a736039 --- /dev/null +++ b/js/src/tests/non262/extensions/uneval/regress-245795.js @@ -0,0 +1,33 @@ +// |reftest| skip-if(!this.uneval) + +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 245795; +var summary = 'eval(uneval(function)) should be round-trippable'; +var actual = ''; +var expect = ''; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +function a() +{ + b = function() {}; +} + +var r = "function a() { b = function() {}; }"; +eval(uneval(a)); + +var v = a.toString().replace(/[ \n]+/g, ' '); +print(v) + +printStatus("[" + v + "]"); + +expect = r; +actual = v; + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/non262/extensions/uneval/regress-254375.js b/js/src/tests/non262/extensions/uneval/regress-254375.js new file mode 100644 index 0000000000..4640d3e1c8 --- /dev/null +++ b/js/src/tests/non262/extensions/uneval/regress-254375.js @@ -0,0 +1,28 @@ +// |reftest| skip-if(!this.uneval) + +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 254375; +var summary = 'Object.toSource for negative number property names'; +var actual = ''; +var expect = ''; + +printBugNumber(BUGNUMBER); +printStatus (summary); + + try + { + expect = 'no error'; + eval(uneval({'-1':true})); + actual = 'no error'; + } + catch(e) + { + actual = 'error'; + } + + reportCompare(expect, actual, summary); diff --git a/js/src/tests/non262/extensions/uneval/regress-304897.js b/js/src/tests/non262/extensions/uneval/regress-304897.js new file mode 100644 index 0000000000..f88bff8445 --- /dev/null +++ b/js/src/tests/non262/extensions/uneval/regress-304897.js @@ -0,0 +1,22 @@ +// |reftest| skip-if(!this.uneval) + +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 304897; +var summary = 'uneval("\\t"), uneval("\\x09")'; +var actual = ''; +var expect = ''; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +expect = '"\\t"'; +actual = uneval('\t'); +reportCompare(expect, actual, summary); + +actual = uneval('\x09'); +reportCompare(expect, actual, summary); diff --git a/js/src/tests/non262/extensions/uneval/regress-306738.js b/js/src/tests/non262/extensions/uneval/regress-306738.js new file mode 100644 index 0000000000..71f8b5d014 --- /dev/null +++ b/js/src/tests/non262/extensions/uneval/regress-306738.js @@ -0,0 +1,30 @@ +// |reftest| skip-if(!this.uneval) + +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 306738; +var summary = 'uneval() on objects with getter or setter'; +var actual = ''; +var expect = ''; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +actual = uneval( + { + get foo() + { + return "foo"; + } + }); + +expect = '({get foo()\n\ + {\n\ + return "foo";\n\ + }})'; + +compareSource(expect, actual, summary); diff --git a/js/src/tests/non262/extensions/uneval/regress-311583.js b/js/src/tests/non262/extensions/uneval/regress-311583.js new file mode 100644 index 0000000000..9121b9f4e9 --- /dev/null +++ b/js/src/tests/non262/extensions/uneval/regress-311583.js @@ -0,0 +1,23 @@ +// |reftest| skip-if(!this.uneval) + +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 311583; +var summary = 'uneval(array) should use elision for holes'; +var actual = ''; +var expect = ''; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +var a = new Array(3); +a[0] = a[2] = 0; + +actual = uneval(a); +expect = '[0, , 0]'; + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/non262/extensions/uneval/regress-313803.js b/js/src/tests/non262/extensions/uneval/regress-313803.js new file mode 100644 index 0000000000..3f5c18456a --- /dev/null +++ b/js/src/tests/non262/extensions/uneval/regress-313803.js @@ -0,0 +1,29 @@ +// |reftest| skip-if(!this.uneval) + +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 313803; +var summary = 'uneval() on func with embedded objects with getter or setter'; +var actual = ''; +var expect = ''; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +var func = function ff() { + obj = { get foo() { return "foo"; }}; + return 1; +}; + +actual = uneval(func); + +expect = '(function ff() {\n\ + obj = { get foo() { return "foo"; }};\n\ + return 1;\n\ +})'; + +compareSource(expect, actual, summary); diff --git a/js/src/tests/non262/extensions/uneval/regress-322957.js b/js/src/tests/non262/extensions/uneval/regress-322957.js new file mode 100644 index 0000000000..e3b8157b52 --- /dev/null +++ b/js/src/tests/non262/extensions/uneval/regress-322957.js @@ -0,0 +1,29 @@ +// |reftest| skip-if(!this.uneval) + +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 322957; +var summary = 'TryMethod should not eat getter exceptions'; +var actual = ''; +var expect = ''; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +var obj = { get toSource() { throw "EXCEPTION"; } }; + +var got_proper_exception = -1; + +try { + uneval(obj); +} catch (e) { + got_proper_exception = (e === "EXCEPTION"); +} + +expect = true; +actual = got_proper_exception; +reportCompare(expect, actual, summary); diff --git a/js/src/tests/non262/extensions/uneval/regress-328556.js b/js/src/tests/non262/extensions/uneval/regress-328556.js new file mode 100644 index 0000000000..c757fad02d --- /dev/null +++ b/js/src/tests/non262/extensions/uneval/regress-328556.js @@ -0,0 +1,21 @@ +// |reftest| skip-if(!this.uneval) + +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 328556; +var summary = 'Do not Assert: growth == (size_t)-1 || (nchars + 1) * sizeof(char16_t) == growth, in jsarray.c'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +var D = []; +D.foo = D; +uneval(D); + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/non262/extensions/uneval/regress-358594-01.js b/js/src/tests/non262/extensions/uneval/regress-358594-01.js new file mode 100644 index 0000000000..e5b22a575c --- /dev/null +++ b/js/src/tests/non262/extensions/uneval/regress-358594-01.js @@ -0,0 +1,31 @@ +// |reftest| skip-if(!this.uneval) + +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +//----------------------------------------------------------------------------- +var BUGNUMBER = 358594; +var summary = 'Do not crash on uneval(this).'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + // don't crash|assert + function f() { } + f.__proto__ = this; + Object.defineProperty(this, "m", { set: f, enumerable: true, configurable: true }); + uneval(this); + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/uneval/regress-358594-02.js b/js/src/tests/non262/extensions/uneval/regress-358594-02.js new file mode 100644 index 0000000000..897d739579 --- /dev/null +++ b/js/src/tests/non262/extensions/uneval/regress-358594-02.js @@ -0,0 +1,23 @@ +// |reftest| skip-if(!this.uneval) + +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +//----------------------------------------------------------------------------- +var BUGNUMBER = 358594; +var summary = 'Do not crash on uneval(this).'; +var actual = ''; +var expect = ''; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +// don't crash|assert +function f() { } +f.__proto__ = this; +Object.defineProperty(this, "m", { set: f, enumerable: true, configurable: true }); +uneval(this); +reportCompare(expect, actual, summary); diff --git a/js/src/tests/non262/extensions/uneval/regress-358594-03.js b/js/src/tests/non262/extensions/uneval/regress-358594-03.js new file mode 100644 index 0000000000..55f4fb250d --- /dev/null +++ b/js/src/tests/non262/extensions/uneval/regress-358594-03.js @@ -0,0 +1,30 @@ +// |reftest| skip-if(!this.uneval) + +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +//----------------------------------------------------------------------------- +var BUGNUMBER = 358594; +var summary = 'Do not crash on uneval(this).'; +var actual = ''; +var expect = ''; + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + // don't crash|assert + f = function () { }; + f.__proto__ = this; + Object.defineProperty(this, "m", { set: f, enumerable: true, configurable: true }); + uneval(this); + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/uneval/regress-358594-04.js b/js/src/tests/non262/extensions/uneval/regress-358594-04.js new file mode 100644 index 0000000000..01d1fe3e03 --- /dev/null +++ b/js/src/tests/non262/extensions/uneval/regress-358594-04.js @@ -0,0 +1,23 @@ +// |reftest| skip-if(!this.uneval) + +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +//----------------------------------------------------------------------------- +var BUGNUMBER = 358594; +var summary = 'Do not crash on uneval(this).'; +var actual = ''; +var expect = ''; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +// don't crash|assert +f = function () { }; +f.__proto__ = this; +Object.defineProperty(this, "m", { set: f, enumerable: true, configurable: true }); +uneval(this); +reportCompare(expect, actual, summary); diff --git a/js/src/tests/non262/extensions/uneval/regress-358594-05.js b/js/src/tests/non262/extensions/uneval/regress-358594-05.js new file mode 100644 index 0000000000..aa2ae6e925 --- /dev/null +++ b/js/src/tests/non262/extensions/uneval/regress-358594-05.js @@ -0,0 +1,31 @@ +// |reftest| skip-if(!this.uneval) + +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +//----------------------------------------------------------------------------- +var BUGNUMBER = 358594; +var summary = 'Do not crash on uneval(this).'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + // don't crash|assert + f = function () { }; + f.hhhhhhhhh = this; + Object.defineProperty(this, "m", { set: f, enumerable: true, configurable: true }); + uneval(this); + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/uneval/regress-358594-06.js b/js/src/tests/non262/extensions/uneval/regress-358594-06.js new file mode 100644 index 0000000000..2a83057eda --- /dev/null +++ b/js/src/tests/non262/extensions/uneval/regress-358594-06.js @@ -0,0 +1,23 @@ +// |reftest| skip-if(!this.uneval) + +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +//----------------------------------------------------------------------------- +var BUGNUMBER = 358594; +var summary = 'Do not crash on uneval(this).'; +var actual = ''; +var expect = ''; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +// don't crash|assert +f = function () { }; +f.hhhhhhhhh = this; +Object.defineProperty(this, "m", { set: f, enumerable: true, configurable: true }); +uneval(this); +reportCompare(expect, actual, summary); diff --git a/js/src/tests/non262/extensions/uneval/regress-367629.js b/js/src/tests/non262/extensions/uneval/regress-367629.js new file mode 100644 index 0000000000..9d7a999a22 --- /dev/null +++ b/js/src/tests/non262/extensions/uneval/regress-367629.js @@ -0,0 +1,45 @@ +// |reftest| skip-if(!this.uneval) + +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +//----------------------------------------------------------------------------- +var BUGNUMBER = 367629; +var summary = 'Decompilation of result with native function as getter'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + var a = + Object.defineProperty({}, "h", + { + get: encodeURI, + enumerable: true, + configurable: true + }); + + expect = '({get h() {[native code]}})'; + actual = uneval(a); + + // Native function syntax: + // `function IdentifierName_opt ( FormalParameters ) { [ native code ] }` + + // The placement of whitespace characters in the native function's body is + // implementation-dependent, so we need to replace those for this test. + var re = new RegExp(["\\{", "\\[", "native", "code", "\\]", "\\}"].join("\\s*")); + actual = actual.replace(re, "{[native code]}"); + + compareSource(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/uneval/regress-375801.js b/js/src/tests/non262/extensions/uneval/regress-375801.js new file mode 100644 index 0000000000..6f345bf8fa --- /dev/null +++ b/js/src/tests/non262/extensions/uneval/regress-375801.js @@ -0,0 +1,35 @@ +// |reftest| skip-if(!this.uneval) + +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 375801; +var summary = 'uneval should use "(void 0)" instead of "undefined"'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = '({a:(void 0)})' + actual = uneval({a: undefined}) + compareSource(expect, actual, summary + ': uneval'); + + expect = 'function() {({a: undefined});}'; + actual = (function() {({a: undefined});}).toString(); + compareSource(expect, actual, summary + ': toString'); + + expect = '(function () {({a: undefined});})'; + actual = (function () {({a: undefined});}).toSource(); + compareSource(expect, actual, summary + ': toSource'); +} diff --git a/js/src/tests/non262/extensions/uneval/regress-380581.js b/js/src/tests/non262/extensions/uneval/regress-380581.js new file mode 100644 index 0000000000..5420b3fe17 --- /dev/null +++ b/js/src/tests/non262/extensions/uneval/regress-380581.js @@ -0,0 +1,28 @@ +// |reftest| skip-if(!this.uneval) + +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +//----------------------------------------------------------------------------- +var BUGNUMBER = 380581; +var summary = 'Incorrect uneval with setter in object literal'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = '(function() { })'; + actual = uneval(eval("(function() { })")); + compareSource(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/uneval/regress-380933.js b/js/src/tests/non262/extensions/uneval/regress-380933.js new file mode 100644 index 0000000000..8033f886e7 --- /dev/null +++ b/js/src/tests/non262/extensions/uneval/regress-380933.js @@ -0,0 +1,29 @@ +// |reftest| skip-if(!this.uneval) + +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +var BUGNUMBER = 380933; +var summary = 'Do not assert with uneval object with setter with modified proto'; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +var f = (function(){}); +var y = + Object.defineProperty({}, "p", + { + get: f, + enumerable: true, + configurable: true + }); +f.__proto__ = []; +uneval(y); + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete"); + diff --git a/js/src/tests/non262/extensions/uneval/regress-381211.js b/js/src/tests/non262/extensions/uneval/regress-381211.js new file mode 100644 index 0000000000..3ac4282e1c --- /dev/null +++ b/js/src/tests/non262/extensions/uneval/regress-381211.js @@ -0,0 +1,28 @@ +// |reftest| skip-if(!this.uneval) + +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +//----------------------------------------------------------------------------- +var BUGNUMBER = 381211; +var summary = 'uneval with getter'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = '({get x(){}})'; + actual = uneval({get x(){}}); + compareSource(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/uneval/regress-381301.js b/js/src/tests/non262/extensions/uneval/regress-381301.js new file mode 100644 index 0000000000..be8495e662 --- /dev/null +++ b/js/src/tests/non262/extensions/uneval/regress-381301.js @@ -0,0 +1,39 @@ +// |reftest| skip-if(!this.uneval) + +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +//----------------------------------------------------------------------------- +var BUGNUMBER = 381301; +var summary = 'uneval of object with native-function getter'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + var o = + Object.defineProperty({}, "x", { get: decodeURI, enumerable: true, configurable: true }); + expect = '({get x() {[native code]}})'; + actual = uneval(o); + + // Native function syntax: + // `function IdentifierName_opt ( FormalParameters ) { [ native code ] }` + + // The placement of whitespace characters in the native function's body is + // implementation-dependent, so we need to replace those for this test. + var re = new RegExp(["\\{", "\\[", "native", "code", "\\]", "\\}"].join("\\s*")); + actual = actual.replace(re, "{[native code]}"); + + compareSource(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/uneval/regress-385393-03.js b/js/src/tests/non262/extensions/uneval/regress-385393-03.js new file mode 100644 index 0000000000..2f11b25ecf --- /dev/null +++ b/js/src/tests/non262/extensions/uneval/regress-385393-03.js @@ -0,0 +1,29 @@ +// |reftest| skip-if(!this.uneval) + +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +//----------------------------------------------------------------------------- +var BUGNUMBER = 385393; +var summary = 'Regression test for bug 385393'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + f = (function() { new (delete y) }); + eval(uneval(f)) + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/uneval/regress-385729.js b/js/src/tests/non262/extensions/uneval/regress-385729.js new file mode 100644 index 0000000000..5f650e6082 --- /dev/null +++ b/js/src/tests/non262/extensions/uneval/regress-385729.js @@ -0,0 +1,58 @@ +// |reftest| skip-if(!this.uneval) + +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 385729; +var summary = 'uneval(eval(expression closure))'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +function normalizeSource(source) { + source = String(source); + source = source.replace(/([(){},.:\[\]])/mg, ' $1 '); + source = source.replace(/\s+/mg, ' '); + + return source; +} + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = '(function f () /x/g)'; + try + { + // mozilla 1.9 + actual = uneval(eval(expect)); + } + catch(ex) + { + // mozilla 1.8 + expect = 'SyntaxError: missing { before function body'; + actual = ex + ''; + } + compareSource(normalizeSource(expect), normalizeSource(actual), summary); + + expect = '({get f () /x/g})'; + try + { + // mozilla 1.9 + actual = uneval(eval("({get f () /x/g})")); + } + catch(ex) + { + // mozilla 1.8 + expect = 'SyntaxError: missing { before function body'; + actual = ex + ''; + } + compareSource(normalizeSource(expect), normalizeSource(actual), summary); +} diff --git a/js/src/tests/non262/extensions/uneval/regress-452498-082.js b/js/src/tests/non262/extensions/uneval/regress-452498-082.js new file mode 100644 index 0000000000..8fee44d2a1 --- /dev/null +++ b/js/src/tests/non262/extensions/uneval/regress-452498-082.js @@ -0,0 +1,33 @@ +// |reftest| skip-if(!this.uneval) + +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 452498; +var summary = 'TM: upvar2 regression tests'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + +// ------- Comment #82 From Gary Kwong [:nth10sd] + +// ===== + + uneval(function(){[y] = [x];}); + +// ===== + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/uneval/regress-452498-101.js b/js/src/tests/non262/extensions/uneval/regress-452498-101.js new file mode 100644 index 0000000000..c660ab9b80 --- /dev/null +++ b/js/src/tests/non262/extensions/uneval/regress-452498-101.js @@ -0,0 +1,30 @@ +// |reftest| skip-if(!this.uneval) + +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 452498; +var summary = 'TM: upvar2 regression tests'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + +// ------- Comment #101 From Gary Kwong [:nth10sd] + + uneval(function(){with({functional: []}){x5, y = this;const y = undefined }}); +// Assertion failure: strcmp(rval, with_cookie) == 0, at ../jsopcode.cpp:2567 + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/uneval/regress-452498-117.js b/js/src/tests/non262/extensions/uneval/regress-452498-117.js new file mode 100644 index 0000000000..c2b5135790 --- /dev/null +++ b/js/src/tests/non262/extensions/uneval/regress-452498-117.js @@ -0,0 +1,35 @@ +// |reftest| skip-if(!this.uneval) + +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 452498; +var summary = 'TM: upvar2 regression tests'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + +// ------- Comment #117 From Gary Kwong [:nth10sd] + +// The following all do not require -j. + +// Assertion failure: pnu->pn_lexdef == dn, at ../jsemit.cpp:1817 +// ===== + uneval(function(){arguments = ({ get y(){} }); for(var [arguments] in y ) (x);}); + +// ===== + + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/extensions/uneval/regress-621814.js b/js/src/tests/non262/extensions/uneval/regress-621814.js new file mode 100644 index 0000000000..7e661d97a8 --- /dev/null +++ b/js/src/tests/non262/extensions/uneval/regress-621814.js @@ -0,0 +1,15 @@ +// |reftest| skip-if(!this.uneval) + +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ +var expect = 'pass'; +var actual = expect; +function f({"\xF51F": x}) {} +try { + eval(uneval(f)); +} catch (e) { + actual = '' + e; +} +reportCompare(expect, actual, ""); diff --git a/js/src/tests/non262/extensions/uneval/regress-624199.js b/js/src/tests/non262/extensions/uneval/regress-624199.js new file mode 100644 index 0000000000..2634600f12 --- /dev/null +++ b/js/src/tests/non262/extensions/uneval/regress-624199.js @@ -0,0 +1,19 @@ +// |reftest| skip-if(!this.uneval) + +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ +function roundTrip(f) { + try { + eval(uneval(f)); + return true; + } catch (e) { + return '' + e; + } +} + +function f() { if (true) { 'use strict'; } var eval; } +assertEq(roundTrip(f), true); + +reportCompare(true,true); diff --git a/js/src/tests/non262/extensions/uneval/regress-90596-002.js b/js/src/tests/non262/extensions/uneval/regress-90596-002.js new file mode 100644 index 0000000000..ae66ea7142 --- /dev/null +++ b/js/src/tests/non262/extensions/uneval/regress-90596-002.js @@ -0,0 +1,264 @@ +// |reftest| skip-if(!this.uneval) + +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * Date: 28 August 2001 + * + * SUMMARY: A [DontEnum] prop, if overridden, should appear in uneval(). + * See http://bugzilla.mozilla.org/show_bug.cgi?id=90596 + * + * NOTE: some inefficiencies in the test are made for the sake of readability. + * Sorting properties alphabetically is done for definiteness in comparisons. + */ +//----------------------------------------------------------------------------- +var UBound = 0; +var BUGNUMBER = 90596; +var summary = 'A [DontEnum] prop, if overridden, should appear in uneval()'; +var cnCOMMA = ','; +var cnLBRACE = '{'; +var cnRBRACE = '}'; +var cnLPAREN = '('; +var cnRPAREN = ')'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; +var obj = {}; + + +status = inSection(1); +obj = {toString:9}; +actual = uneval(obj); +expect = '({toString:9})'; +addThis(); + +status = inSection(2); +obj = {hasOwnProperty:"Hi"}; +actual = uneval(obj); +expect = '({hasOwnProperty:"Hi"})'; +addThis(); + +status = inSection(3); +obj = {toString:9, hasOwnProperty:"Hi"}; +actual = uneval(obj); +expect = '({toString:9, hasOwnProperty:"Hi"})'; +addThis(); + +status = inSection(4); +obj = {prop1:1, toString:9, hasOwnProperty:"Hi"}; +actual = uneval(obj); +expect = '({prop1:1, toString:9, hasOwnProperty:"Hi"})'; +addThis(); + + +// TRY THE SAME THING IN EVAL CODE +var s = ''; + +status = inSection(5); +s = 'obj = {toString:9}'; +eval(s); +actual = uneval(obj); +expect = '({toString:9})'; +addThis(); + +status = inSection(6); +s = 'obj = {hasOwnProperty:"Hi"}'; +eval(s); +actual = uneval(obj); +expect = '({hasOwnProperty:"Hi"})'; +addThis(); + +status = inSection(7); +s = 'obj = {toString:9, hasOwnProperty:"Hi"}'; +eval(s); +actual = uneval(obj); +expect = '({toString:9, hasOwnProperty:"Hi"})'; +addThis(); + +status = inSection(8); +s = 'obj = {prop1:1, toString:9, hasOwnProperty:"Hi"}'; +eval(s); +actual = uneval(obj); +expect = '({prop1:1, toString:9, hasOwnProperty:"Hi"})'; +addThis(); + + +// TRY THE SAME THING IN FUNCTION CODE +function A() +{ + status = inSection(9); + var s = 'obj = {toString:9}'; + eval(s); + actual = uneval(obj); + expect = '({toString:9})'; + addThis(); +} +A(); + +function B() +{ + status = inSection(10); + var s = 'obj = {hasOwnProperty:"Hi"}'; + eval(s); + actual = uneval(obj); + expect = '({hasOwnProperty:"Hi"})'; + addThis(); +} +B(); + +function C() +{ + status = inSection(11); + var s = 'obj = {toString:9, hasOwnProperty:"Hi"}'; + eval(s); + actual = uneval(obj); + expect = '({toString:9, hasOwnProperty:"Hi"})'; + addThis(); +} +C(); + +function D() +{ + status = inSection(12); + var s = 'obj = {prop1:1, toString:9, hasOwnProperty:"Hi"}'; + eval(s); + actual = uneval(obj); + expect = '({prop1:1, toString:9, hasOwnProperty:"Hi"})'; + addThis(); +} +D(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +/* + * Sort properties alphabetically - + */ +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = sortThis(actual); + expectedvalues[UBound] = sortThis(expect); + UBound++; +} + + +/* + * Takes string of form '({"c", "b", "a", 2})' and returns '({"a","b","c",2})' + */ +function sortThis(sList) +{ + sList = compactThis(sList); + sList = stripParens(sList); + sList = stripBraces(sList); + var arr = sList.split(cnCOMMA); + arr = arr.sort(); + var ret = String(arr); + ret = addBraces(ret); + ret = addParens(ret); + return ret; +} + + +/* + * Strips out any whitespace from the text - + */ +function compactThis(text) +{ + var charCode = 0; + var ret = ''; + + for (var i=0; i<text.length; i++) + { + charCode = text.charCodeAt(i); + + if (!isWhiteSpace(charCode)) + ret += text.charAt(i); + } + + return ret; +} + + +function isWhiteSpace(charCode) +{ + switch (charCode) + { + case (0x0009): + case (0x000B): + case (0x000C): + case (0x0020): + case (0x000A): // '\n' + case (0x000D): // '\r' + return true; + break; + + default: + return false; + } +} + + +/* + * strips off parens at beginning and end of text - + */ +function stripParens(text) +{ + // remember to escape the parens... + var arr = text.match(/^\((.*)\)$/); + + // defend against a null match... + if (arr != null && arr[1] != null) + return arr[1]; + return text; +} + + +/* + * strips off braces at beginning and end of text - + */ +function stripBraces(text) +{ + // remember to escape the braces... + var arr = text.match(/^\{(.*)\}$/); + + // defend against a null match... + if (arr != null && arr[1] != null) + return arr[1]; + return text; +} + + +function addBraces(text) +{ + return cnLBRACE + text + cnRBRACE; +} + + +function addParens(text) +{ + return cnLPAREN + text + cnRPAREN; +} + + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + for (var i=0; i<UBound; i++) + { + reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); + } +} diff --git a/js/src/tests/non262/extensions/uneval/regress-96284-002.js b/js/src/tests/non262/extensions/uneval/regress-96284-002.js new file mode 100644 index 0000000000..f49b670aff --- /dev/null +++ b/js/src/tests/non262/extensions/uneval/regress-96284-002.js @@ -0,0 +1,147 @@ +// |reftest| skip-if(!this.uneval) + +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * Date: 03 September 2001 + * + * SUMMARY: Double quotes should be escaped in uneval(new Error('""')) + * See http://bugzilla.mozilla.org/show_bug.cgi?id=96284 + * + * The real point here is this: we should be able to reconstruct an object + * obj from uneval(obj). We'll test this on various types of objects. + * + * Method: define obj2 = eval(uneval(obj1)) and verify that + * obj2.toSource() == obj1.toSource(). + */ +//----------------------------------------------------------------------------- +var UBound = 0; +var BUGNUMBER = 96284; +var summary = 'Double quotes should be escaped in Error.prototype.toSource()'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; +var obj1 = {}; +var obj2 = {}; +var cnTestString = '"This is a \" STUPID \" test string!!!"\\'; + + +// various NativeError objects - +status = inSection(1); +obj1 = Error(cnTestString); +obj2 = eval(uneval(obj1)); +actual = obj2.toSource(); +expect = obj1.toSource(); +addThis(); + +status = inSection(2); +obj1 = EvalError(cnTestString); +obj2 = eval(uneval(obj1)); +actual = obj2.toSource(); +expect = obj1.toSource(); +addThis(); + +status = inSection(3); +obj1 = RangeError(cnTestString); +obj2 = eval(uneval(obj1)); +actual = obj2.toSource(); +expect = obj1.toSource(); +addThis(); + +status = inSection(4); +obj1 = ReferenceError(cnTestString); +obj2 = eval(uneval(obj1)); +actual = obj2.toSource(); +expect = obj1.toSource(); +addThis(); + +status = inSection(5); +obj1 = SyntaxError(cnTestString); +obj2 = eval(uneval(obj1)); +actual = obj2.toSource(); +expect = obj1.toSource(); +addThis(); + +status = inSection(6); +obj1 = TypeError(cnTestString); +obj2 = eval(uneval(obj1)); +actual = obj2.toSource(); +expect = obj1.toSource(); +addThis(); + +status = inSection(7); +obj1 = URIError(cnTestString); +obj2 = eval(uneval(obj1)); +actual = obj2.toSource(); +expect = obj1.toSource(); +addThis(); + + +// other types of objects - +status = inSection(8); +obj1 = new String(cnTestString); +obj2 = eval(uneval(obj1)); +actual = obj2.toSource(); +expect = obj1.toSource(); +addThis(); + +status = inSection(9); +obj1 = {color:'red', texture:cnTestString, hasOwnProperty:42}; +obj2 = eval(uneval(obj1)); +actual = obj2.toSource(); +expect = obj1.toSource(); +addThis(); + +status = inSection(10); +obj1 = function(x) {function g(y){return y+1;} return g(x);}; +obj2 = eval(uneval(obj1)); +actual = obj2.toSource(); +expect = obj1.toSource(); +addThis(); + +status = inSection(11); +obj1 = new Number(eval('6')); +obj2 = eval(uneval(obj1)); +actual = obj2.toSource(); +expect = obj1.toSource(); +addThis(); + +status = inSection(12); +obj1 = /ad;(lf)kj(2309\/\/)\/\//; +obj2 = eval(uneval(obj1)); +actual = obj2.toSource(); +expect = obj1.toSource(); +addThis(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus (summary); + + for (var i = 0; i < UBound; i++) + { + reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); + } +} diff --git a/js/src/tests/non262/extensions/uneval/regress-bug567606.js b/js/src/tests/non262/extensions/uneval/regress-bug567606.js new file mode 100644 index 0000000000..7123f8e36b --- /dev/null +++ b/js/src/tests/non262/extensions/uneval/regress-bug567606.js @@ -0,0 +1,21 @@ +// |reftest| skip-if(!this.uneval) + +// Any copyright is dedicated to the Public Domain. +// http://creativecommons.org/licenses/publicdomain/ + +var global = this; + +(function() { + function f() { + this.b = function() {}; + Object.defineProperty(this, "b", ({ + configurable: global.__defineSetter__("", function() {}) + })); + } + for (y of [0]) { + _ = new f(); + } +})(); +uneval(this); + +reportCompare(true, true); diff --git a/js/src/tests/non262/extensions/uneval/strict-function-toSource.js b/js/src/tests/non262/extensions/uneval/strict-function-toSource.js new file mode 100644 index 0000000000..383da34df6 --- /dev/null +++ b/js/src/tests/non262/extensions/uneval/strict-function-toSource.js @@ -0,0 +1,19 @@ +// |reftest| skip-if(!this.uneval) + +/* + * Bug 800407 - Functions defined with Function construcor + * do have strict mode when JSOPTION_STRICT_MODE is on. + */ + +options("strict_mode"); +function testRunOptionStrictMode(str, arg, result) { + var strict_inner = new Function('return typeof this == "undefined";'); + return strict_inner; +} +let inner = testRunOptionStrictMode(); +assertEq(inner(), true); +assertEq(eval(uneval(inner))(), true); + +assertEq((new Function('x', 'return x*2;')).toSource().includes('"use strict"'), false); + +reportCompare(true, true); diff --git a/js/src/tests/non262/extensions/uneval/symbol-uneval.js b/js/src/tests/non262/extensions/uneval/symbol-uneval.js new file mode 100644 index 0000000000..1454bc0c3a --- /dev/null +++ b/js/src/tests/non262/extensions/uneval/symbol-uneval.js @@ -0,0 +1,15 @@ +// |reftest| skip-if(!this.uneval) + +// 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/non262/extensions/uneval/toSource-0.js b/js/src/tests/non262/extensions/uneval/toSource-0.js new file mode 100644 index 0000000000..60906463c7 --- /dev/null +++ b/js/src/tests/non262/extensions/uneval/toSource-0.js @@ -0,0 +1,16 @@ +// |reftest| skip-if(!this.uneval) + +/* + * 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/non262/extensions/unterminated-literal-error-location.js b/js/src/tests/non262/extensions/unterminated-literal-error-location.js new file mode 100644 index 0000000000..de9767a1c2 --- /dev/null +++ b/js/src/tests/non262/extensions/unterminated-literal-error-location.js @@ -0,0 +1,119 @@ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +var BUGNUMBER = 1434429; +var summary = + "Report unterminated string/template literal errors with the line/column " + + "number of the point of non-termination"; + +function test(f, quotes, [line, col]) +{ + var caught = false; + try + { + f(); + } + catch (e) + { + caught = true; + assertEq(e.lineNumber, line, "line number"); + assertEq(e.columnNumber, col, "column number"); + assertEq(e.message.includes(quotes), true, + "message must contain delimiter"); + } + + assertEq(caught, true); +} + +test(function() { + //0123 + eval("'hi"); +}, "''", [1, 3]); + +test(function() { + //0123 4 + eval("'hi\\"); +}, "''", [1, 4]); + +test(function() { + //0123456 + eval(" 'hi"); +}, "''", [1, 6]); + +test(function() { + //0123456 7 + eval(" 'hi\\"); +}, "''", [1, 7]); + +test(function() { + //01234567 01234567 + eval('var x =\n "hi'); +}, '""', [2, 7]); + +test(function() { + //0123456 01234567 8 + eval('var x =\n "hi\\'); +}, '""', [2, 8]); + +test(function() { + // 1 + //0123456 01234567 012345678 01234567890123 + eval('var x =\n "hi\\\n bye\\\n no really'); +}, '""', [4, 13]); + +test(function() { + // 1 + //0123456 01234567 012345678 01234567890123 4 + eval('var x =\n "hi\\\n bye\\\n no really\\'); +}, '""', [4, 14]); + +test(function() { + //0123456 01234567 012345678 + eval('var x =\n "hi\\\n bye\n'); +}, '""', [3, 8]); + +test(function() { + //0123456 01234567 012345678 9 + eval('var x =\n "hi\\\n bye\\'); +}, '""', [3, 9]); + +test(function() { + //0123456 01234567 + eval('var x =\n `'); +}, '``', [2, 7]); + +test(function() { + //0123456 01234567 8 + eval('var x =\n `\\'); +}, '``', [2, 8]); + +test(function() { + // 1 + //0123456 0123456789012345 + eval('var x =\n htmlEscape`'); +}, '``', [2, 15]); + +test(function() { + // 1 + //0123456 0123456789012345 6 + eval('var x =\n htmlEscape`\\'); +}, '``', [2, 16]); + +test(function() { + // 1 + //0123456 01234567890123 01234 + eval('var x =\n htmlEscape\n `'); +}, '``', [3, 4]); + +test(function() { + // 1 + //0123456 01234567890123 01234 5 + eval('var x =\n htmlEscape\n `\\'); +}, '``', [3, 5]); + +if (typeof reportCompare === "function") + reportCompare(0, 0, "ok"); + +print("Tests complete"); diff --git a/js/src/tests/non262/extensions/weakmap.js b/js/src/tests/non262/extensions/weakmap.js new file mode 100644 index 0000000000..927a4dc36b --- /dev/null +++ b/js/src/tests/non262/extensions/weakmap.js @@ -0,0 +1,121 @@ +/* + * 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() +{ + 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"); +} |