diff options
Diffstat (limited to 'js/src/tests/js1_6/extensions')
17 files changed, 662 insertions, 0 deletions
diff --git a/js/src/tests/js1_6/extensions/browser.js b/js/src/tests/js1_6/extensions/browser.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/js1_6/extensions/browser.js diff --git a/js/src/tests/js1_6/extensions/nested-for-each.js b/js/src/tests/js1_6/extensions/nested-for-each.js new file mode 100644 index 000000000..d311d30d2 --- /dev/null +++ b/js/src/tests/js1_6/extensions/nested-for-each.js @@ -0,0 +1,39 @@ +/* -*- 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/. */ + + +var summary = 'for-each-in should not affect for-in'; +var BUGNUMBER = 292020; +var actual = ''; +var expect = ''; + +printBugNumber(BUGNUMBER); + +// test here +function foreachbug() +{ + var arryOuter = ["outervalue0", "outervalue1"]; + var arryInner = ["innervalue1","innervalue2"]; + + for (var j in arryOuter) + { + var result = (j in arryOuter); + if (!result) + { + return ("enumerated property not in object: (" + + j + " in arryOuter) " + result); + return result; + } + + + for each (k in arryInner) + { + // this for-each-in should not affect the outer for-in + } + } + return ''; +} + +reportCompare('', foreachbug()); diff --git a/js/src/tests/js1_6/extensions/regress-312385-01.js b/js/src/tests/js1_6/extensions/regress-312385-01.js new file mode 100644 index 000000000..7aa5d0d46 --- /dev/null +++ b/js/src/tests/js1_6/extensions/regress-312385-01.js @@ -0,0 +1,129 @@ +/* -*- 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 = 312385; +var summary = 'Generic methods with null or undefined |this|'; +var actual = ''; +var expect = true; +var voids = [null, undefined]; + + +function noop() { } + +var generics = { +String: [{ substring: [] }, +{ toLowerCase: [] }, +{ toUpperCase: [] }, +{ charAt: [] }, +{ charCodeAt: [] }, +{ indexOf: [] }, +{ lastIndexOf: [] }, +{ toLocaleLowerCase: [] }, +{ toLocaleUpperCase: [] }, +{ localeCompare: [] }, +{ match: [/(?:)/] }, // match(regexp) +{ search: [] }, +{ replace: [] }, +{ split: [] }, +{ substr: [] }, +{ concat: [] }, +{ slice: [] }], + + Array: [{ join: [] }, +{ reverse: [] }, +{ sort: [] }, + // { push: [0] }, // push(item1, ...) + // { pop: [] }, + // { shift: [] }, +{ unshift: [] }, + // { splice: [0, 0, 1] }, // splice(start, deleteCount, item1, ...) +{ concat: [] }, +{ indexOf: [] }, +{ lastIndexOf: [] }, + // forEach is excluded since it does not return a value... + /* { forEach: [noop] }, // forEach(callback, thisObj) */ +{ map: [noop] }, // map(callback, thisObj) +{ filter: [noop] }, // filter(callback, thisObj) +{ some: [noop] }, // some(callback, thisObj) +{ every: [noop] } // every(callback, thisObj) + ] +}; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +var global = this; + +for (var c in generics) +{ + var methods = generics[c]; + for (var i = 0; i < methods.length; i++) + { + var method = methods[i]; + + for (var methodname in method) + { + for (var v = 0; v < voids.length; v++) + { + var Constructor = global[c] + + var argsLen = method[methodname].length; + assertEq(argsLen === 0 || argsLen === 1, true, "not all arities handled"); + + var generic = Constructor[methodname]; + var prototypy = Constructor.prototype[methodname]; + + assertEq(typeof generic, "function"); + assertEq(typeof prototypy, "function"); + + // GENERIC METHOD TESTING + + try + { + switch (method[methodname].length) + { + case 0: + generic(voids[v]); + break; + + case 1: + generic(voids[v], method[methodname][0]); + break; + } + throw new Error(c + "." + methodname + " must throw for null or " + + "undefined first argument"); + } + catch (e) + { + assertEq(e instanceof TypeError, true, + "Didn't get a TypeError for " + c + "." + methodname + + " called with null or undefined first argument"); + } + + + // PROTOTYPE METHOD TESTING + + try + { + prototypy.apply(voids[v], method[methodname][0]); + throw new Error(c + ".prototype." + methodname + " must throw " + + "for null or undefined this"); + } + catch (e) + { + assertEq(e instanceof TypeError, true, + c + ".prototype." + methodname + "didn't throw a " + + "TypeError when called with null or undefined this"); + } + } + } + } +} + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests finished."); diff --git a/js/src/tests/js1_6/extensions/regress-385393-08.js b/js/src/tests/js1_6/extensions/regress-385393-08.js new file mode 100644 index 000000000..b00cafde9 --- /dev/null +++ b/js/src/tests/js1_6/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/js1_6/extensions/regress-414098.js b/js/src/tests/js1_6/extensions/regress-414098.js new file mode 100644 index 000000000..aa2b6e9de --- /dev/null +++ b/js/src/tests/js1_6/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/js1_6/extensions/regress-455464-01.js b/js/src/tests/js1_6/extensions/regress-455464-01.js new file mode 100644 index 000000000..c9d3486e9 --- /dev/null +++ b/js/src/tests/js1_6/extensions/regress-455464-01.js @@ -0,0 +1,20 @@ +// |reftest| skip-if(Android) -- bug - nsIDOMWindow.crypto throws NS_ERROR_NOT_IMPLEMENTED on 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 = 455464; +var summary = 'Do not assert with JIT: !TRACE_RECORDER(cx) ^ (jumpTable == recordingJumpTable)'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +printBugNumber(BUGNUMBER); +printStatus (summary); + + +a=b=c=d=0; this.__defineGetter__('g', gc); for each (y in this); + + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/js1_6/extensions/regress-455464-02.js b/js/src/tests/js1_6/extensions/regress-455464-02.js new file mode 100644 index 000000000..6ca53a495 --- /dev/null +++ b/js/src/tests/js1_6/extensions/regress-455464-02.js @@ -0,0 +1,30 @@ +// |reftest| skip-if(Android) -- bug - nsIDOMWindow.crypto throws NS_ERROR_NOT_IMPLEMENTED on 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 = 455464; +var summary = 'Do not assert with JIT: !TRACE_RECORDER(cx) ^ (jumpTable == recordingJumpTable)'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + + a=b=c=d=0; this.__defineGetter__('g', gc); for each (y in this); + + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_6/extensions/regress-455464-03.js b/js/src/tests/js1_6/extensions/regress-455464-03.js new file mode 100644 index 000000000..9a29c4f3e --- /dev/null +++ b/js/src/tests/js1_6/extensions/regress-455464-03.js @@ -0,0 +1,32 @@ +// |reftest| skip-if(Android) -- bug - nsIDOMWindow.crypto throws NS_ERROR_NOT_IMPLEMENTED on 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 = 455464; +var summary = 'Do not assert with JIT: !TRACE_RECORDER(cx) ^ (jumpTable == recordingJumpTable)'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +a=b=c=d=0; this.__defineGetter__('g', gc); for each (y in this); + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + + a=b=c=d=0; this.__defineGetter__('g', gc); for each (y in this); + + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_6/extensions/regress-455464-04.js b/js/src/tests/js1_6/extensions/regress-455464-04.js new file mode 100644 index 000000000..f7616d3b7 --- /dev/null +++ b/js/src/tests/js1_6/extensions/regress-455464-04.js @@ -0,0 +1,33 @@ +// |reftest| skip-if(Android) -- bug - nsIDOMWindow.crypto throws NS_ERROR_NOT_IMPLEMENTED on 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 = 455464; +var summary = 'Do not assert with JIT, gczeal 2: !TRACE_RECORDER(cx) ^ (jumpTable == recordingJumpTable)'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +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); + + a=b=c=d=0; this.__defineGetter__('g', gc); for each (y in this); + + gczeal(0); +} + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/js1_6/extensions/regress-456826.js b/js/src/tests/js1_6/extensions/regress-456826.js new file mode 100644 index 000000000..a073e8c8d --- /dev/null +++ b/js/src/tests/js1_6/extensions/regress-456826.js @@ -0,0 +1,128 @@ +// |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() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + + if (typeof gcparam != 'undefined') + { + gc(); + gc(); + gcparam("maxBytes", gcparam("gcBytes") + 4*1024); + expectExitCode(5); + } + + 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 each (var color in 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); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_6/extensions/regress-457521.js b/js/src/tests/js1_6/extensions/regress-457521.js new file mode 100644 index 000000000..6f4fbda50 --- /dev/null +++ b/js/src/tests/js1_6/extensions/regress-457521.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 = 457521; +var summary = 'Do not crash @ js_DecompileValueGenerator'; +var actual = ''; +var expect = ''; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +try +{ + this.__defineSetter__("x", [,,,].map); + this.watch("x", (new Function("var y, eval"))); + x = true; +} +catch(ex) +{ +} +reportCompare(expect, actual, summary); diff --git a/js/src/tests/js1_6/extensions/regress-465443.js b/js/src/tests/js1_6/extensions/regress-465443.js new file mode 100644 index 000000000..529c59a54 --- /dev/null +++ b/js/src/tests/js1_6/extensions/regress-465443.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 = 465443; +var summary = ''; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = 'TypeError: invalid assignment to const `b\''; + + + try + { + eval('(function () { const b = 16; var out = []; for each (b in [true, "", true, "", true, ""]) out.push(b >> 1) })();'); + } + catch(ex) + { + actual = ex + ''; + } + + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_6/extensions/regress-470310.js b/js/src/tests/js1_6/extensions/regress-470310.js new file mode 100644 index 000000000..c144b54b1 --- /dev/null +++ b/js/src/tests/js1_6/extensions/regress-470310.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 = 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() +{ + enterFunc ('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); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_6/extensions/regress-472508.js b/js/src/tests/js1_6/extensions/regress-472508.js new file mode 100644 index 000000000..93b929add --- /dev/null +++ b/js/src/tests/js1_6/extensions/regress-472508.js @@ -0,0 +1,23 @@ +/* -*- 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 = 472508; +var summary = 'TM: Do not crash @ TraceRecorder::emitTreeCall'; +var actual = ''; +var expect = ''; + +printBugNumber(BUGNUMBER); +printStatus (summary); + + +for (var x in this) { } +var a = [false, false, false]; +a.__defineGetter__("q", function() { }); +a.__defineGetter__("r", function() { }); +for (var i = 0; i < 2; ++i) for each (var e in a) { } + + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/js1_6/extensions/regress-479567.js b/js/src/tests/js1_6/extensions/regress-479567.js new file mode 100644 index 000000000..6f3525130 --- /dev/null +++ b/js/src/tests/js1_6/extensions/regress-479567.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 = 479567; +var summary = 'Do not assert: thing'; +var actual = ''; +var expect = ''; + +printBugNumber(BUGNUMBER); +printStatus (summary); + + +function f() +{ + (eval("(function(){for each (y in [false, false, false]);});"))(); +} + +try +{ + this.__defineGetter__("x", gc); + uneval(this.watch("y", this.toSource)) + f(); + throw x; +} +catch(ex) +{ +} + + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/js1_6/extensions/regress-565521.js b/js/src/tests/js1_6/extensions/regress-565521.js new file mode 100644 index 000000000..9dd26a250 --- /dev/null +++ b/js/src/tests/js1_6/extensions/regress-565521.js @@ -0,0 +1,40 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + * Contributor: Blake Kaplan + */ + + +//----------------------------------------------------------------------------- +var BUGNUMBER = 565521; +var summary = 'for-each getter calling'; +var actual = ''; +var expect = 'PASS'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + var proto = { get prop() { return (this === proto) ? "FAIL" : "PASS"; } }; + var obj = Object.create(proto); + + var itercount = 0; + for each (var i in obj) { + ++itercount; + actual = i; + } + + reportCompare(itercount, 1, summary + ': right itercount') + reportCompare(expect, actual, summary + ': right value'); + + exitFunc ('test'); +} + diff --git a/js/src/tests/js1_6/extensions/shell.js b/js/src/tests/js1_6/extensions/shell.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/js1_6/extensions/shell.js |