diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /js/src/tests/ecma_3/ExecutionContexts | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'js/src/tests/ecma_3/ExecutionContexts')
-rw-r--r-- | js/src/tests/ecma_3/ExecutionContexts/10.1.3-1.js | 167 | ||||
-rw-r--r-- | js/src/tests/ecma_3/ExecutionContexts/10.1.3-2.js | 37 | ||||
-rw-r--r-- | js/src/tests/ecma_3/ExecutionContexts/10.1.3.js | 37 | ||||
-rw-r--r-- | js/src/tests/ecma_3/ExecutionContexts/10.1.4-1.js | 49 | ||||
-rw-r--r-- | js/src/tests/ecma_3/ExecutionContexts/10.6.1-01.js | 103 | ||||
-rw-r--r-- | js/src/tests/ecma_3/ExecutionContexts/browser.js | 0 | ||||
-rw-r--r-- | js/src/tests/ecma_3/ExecutionContexts/regress-23346.js | 35 | ||||
-rw-r--r-- | js/src/tests/ecma_3/ExecutionContexts/regress-448595-01.js | 58 | ||||
-rw-r--r-- | js/src/tests/ecma_3/ExecutionContexts/shell.js | 0 |
9 files changed, 486 insertions, 0 deletions
diff --git a/js/src/tests/ecma_3/ExecutionContexts/10.1.3-1.js b/js/src/tests/ecma_3/ExecutionContexts/10.1.3-1.js new file mode 100644 index 000000000..eb29e55e5 --- /dev/null +++ b/js/src/tests/ecma_3/ExecutionContexts/10.1.3-1.js @@ -0,0 +1,167 @@ +/* -*- 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: 11 Feb 2002 + * SUMMARY: Testing functions having duplicate formal parameter names + * + * Note: given function f(x,x,x,x) {return x;}; f(1,2,3,4) should return 4. + * See ECMA-262 3rd Edition Final Section 10.1.3: Variable Instantiation + * + * Also see http://bugzilla.mozilla.org/show_bug.cgi?id=124900 + */ +//----------------------------------------------------------------------------- +var UBound = 0; +var BUGNUMBER = 124900; +var summary = 'Testing functions having duplicate formal parameter names'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; + + +function f1(x,x) +{ + return x; +} +status = inSection(1); +actual = f1(1,2); +expect = 2; +addThis(); + + +function f2(x,x,x) +{ + return x*x*x; +} +status = inSection(2); +actual = f2(1,2,3); +expect = 27; +addThis(); + + +function f3(x,x,x,x) +{ + return 'a' + x + 'b' + x + 'c' + x ; +} +status = inSection(3); +actual = f3(1,2,3,4); +expect = 'a4b4c4'; +addThis(); + + +/* + * If the value of the last duplicate parameter is not provided by + * the function caller, the value of this parameter is undefined + */ +function f4(x,a,b,x,z) +{ + return x; +} +status = inSection(4); +actual = f4(1,2); +expect = undefined; +addThis(); + + +/* + * f.toString() should preserve any duplicate formal parameter names that exist + */ +function f5(x,x,x,x) +{ +} +status = inSection(5); +actual = f5.toString().match(/\((.*)\)/)[1]; +actual = actual.replace(/\s/g, ''); // for definiteness, remove any white space +expect = 'x,x,x,x'; +addThis(); + + +function f6(x,x,x,x) +{ + var ret = []; + + for (var i=0; i<arguments.length; i++) + ret.push(arguments[i]); + + return ret.toString(); +} +status = inSection(6); +actual = f6(1,2,3,4); +expect = '1,2,3,4'; +addThis(); + + +/* + * This variation (assigning to x inside f) is from nboyd@atg.com + * See http://bugzilla.mozilla.org/show_bug.cgi?id=124900 + */ +function f7(x,x,x,x) +{ + x = 999; + var ret = []; + + for (var i=0; i<arguments.length; i++) + ret.push(arguments[i]); + + return ret.toString(); +} +status = inSection(7); +actual = f7(1,2,3,4); +expect = '1,2,3,999'; +addThis(); + + +/* + * Same as above, but with |var| keyword added - + */ +function f8(x,x,x,x) +{ + var x = 999; + var ret = []; + + for (var i=0; i<arguments.length; i++) + ret.push(arguments[i]); + + return ret.toString(); +} +status = inSection(8); +actual = f8(1,2,3,4); +expect = '1,2,3,999'; +addThis(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc('test'); + printBugNumber(BUGNUMBER); + printStatus(summary); + + for (var i=0; i<UBound; i++) + { + reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); + } + + exitFunc ('test'); +} diff --git a/js/src/tests/ecma_3/ExecutionContexts/10.1.3-2.js b/js/src/tests/ecma_3/ExecutionContexts/10.1.3-2.js new file mode 100644 index 000000000..295a58d4b --- /dev/null +++ b/js/src/tests/ecma_3/ExecutionContexts/10.1.3-2.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 = 395907; +var summary = 'eval of function declaration should change existing variable'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = 'typeof x: number, typeof x: function, x(): true'; + var x = "string"; + function f () { + var x = 0; + actual += 'typeof x: ' + (typeof x) + ', '; + eval('function x() { return true; }'); + actual += 'typeof x: ' + (typeof x) + ', '; + actual += 'x(): ' + x(); + } + f(); + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/ecma_3/ExecutionContexts/10.1.3.js b/js/src/tests/ecma_3/ExecutionContexts/10.1.3.js new file mode 100644 index 000000000..0911afcb6 --- /dev/null +++ b/js/src/tests/ecma_3/ExecutionContexts/10.1.3.js @@ -0,0 +1,37 @@ +/* -*- 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/. */ + + +/** + ECMA Section: 10.1.3: Variable Instantiation + FunctionDeclarations are processed before VariableDeclarations, and + VariableDeclarations don't replace existing values with undefined +*/ + +test(); + +function f() +{ + var x; + + return typeof x; + + function x() + { + return 7; + } +} + +function test() +{ + enterFunc ("test"); + + printStatus ("ECMA Section: 10.1.3: Variable Instantiation."); + printBugNumber (17290); + + reportCompare ("function", f(), "Declaration precedence test"); + + exitFunc("test"); +} diff --git a/js/src/tests/ecma_3/ExecutionContexts/10.1.4-1.js b/js/src/tests/ecma_3/ExecutionContexts/10.1.4-1.js new file mode 100644 index 000000000..95cc5b476 --- /dev/null +++ b/js/src/tests/ecma_3/ExecutionContexts/10.1.4-1.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/. */ + + +/** + ECMA Section: 10.1.4.1 Entering An Execution Context + ECMA says: + * Global Code, Function Code + Variable instantiation is performed using the global object as the + variable object and using property attributes { DontDelete }. + + * Eval Code + Variable instantiation is performed using the calling context's + variable object and using empty property attributes. +*/ + +var BUGNUMBER = '(none)'; +var summary = '10.1.4.1 Entering An Execution Context'; +var actual = ''; +var expect = ''; + +test(); + +function test() +{ + enterFunc ("test"); + printBugNumber(BUGNUMBER); + printStatus (summary); + + var y; + eval("var x = 1"); + + if (delete y) + reportCompare('PASS', 'FAIL', "Expected *NOT* to be able to delete y"); + + if (typeof x == "undefined") + reportCompare('PASS', 'FAIL', "x did not remain defined after eval()"); + else if (x != 1) + reportCompare('PASS', 'FAIL', "x did not retain it's value after eval()"); + + if (!delete x) + reportCompare('PASS', 'FAIL', "Expected to be able to delete x"); + + reportCompare('PASS', 'PASS', '10.1.4.1 Entering An Execution Context'); + + exitFunc("test"); +} diff --git a/js/src/tests/ecma_3/ExecutionContexts/10.6.1-01.js b/js/src/tests/ecma_3/ExecutionContexts/10.6.1-01.js new file mode 100644 index 000000000..3de644571 --- /dev/null +++ b/js/src/tests/ecma_3/ExecutionContexts/10.6.1-01.js @@ -0,0 +1,103 @@ +/* -*- 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 = 290774; +var summary = 'activation object never delegates to Object.prototype'; +var actual = ''; +var expect = ''; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +var toStringResult; +var evalResult; +var watchResult; +var parseIntResult; + +var eval = 'fooEval'; +var watch = undefined; +var parseInt = 'fooParseInt'; + + +function toString() +{ + return 'fooString'; +} + +function normal() +{ + toStringResult = toString; + evalResult = eval; + watchResult = watch; + parseIntResult = parseInt; +} + +function outerinnervar() +{ + toStringResult = toString; + evalResult = eval; + watchResult = watch; + parseIntResult = parseInt; + function inner() + { + // addition of any statement + // which accesses a variable + // from the outer scope causes the bug + printStatus(toString); + } +} + +expect = true; + +printStatus('normal'); +printStatus('======'); +normal(); + +printStatus('toStringResult ' + toStringResult); +printStatus('toString ' + toString); +actual = ((toStringResult + '') == (toString + '')); +reportCompare(expect, actual, inSection(1)); + +printStatus('evalResult ' + evalResult); +printStatus('eval ' + eval); +actual = ((evalResult + '') == (eval + '')); +reportCompare(expect, actual, inSection(2)); + +printStatus('watchResult ' + watchResult); +printStatus('watch ' + watch); +actual = ((watchResult + '') == (watch + '')); +reportCompare(expect, actual, inSection(3)); + +printStatus('parseIntResult ' + parseIntResult); +printStatus('parseInt ' + parseInt); +actual = ((parseIntResult + '') == (parseInt + '')); +reportCompare(expect, actual, inSection(4)); + +printStatus('outerinner'); +printStatus('=========='); + +outerinnervar(); + +printStatus('toStringResult ' + toStringResult); +printStatus('toString ' + toString); +actual = ((toStringResult + '') == (toString + '')); +reportCompare(expect, actual, inSection(5)); + + +printStatus('evalResult ' + evalResult); +printStatus('eval ' + eval); +actual = ((evalResult + '') == (eval + '')); +reportCompare(expect, actual, inSection(6)); + +printStatus('watchResult ' + watchResult); +printStatus('watch ' + watch); +actual = ((watchResult + '') == (watch + '')); +reportCompare(expect, actual, inSection(7)); + +printStatus('parseIntResult ' + parseIntResult); +printStatus('parseInt ' + parseInt); +actual = ((parseIntResult + '') == (parseInt + '')); +reportCompare(expect, actual, inSection(8)); diff --git a/js/src/tests/ecma_3/ExecutionContexts/browser.js b/js/src/tests/ecma_3/ExecutionContexts/browser.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/ecma_3/ExecutionContexts/browser.js diff --git a/js/src/tests/ecma_3/ExecutionContexts/regress-23346.js b/js/src/tests/ecma_3/ExecutionContexts/regress-23346.js new file mode 100644 index 000000000..1b22b8c51 --- /dev/null +++ b/js/src/tests/ecma_3/ExecutionContexts/regress-23346.js @@ -0,0 +1,35 @@ +/* -*- tab-width: 8; 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 CALL_CALLED = "PASSED"; + +test(); + +function f(x) +{ + if (x) + return call(); + + return "FAILED!"; +} + +function call() +{ + return CALL_CALLED; +} + +function test() +{ + enterFunc ("test"); + + printStatus ("ECMA Section: 10.1.3: Variable Instantiation."); + printBugNumber (23346); + + reportCompare ("PASSED", f(true), + "Unqualified reference should not see Function.prototype"); + + exitFunc("test"); +} diff --git a/js/src/tests/ecma_3/ExecutionContexts/regress-448595-01.js b/js/src/tests/ecma_3/ExecutionContexts/regress-448595-01.js new file mode 100644 index 000000000..36359eb2a --- /dev/null +++ b/js/src/tests/ecma_3/ExecutionContexts/regress-448595-01.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 = 448595; +var summary = 'scope chain var declaration with initialiser in |with| clauses'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + var f; + + expect = 'bar'; + + f = function(){ + var e = "bar"; + with({e:"foo"}) { + var e = "wibble"; + }; + + actual = e; + } + + f(); + + reportCompare(expect, actual, summary + ': with'); + + f = function(){ + var e = "bar"; + try + { + throw {e:"foo"}; + } + catch(e) { + var e = "wibble"; + }; + + actual = e; + } + + f(); + + reportCompare(expect, actual, summary + ': catch'); + + exitFunc ('test'); +} diff --git a/js/src/tests/ecma_3/ExecutionContexts/shell.js b/js/src/tests/ecma_3/ExecutionContexts/shell.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/ecma_3/ExecutionContexts/shell.js |