diff options
Diffstat (limited to 'js/src/tests/js1_8_1/extensions')
-rw-r--r-- | js/src/tests/js1_8_1/extensions/browser.js | 0 | ||||
-rw-r--r-- | js/src/tests/js1_8_1/extensions/new-parenthesization.js | 21 | ||||
-rw-r--r-- | js/src/tests/js1_8_1/extensions/regress-353214-02.js | 30 | ||||
-rw-r--r-- | js/src/tests/js1_8_1/extensions/regress-437288-01.js | 35 | ||||
-rw-r--r-- | js/src/tests/js1_8_1/extensions/regress-452498-162.js | 24 | ||||
-rw-r--r-- | js/src/tests/js1_8_1/extensions/regress-452498-193.js | 34 | ||||
-rw-r--r-- | js/src/tests/js1_8_1/extensions/regress-452498-196.js | 44 | ||||
-rw-r--r-- | js/src/tests/js1_8_1/extensions/regress-466905-04.js | 49 | ||||
-rw-r--r-- | js/src/tests/js1_8_1/extensions/regress-466905-05.js | 45 | ||||
-rw-r--r-- | js/src/tests/js1_8_1/extensions/regress-477158.js | 31 | ||||
-rw-r--r-- | js/src/tests/js1_8_1/extensions/regress-477187.js | 41 | ||||
-rw-r--r-- | js/src/tests/js1_8_1/extensions/regress-520572.js | 41 | ||||
-rw-r--r-- | js/src/tests/js1_8_1/extensions/shell.js | 0 | ||||
-rw-r--r-- | js/src/tests/js1_8_1/extensions/strict-warning.js | 32 |
14 files changed, 427 insertions, 0 deletions
diff --git a/js/src/tests/js1_8_1/extensions/browser.js b/js/src/tests/js1_8_1/extensions/browser.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/js1_8_1/extensions/browser.js diff --git a/js/src/tests/js1_8_1/extensions/new-parenthesization.js b/js/src/tests/js1_8_1/extensions/new-parenthesization.js new file mode 100644 index 000000000..a3aebf383 --- /dev/null +++ b/js/src/tests/js1_8_1/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/js1_8_1/extensions/regress-353214-02.js b/js/src/tests/js1_8_1/extensions/regress-353214-02.js new file mode 100644 index 000000000..13a8f246d --- /dev/null +++ b/js/src/tests/js1_8_1/extensions/regress-353214-02.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 = 353214; +var summary = 'bug 353214'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + var f = function ([x]) { let y; } + expect = 'function ([x]) { let y; }'; + actual = f + ''; + + compareSource(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_8_1/extensions/regress-437288-01.js b/js/src/tests/js1_8_1/extensions/regress-437288-01.js new file mode 100644 index 000000000..d9813c34f --- /dev/null +++ b/js/src/tests/js1_8_1/extensions/regress-437288-01.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 = 437288; +var summary = 'for loop turning into a while loop'; +var actual = 'No Hang'; +var expect = 'No Hang'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + try + { + eval('(function() { const x = 1; for (x in null); })();'); + } + catch(ex) + { + actual = ex + ''; + } + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_8_1/extensions/regress-452498-162.js b/js/src/tests/js1_8_1/extensions/regress-452498-162.js new file mode 100644 index 000000000..543c9a1b0 --- /dev/null +++ b/js/src/tests/js1_8_1/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/js1_8_1/extensions/regress-452498-193.js b/js/src/tests/js1_8_1/extensions/regress-452498-193.js new file mode 100644 index 000000000..1397bf4bb --- /dev/null +++ b/js/src/tests/js1_8_1/extensions/regress-452498-193.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 = 452498; +var summary = 'TM: upvar2 regression tests'; +var actual = ''; +var expect = ''; + +//------- Comment #193 From Gary Kwong + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + +// Assertion failure: afunbox->parent, at ../jsparse.cpp:1912 + + this.x = undefined; + this.watch("x", Function); + NaN = uneval({ get \u3056 (){ return undefined } }); + x+=NaN; + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_8_1/extensions/regress-452498-196.js b/js/src/tests/js1_8_1/extensions/regress-452498-196.js new file mode 100644 index 000000000..69d5a3586 --- /dev/null +++ b/js/src/tests/js1_8_1/extensions/regress-452498-196.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 = 452498; +var summary = 'TM: upvar2 regression tests'; +var actual = ''; +var expect = ''; + +//------- Comment #196 From Gary Kwong + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + +// Assertion failure: localKind == JSLOCAL_VAR || localKind == JSLOCAL_CONST, at ../jsfun.cpp:916 + + this.x = undefined; + this.watch("x", Function); + NaN = uneval({ get \u3056 (){ return undefined } }); + x+=NaN; + + reportCompare(expect, actual, summary + ': 1'); + +// Assertion failure: lexdep->isLet(), at ../jsparse.cpp:1900 + + (function (){ + var x; + eval("var x; (function ()x)"); + } + )(); + + reportCompare(expect, actual, summary + ': 2'); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_8_1/extensions/regress-466905-04.js b/js/src/tests/js1_8_1/extensions/regress-466905-04.js new file mode 100644 index 000000000..95f9e2aef --- /dev/null +++ b/js/src/tests/js1_8_1/extensions/regress-466905-04.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 = 466905; +var summary = 'Prototypes of sandboxed arrays'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('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); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_8_1/extensions/regress-466905-05.js b/js/src/tests/js1_8_1/extensions/regress-466905-05.js new file mode 100644 index 000000000..c1da83dba --- /dev/null +++ b/js/src/tests/js1_8_1/extensions/regress-466905-05.js @@ -0,0 +1,45 @@ +// |reftest| skip -- no-op in browser, fails in shell - see bug 554793 +/* -*- 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 = 466905; +var summary = 'Sandbox shapes'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + if (typeof evalcx != 'function') + { + expect = actual = 'Test skipped: requires evalcx support'; + } + else if (typeof shapeOf != 'function') + { + expect = actual = 'Test skipped: requires shapeOf support'; + } + else + { + + var s1 = evalcx('lazy'); + var s2 = evalcx('lazy'); + + expect = shapeOf(s1); + actual = shapeOf(s2); + } + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_8_1/extensions/regress-477158.js b/js/src/tests/js1_8_1/extensions/regress-477158.js new file mode 100644 index 000000000..9ff3591e6 --- /dev/null +++ b/js/src/tests/js1_8_1/extensions/regress-477158.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 = 477158; +var summary = 'Do not assert: v == JSVAL_TRUE || v == JSVAL_FALSE'; +var actual = ''; +var expect = ''; + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + + x = 0; + x = x.prop; + for each (let [] in ['', '']) { switch(x) { default: (function(){}); } }; + + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_8_1/extensions/regress-477187.js b/js/src/tests/js1_8_1/extensions/regress-477187.js new file mode 100644 index 000000000..76b2d1954 --- /dev/null +++ b/js/src/tests/js1_8_1/extensions/regress-477187.js @@ -0,0 +1,41 @@ +// |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() +{ + enterFunc ('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); + } + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_8_1/extensions/regress-520572.js b/js/src/tests/js1_8_1/extensions/regress-520572.js new file mode 100644 index 000000000..97f00029a --- /dev/null +++ b/js/src/tests/js1_8_1/extensions/regress-520572.js @@ -0,0 +1,41 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 4 -*- */ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + * Contributor: Blake Kaplan + */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 520572; +var summary = 'watch should innerize the object being watched'; +var actual = 0; +var expect = 2; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + if ("evalcx" in this) { + // shell + let s = evalcx("lazy"); + s.n = 0; + evalcx('this.watch("x", function(){ n++; }); this.x = 4; x = 6', s); + actual = s.n; + reportCompare(expect, actual, summary); + } else { + // browser + this.watch('x', function(){ actual++; }); + this.x = 4; + x = 6; + reportCompare(expect, actual, summary); + } + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_8_1/extensions/shell.js b/js/src/tests/js1_8_1/extensions/shell.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/js1_8_1/extensions/shell.js diff --git a/js/src/tests/js1_8_1/extensions/strict-warning.js b/js/src/tests/js1_8_1/extensions/strict-warning.js new file mode 100644 index 000000000..b5a37ea70 --- /dev/null +++ b/js/src/tests/js1_8_1/extensions/strict-warning.js @@ -0,0 +1,32 @@ +// Turn on strict mode and warnings-as-errors mode. +if (options().split().indexOf('strict') == -1) + options('strict'); +if (options().split().indexOf('werror') == -1) + options('werror'); + +function expectSyntaxError(stmt) { + print(stmt); + var result = 'no error'; + try { + Function(stmt); + } catch (exc) { + result = exc.constructor.name; + } + assertEq(result, 'SyntaxError'); +} + +function test(expr) { + // Without extra parentheses, expect an error. + expectSyntaxError('if (' + expr + ') {};'); + + // Extra parentheses silence the warning/error. + Function('if ((' + expr + ')) {};'); +} + +// Overparenthesized assignment in a condition should not be a strict error. +test('a = 0'); +test('a = (f(), g)'); +test('a = b || c > d'); +expectSyntaxError('if (a == 0);'); +reportCompare('passed', 'passed', 'Overparenthesized assignment in a condition should not be a strict error.'); + |