diff options
Diffstat (limited to 'js/src/tests/js1_7/extensions')
60 files changed, 2636 insertions, 0 deletions
diff --git a/js/src/tests/js1_7/extensions/basic-Iterator.js b/js/src/tests/js1_7/extensions/basic-Iterator.js new file mode 100644 index 000000000..b35f46d03 --- /dev/null +++ b/js/src/tests/js1_7/extensions/basic-Iterator.js @@ -0,0 +1,165 @@ +/* -*- 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 = "(none)"; +var summary = "Basic support for accessing iterable objects using Iterator"; +var actual, expect; + +printBugNumber(BUGNUMBER); +printStatus(summary); + +/************** + * BEGIN TEST * + **************/ + +var failed = false; + +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; +} + +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"; + } + + var keys = ["foo", "bar", "baz"]; + var vals = [6, 5, 14]; + + iterable.__iterator__ = + function(keysOnly) + { + var gen = + function() + { + for (var i = 0; i < keys.length; i++) + { + if (keysOnly) + yield keys[i]; + else + yield [keys[i], vals[i]]; + } + }; + return gen(); + }; + + /* Test [key, value] Iterator */ + var index = 0; + var lastSeen = "INITIALVALUE"; + var it = Iterator(iterable); + try + { + while (true) + { + var nextVal = it.next(); + if (!Array_equals(nextVal, [keys[index], vals[index]])) + throw "Iterator(iterable): wrong next result\n" + + " expected: " + [keys[index], vals[index]] + "\n" + + " actual: " + nextVal; + lastSeen = keys[index]; + index++; + } + } + catch (e) + { + if (lastSeen !== keys[keys.length - 1]) + throw "Iterator(iterable): not everything was iterated!\n" + + " last iterated was: " + lastSeen + "\n" + + " error: " + e; + if (e !== StopIteration) + throw "Iterator(iterable): missing or invalid StopIteration"; + } + + if (iterable.persistedProp != 17) + throw "iterable.persistedProp not persisted!"; + + /* Test [key, value] Iterator, called with an explicit |false| parameter */ + var index = 0; + lastSeen = "INITIALVALUE"; + it = Iterator(iterable, false); + try + { + while (true) + { + var nextVal = it.next(); + if (!Array_equals(nextVal, [keys[index], vals[index]])) + throw "Iterator(iterable, false): wrong next result\n" + + " expected: " + [keys[index], vals[index]] + "\n" + + " actual: " + nextVal; + lastSeen = keys[index]; + index++; + } + } + catch (e) + { + if (lastSeen !== keys[keys.length - 1]) + throw "Iterator(iterable, false): not everything was iterated!\n" + + " last iterated was: " + lastSeen + "\n" + + " error: " + e; + if (e !== StopIteration) + throw "Iterator(iterable, false): missing or invalid StopIteration"; + } + + if (iterable.persistedProp != 17) + throw "iterable.persistedProp not persisted!"; + + /* Test key-only Iterator */ + index = 0; + lastSeen = undefined; + it = Iterator(iterable, true); + try + { + while (true) + { + var nextVal = it.next(); + if (nextVal !== keys[index]) + throw "Iterator(iterable, true): wrong next result\n" + + " expected: " + keys[index] + "\n" + + " actual: " + nextVal; + lastSeen = keys[index]; + index++; + } + } + catch (e) + { + if (lastSeen !== keys[keys.length - 1]) + throw "Iterator(iterable, true): not everything was iterated!\n" + + " last iterated was: " + lastSeen + "\n" + + " error: " + e; + if (e !== StopIteration) + throw "Iterator(iterable, true): missing or invalid StopIteration"; + } + + 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/js1_7/extensions/basic-for-each.js b/js/src/tests/js1_7/extensions/basic-for-each.js new file mode 100644 index 000000000..8b3097d4b --- /dev/null +++ b/js/src/tests/js1_7/extensions/basic-for-each.js @@ -0,0 +1,90 @@ +/* -*- 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"; + } + + var keys = ["foo", "bar", "baz"]; + var vals = [6, 5, 14]; + + iterable.__iterator__ = + function(keysOnly) + { + var gen = + function() + { + for (var i = 0; i < keys.length; i++) + { + if (keysOnly) + yield keys[i]; + else + yield [keys[i], vals[i]]; + } + }; + return gen(); + }; + + // for each sets keysOnly==false + var index = 0; + for each (var v in iterable) + { + if (!Array_equals(v, [keys[index], vals[index]])) + throw "for-each iteration failed on index=" + index + "!"; + index++; + } + if (index != keys.length) + throw "not everything iterated! index=" + index + + ", keys.length=" + keys.length; + + 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/js1_7/extensions/basic-for-in.js b/js/src/tests/js1_7/extensions/basic-for-in.js new file mode 100644 index 000000000..d50aa5cbe --- /dev/null +++ b/js/src/tests/js1_7/extensions/basic-for-in.js @@ -0,0 +1,78 @@ +/* -*- 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"; + } + + var keys = ["foo", "bar", "baz"]; + var vals = [6, 5, 14]; + + iterable.__iterator__ = + function(keysOnly) + { + var gen = + function() + { + for (var i = 0; i < keys.length; i++) + { + if (keysOnly) + yield keys[i]; + else + yield [keys[i], vals[i]]; + } + }; + return gen(); + }; + + // for in sets keysOnly==true + var index = 0; + for (var k in iterable) + { + if (k != keys[index]) + throw "for-in iteration failed on keys[\"" + index + "\"]"; + index++; + } + if (index != keys.length) + throw "not everything iterated! index=" + index + + ", keys.length=" + keys.length; + + 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/js1_7/extensions/browser.js b/js/src/tests/js1_7/extensions/browser.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/js1_7/extensions/browser.js diff --git a/js/src/tests/js1_7/extensions/destructuring-order.js b/js/src/tests/js1_7/extensions/destructuring-order.js new file mode 100644 index 000000000..72bba5b09 --- /dev/null +++ b/js/src/tests/js1_7/extensions/destructuring-order.js @@ -0,0 +1,152 @@ +/* -*- 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 = "(none)"; +var summary = "Order of destructuring, destructuring in the presence of " + + "exceptions"; +var actual, expect; + +printBugNumber(BUGNUMBER); +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/js1_7/extensions/iterator-ctor.js b/js/src/tests/js1_7/extensions/iterator-ctor.js new file mode 100644 index 000000000..92d3347cf --- /dev/null +++ b/js/src/tests/js1_7/extensions/iterator-ctor.js @@ -0,0 +1,102 @@ +/* -*- 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/. */ + +// See http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Guide:Iterators_and_Generators + +//----------------------------------------------------------------------------- +var BUGNUMBER = "410725"; +var summary = "Test of the global Iterator constructor"; +var actual, expect; + +printBugNumber(BUGNUMBER); +printStatus(summary); + +/************** + * BEGIN TEST * + **************/ + +function iteratorToArray(iterator) { + var result = []; + for (var i in iterator) { + result[result.length] = i; + } + return result.sort(); +} + +var obj = {a:1, b:2}; + +reportCompare('["a", "b"]', + uneval(iteratorToArray(obj)), + 'uneval(iteratorToArray(obj))'); + +reportCompare('[["a", 1], ["b", 2]]', + uneval(iteratorToArray(Iterator(obj))), + 'uneval(iteratorToArray(Iterator(obj)))'); + +reportCompare('[["a", 1], ["b", 2]]', + uneval(iteratorToArray(new Iterator(obj))), + 'uneval(iteratorToArray(new Iterator(obj)))'); + +reportCompare('[["a", 1], ["b", 2]]', + uneval(iteratorToArray(Iterator(obj,false))), + 'uneval(iteratorToArray(Iterator(obj,false)))'); + +reportCompare('[["a", 1], ["b", 2]]', + uneval(iteratorToArray(new Iterator(obj,false))), + 'uneval(iteratorToArray(new Iterator(obj,false)))'); + +reportCompare('["a", "b"]', + uneval(iteratorToArray(Iterator(obj,true))), + 'uneval(iteratorToArray(Iterator(obj,true)))'); + +reportCompare('["a", "b"]', + uneval(iteratorToArray(new Iterator(obj,true))), + 'uneval(iteratorToArray(new Iterator(obj,true)))'); + +var flag; +var obji = {a:1, b:2}; +obji.__iterator__ = function (b) { flag = b; yield -1; yield -2; } + +flag = -1; +reportCompare('[-1, -2]', + uneval(iteratorToArray(obji)), + 'uneval(iteratorToArray(obji))'); +reportCompare(true, flag, 'uneval(iteratorToArray(obji)) flag'); + +flag = -1; +reportCompare('[-1, -2]', + uneval(iteratorToArray(Iterator(obji))), + 'uneval(iteratorToArray(Iterator(obji)))'); +reportCompare(false, flag, 'uneval(iteratorToArray(Iterator(obji))) flag'); + +flag = -1; +reportCompare('[-1, -2]', + uneval(iteratorToArray(new Iterator(obji))), + 'uneval(iteratorToArray(new Iterator(obji)))'); +reportCompare(false, flag, 'uneval(iteratorToArray(new Iterator(obji))) flag'); + +flag = -1; +reportCompare('[-1, -2]', + uneval(iteratorToArray(Iterator(obji,false))), + 'uneval(iteratorToArray(Iterator(obji,false)))'); +reportCompare(false, flag, 'uneval(iteratorToArray(Iterator(obji,false))) flag'); + +flag = -1; +reportCompare('[-1, -2]', + uneval(iteratorToArray(new Iterator(obji,false))), + 'uneval(iteratorToArray(new Iterator(obji,false)))'); +reportCompare(false, flag, 'uneval(iteratorToArray(new Iterator(obji,false))) flag'); + +flag = -1; +reportCompare('[-1, -2]', + uneval(iteratorToArray(Iterator(obji,true))), + 'uneval(iteratorToArray(Iterator(obji,true)))'); +reportCompare(true, flag, 'uneval(iteratorToArray(Iterator(obji,true))) flag'); + +flag = -1; +reportCompare('[-1, -2]', + uneval(iteratorToArray(new Iterator(obji,true))), + 'uneval(iteratorToArray(new Iterator(obji,true)))'); +reportCompare(true, flag, 'uneval(iteratorToArray(new Iterator(obji,true))) flag'); diff --git a/js/src/tests/js1_7/extensions/regress-346021.js b/js/src/tests/js1_7/extensions/regress-346021.js new file mode 100644 index 000000000..e8849aae3 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-346021.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 = 346021; +var summary = 'Implementing __iterator__ as generator'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + var o = { __iterator__: function () { print(12); yield 42; } }; + + expect = 42; + actual = 0; + + for (let i in Iterator(o)) + { + actual = i; + } + + reportCompare(expect, actual, summary); + + actual = 0; + + for (let i in o) + { + actual = i; // this doesn't iterate 42 + } + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-346642-06.js b/js/src/tests/js1_7/extensions/regress-346642-06.js new file mode 100644 index 000000000..e7664eab5 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-346642-06.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 = 346642; +var summary = 'decompilation of destructuring assignment'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('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'); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-346773.js b/js/src/tests/js1_7/extensions/regress-346773.js new file mode 100644 index 000000000..3faa2c73f --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-346773.js @@ -0,0 +1,52 @@ +/* -*- 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 brances in function'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('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); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-350312.js b/js/src/tests/js1_7/extensions/regress-350312.js new file mode 100644 index 000000000..4da03648c --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-350312.js @@ -0,0 +1,80 @@ +/* -*- 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() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + var iter; + function gen() + { + try { + yield iter; + } catch (e if e == null) { + actual += 'CATCH,'; + print("CATCH"); + } finally { + actual += 'FINALLY'; + print("FINALLY"); + } + } + + expect = 'FINALLY'; + actual = ''; + (iter = gen()).next().close(); + reportCompare(expect, actual, summary); + + expect = 'FINALLY'; + actual = ''; + try + { + (iter = gen()).next().throw(1); + } + catch(ex) + { + } + reportCompare(expect, actual, summary); + + expect = 'CATCH,FINALLY'; + actual = ''; + try + { + (iter = gen()).next().throw(null); + } + catch(ex) + { + } + reportCompare(expect, actual, summary); + + expect = 'FINALLY'; + actual = ''; + var expectexcp = '[object StopIteration]'; + var actualexcp = ''; + try + { + (iter = gen()).next().next(); + } + catch(ex) + { + actualexcp = ex + ''; + } + reportCompare(expect, actual, summary); + reportCompare(expectexcp, actualexcp, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-351070-02.js b/js/src/tests/js1_7/extensions/regress-351070-02.js new file mode 100644 index 000000000..b478da195 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-351070-02.js @@ -0,0 +1,69 @@ +/* -*- 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() +{ + enterFunc ('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; + } + print('uneval: ' + uneval(fun)); + 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); + } + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-351102-03.js b/js/src/tests/js1_7/extensions/regress-351102-03.js new file mode 100644 index 000000000..5790cfab8 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-351102-03.js @@ -0,0 +1,43 @@ +/* -*- 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 = 351102; +var summary = 'try/catch-guard/finally GC issues'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + var f; + f = function() + { + try + { + d.d.d; + } + catch({} if gc()) + { + } + catch(y) + { + } + }; + + f(); + f(); + + reportCompare(expect, actual, summary + ': 3'); + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-351102-04.js b/js/src/tests/js1_7/extensions/regress-351102-04.js new file mode 100644 index 000000000..716454160 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-351102-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 = 351102; +var summary = 'try/catch-guard/finally GC issues'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + var f; + try + { + try { foo() } catch([] if gc()) { } + } + catch(ex) + { + } + reportCompare(expect, actual, summary + ': 4'); + + exitFunc ('test'); +} + diff --git a/js/src/tests/js1_7/extensions/regress-351102-05.js b/js/src/tests/js1_7/extensions/regress-351102-05.js new file mode 100644 index 000000000..32b3d39e6 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-351102-05.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 = 351102; +var summary = 'try/catch-guard/finally GC issues'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + var f; + try + { + try { d.d.d } catch([] if gc()) { } + } + catch(ex) + { + } + reportCompare(expect, actual, summary + ': 5'); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-351102-07.js b/js/src/tests/js1_7/extensions/regress-351102-07.js new file mode 100644 index 000000000..16a6f18fe --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-351102-07.js @@ -0,0 +1,43 @@ +/* -*- 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 = 351102; +var summary = 'try/catch-guard/finally GC issues'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + var f; + var obj = { get a() { + try { + throw 1; + } catch (e) { + } + return false; + }}; + + try { + throw obj; + } catch ({a: a} if a) { + throw "Unreachable"; + } catch (e) { + if (e !== obj) + throw "Unexpected exception: "+uneval(e); + } + reportCompare(expect, actual, summary + ': 7'); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-352797-01.js b/js/src/tests/js1_7/extensions/regress-352797-01.js new file mode 100644 index 000000000..cb3c98f59 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-352797-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 = 352797; +var summary = 'Do not assert: OBJ_GET_CLASS(cx, obj) == &js_BlockClass'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + if (typeof Script == 'undefined') + { + print('Test skipped. Script not defined.'); + } + else + { + (function(){let x = 'fafafa'.replace(/a/g, new Script(''))})(); + } + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-352885-01.js b/js/src/tests/js1_7/extensions/regress-352885-01.js new file mode 100644 index 000000000..9210f17a7 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-352885-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 = 352885; +var summary = 'Do not crash iterating over gen.__proto__'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + for (j in ((function() { yield 3; })().__proto__)) + print(j); + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-352885-02.js b/js/src/tests/js1_7/extensions/regress-352885-02.js new file mode 100644 index 000000000..d243813f9 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-352885-02.js @@ -0,0 +1,67 @@ +/* -*- 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 = 352885; +var summary = 'Do not crash iterating over gen.__proto__'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + function dotest() + { + var proto = (function() { yield 3; })().__proto__; + + try { + proto.next(); + throw "generatorProto.next() does not throw TypeError"; + } catch (e) { + if (!(e instanceof TypeError)) + throw "generatorProto.next() throws unexpected exception: "+uneval(e); + } + + try { + proto.send(); + throw "generatorProto.send() does not throw TypeError"; + } catch (e) { + if (!(e instanceof TypeError)) + throw "generatorProto.send() throws unexpected exception: "+uneval(e); + } + + var obj = {}; + try { + proto.throw(obj); + throw "generatorProto.throw(obj) does not throw TypeError"; + } catch (e) { + if (!(e instanceof TypeError)) + throw "generatorProto.throw() throws unexpected exception: "+uneval(e); + } + + try { + proto.close(); + throw "generatorProto.close() does not throw TypeError"; + } catch (e) { + if (!(e instanceof TypeError)) + throw "generatorProto.close() throws unexpected exception: "+uneval(e); + } + + } + + dotest(); + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-353214-01.js b/js/src/tests/js1_7/extensions/regress-353214-01.js new file mode 100644 index 000000000..bd0cbb676 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-353214-01.js @@ -0,0 +1,47 @@ +// |reftest| skip -- obsolete test +/* -*- 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 = 353214; +var summary = 'bug 353214'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + var f = function () { + switch(({ get x() { export *; }, set x([[y], [x] ]) { let x; } })) { + case eval("[[1]]", function(id) { return id; }): + L:for(let x in (((eval).call)(eval("yield <x><y/></x>;", "" ))))var x; + case (uneval(this)): + import x.*; + } + } + + expect = 'function () { ' + + 'switch({ get x() { export *; }, set x([[y], [x] ]) { let x; } }) { ' + + 'case eval("[[1]]", function(id) { return id; }): ' + + 'L:for(let x in eval.call(eval("yield <x><y/></x>;", "" ))){var x;} ' + + 'case uneval(this): ' + + 'import x.*; default:;' + + '} ' + + '}'; + + actual = f + ''; + + compareSource(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-353249.js b/js/src/tests/js1_7/extensions/regress-353249.js new file mode 100644 index 000000000..8bc5ed931 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-353249.js @@ -0,0 +1,35 @@ +// |reftest| skip -- obsolete test +/* -*- 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 = 353249; +var summary = 'regression test for bug 353249'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + var f = (function () { let (x) <x/>.(1) < let (z) eval('3'); + for (x in this) {} }); + + expect = 'function () { (let (x) <x/>.((1)) < (let (z) eval("3"))); ' + + 'for (x in this) {} }'; + actual = f + ''; + compareSource(expect, actual, summary); + + // do not crash() + f(); + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-354499-01.js b/js/src/tests/js1_7/extensions/regress-354499-01.js new file mode 100644 index 000000000..6a9ae40b9 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-354499-01.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 = 354499; +var summary = 'Iterating over Array elements'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = actual = 'No Crash'; + + var obj = {get a(){ return new Object(); }}; + + function setter(v) + { + // Push out obj.a from all temp roots + var tmp = { get toString() { return new Object(); }}; + try { String(tmp); } catch (e) { } + gc(); + } + + Array.prototype.__defineGetter__(0, function() { }); + Array.prototype.__defineSetter__(0, setter); + + for (var i in Iterator(obj)) + print(uneval(i)); + + delete Array.prototype[0]; + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-354499-02.js b/js/src/tests/js1_7/extensions/regress-354499-02.js new file mode 100644 index 000000000..8f5c62918 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-354499-02.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 = 354499; +var summary = 'Iterating over Array elements'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = actual = 'No Crash'; + + function get_value() + { + // Unroot the first element + this[0] = 0; + + // Call gc to collect atom corresponding to Math.sqrt(2) + gc(); + } + + var counter = 2; + Iterator.prototype.next = function() + { + if (counter-- <= 0) throw StopIteration; + var a = [Math.sqrt(2), 1]; + a.__defineGetter__(1, get_value); + return a; + }; + + for (i in [1]) + ; + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-354945-01.js b/js/src/tests/js1_7/extensions/regress-354945-01.js new file mode 100644 index 000000000..76f1a3c82 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-354945-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 = 354945; +var summary = 'Do not crash with new Iterator'; +var expect = 'TypeError: trap __iterator__ for ({__iterator__:(function (){ })}) returned a primitive value'; +var actual; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + try { + var obj = {}; + obj.__iterator__ = function(){ }; + for(t in (new Iterator(obj))) { } + } catch (ex) { + actual = ex.toString(); + } + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-354945-02.js b/js/src/tests/js1_7/extensions/regress-354945-02.js new file mode 100644 index 000000000..261bf7de1 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-354945-02.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 = 354945; +var summary = 'Do not crash with new Iterator'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = 'TypeError: trap __iterator__ for ({__iterator__:(function (){ })}) returned a primitive value'; + var obj = {}; + obj.__iterator__ = function(){ }; + try + { + for(t in (obj)) { } + } + catch(ex) + { + actual = ex + ''; + } + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-355052-01.js b/js/src/tests/js1_7/extensions/regress-355052-01.js new file mode 100644 index 000000000..ea5f5d7d7 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-355052-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 = 355052; +var summary = 'Do not crash with valueOf:gc and __iterator__'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('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); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-355052-02.js b/js/src/tests/js1_7/extensions/regress-355052-02.js new file mode 100644 index 000000000..57d06153e --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-355052-02.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 = 355052; +var summary = 'Do not crash with valueOf:gc and __iterator__'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('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); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-355052-03.js b/js/src/tests/js1_7/extensions/regress-355052-03.js new file mode 100644 index 000000000..e987101fb --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-355052-03.js @@ -0,0 +1,43 @@ +/* -*- 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() +{ + enterFunc ('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); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-355410.js b/js/src/tests/js1_7/extensions/regress-355410.js new file mode 100644 index 000000000..6b00b704f --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-355410.js @@ -0,0 +1,40 @@ +/* -*- 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() +{ + enterFunc ('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); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-355512.js b/js/src/tests/js1_7/extensions/regress-355512.js new file mode 100644 index 000000000..554242382 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-355512.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 = 355512; +var summary = 'Do not crash with generator arguments'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + function foopy() + { + var f = function(){ r = arguments; d.d.d; yield 170; } + try { for (var i in f()) { } } catch (iterError) { } + } + + typeof uneval; + foopy(); + gc(); + uneval(r); + gc(); + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-363040-01.js b/js/src/tests/js1_7/extensions/regress-363040-01.js new file mode 100644 index 000000000..5b89b4e81 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-363040-01.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 = 363040; +var summary = 'Array.prototype.reduce application in continued fraction'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('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(uneval(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 each (num in [Math.PI, Math.sqrt(2), 1 / (Math.sqrt(Math.E) - 1)]) { + print('Continued fractions for', num); + for each (eps in [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(uneval(frac), est, err); + } + print(); + } + } + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-363040-02.js b/js/src/tests/js1_7/extensions/regress-363040-02.js new file mode 100644 index 000000000..ea163790a --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-363040-02.js @@ -0,0 +1,64 @@ +/* -*- 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() +{ + enterFunc ('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(uneval(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 each (num in [Math.PI, Math.sqrt(2), 1 / (Math.sqrt(Math.E) - 1)]) { + print('Continued fractions for', num); + for each (eps in [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(uneval(frac), est, err); + } + print(); + } + } + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-366668-01.js b/js/src/tests/js1_7/extensions/regress-366668-01.js new file mode 100644 index 000000000..92d01e800 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-366668-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 = 366668; +var summary = 'decompilation of "for (let x in x.p)" '; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('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); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-367629.js b/js/src/tests/js1_7/extensions/regress-367629.js new file mode 100644 index 000000000..7808701cb --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-367629.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 = 367629; +var summary = 'Decompilation of result with native function as getter'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + var a = + Object.defineProperty({}, "h", + { + get: encodeURI, + enumerable: true, + configurable: true + }); + + expect = '({get h() {[native code]}})'; + actual = uneval(a); + + compareSource(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-368213.js b/js/src/tests/js1_7/extensions/regress-368213.js new file mode 100644 index 000000000..c1f9be735 --- /dev/null +++ b/js/src/tests/js1_7/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/js1_7/extensions/regress-368224.js b/js/src/tests/js1_7/extensions/regress-368224.js new file mode 100644 index 000000000..234f26856 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-368224.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 = 368224; +var summary = 'Do not assert: pnprop->pn_type == TOK_COLON'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + ({ x: a } = {}); + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-372364.js b/js/src/tests/js1_7/extensions/regress-372364.js new file mode 100644 index 000000000..ed641045f --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-372364.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 = 372364; +var summary = 'Do not recurse to death on (function() { yield ([15].some([].watch)); })().next()'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + print('FIXME: Fix this test to check the proper error when bug 366669 is fixed'); + try + { + (function() { yield ([15].some([].watch)); })().next(); + } + catch(ex) + { + } + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-379566.js b/js/src/tests/js1_7/extensions/regress-379566.js new file mode 100644 index 000000000..73f80ce04 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-379566.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 = 379566; +var summary = 'Keywords after get|set'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('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); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-380933.js b/js/src/tests/js1_7/extensions/regress-380933.js new file mode 100644 index 000000000..09f64209d --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-380933.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 = 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/js1_7/extensions/regress-381301.js b/js/src/tests/js1_7/extensions/regress-381301.js new file mode 100644 index 000000000..e69009b80 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-381301.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 = 381301; +var summary = 'uneval of object with native-function getter'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + var o = + Object.defineProperty({}, "x", { get: decodeURI, enumerable: true, configurable: true }); + expect = '( { get x ( ) { [ native code ] } } )'; + actual = uneval(o); + + compareSource(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-381303.js b/js/src/tests/js1_7/extensions/regress-381303.js new file mode 100644 index 000000000..40c9dbdef --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-381303.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 = 381303; +var summary = 'object toSource when a property has both a getter and a setter'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('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); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-387955-01.js b/js/src/tests/js1_7/extensions/regress-387955-01.js new file mode 100644 index 000000000..e3af18401 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-387955-01.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 = 387955; +var summary = 'Do not Crash [@ TraceEdge]'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + var fal = false; + + function gen() { + let x; + function y(){} + this.__defineGetter__('', function(){}); + if (fal) + yield; + } + + for (var i in gen()) { } + + gc(); + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-387955-02.js b/js/src/tests/js1_7/extensions/regress-387955-02.js new file mode 100644 index 000000000..dc3b795b6 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-387955-02.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 = 387955; +var summary = 'Do not Crash [@ TraceEdge]'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + var f; + + function gen(yield_at_least_once) { + let x = 11; + function y(){} + f = function(){ return x; }; + if (yield_at_least_once) + yield; + } + + for (var i in gen()) { } + + if (f() !== 11) + throw "unexpected value of local x"; + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-392308.js b/js/src/tests/js1_7/extensions/regress-392308.js new file mode 100644 index 000000000..7d4c9e1d9 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-392308.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 = 392308; +var summary = 'StopIteration should be catchable'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + function testStop() { + function yielder() { + actual += 'before, '; + yield; + actual += 'after, '; + } + + expect = 'before, after, iteration terminated normally'; + + try { + var gen = yielder(); + result = gen.next(); + gen.send(result); + } catch (x if x instanceof StopIteration) { + actual += 'iteration terminated normally'; + } catch (x2) { + actual += 'unexpected throw: ' + x2; + } + } + testStop(); + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-396326.js b/js/src/tests/js1_7/extensions/regress-396326.js new file mode 100644 index 000000000..2a26e5350 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-396326.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 = 396326; +var summary = 'Do not assert trying to disassemble get(var|arg) prop'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('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 };'); + } + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-453955.js b/js/src/tests/js1_7/extensions/regress-453955.js new file mode 100644 index 000000000..454f712f3 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-453955.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 = 453955; +var summary = 'Do not assert: sprop->setter != js_watch_set || pobj != obj'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + for (var z = 0; z < 2; ++z) + { + [].filter.watch("9", function(y) { yield y; }); + } + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-458679.js b/js/src/tests/js1_7/extensions/regress-458679.js new file mode 100644 index 000000000..d87d23512 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-458679.js @@ -0,0 +1,52 @@ +// |reftest| skip-if(!xulRuntime.shell||xulRuntime.shell&&xulRuntime.XPCOMABI.match(/x86_64/)) 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 = 458679; +var summary = 'Do not assert: nbytes != 0'; +var actual = ''; +var expect = ''; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +function f() +{ + for (var i = 1; i < dps.length; ++i) { + var a = ""; + var b = ""; + var c = ""; + } +} + +function stringOfLength(n) +{ + if (n == 0) { + return ""; + } else if (n == 1) { + return "\""; + } else { + var r = n % 2; + var d = (n - r) / 2; + var y = stringOfLength(d); + return y + y + stringOfLength(r); + } +} + +try +{ + this.__defineGetter__('x', this.toSource); + while (x.length < 12000000) { + let q = x; + s = q + q; + } + print(x.length); +} +catch(ex) +{ +} + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/js1_7/extensions/regress-469234.js b/js/src/tests/js1_7/extensions/regress-469234.js new file mode 100644 index 000000000..52ca30bf0 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-469234.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 = 469234; +var summary = 'TM: Do not assert: !JS_ON_TRACE(cx)'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + + for(var j=0;j<3;++j)({__proto__:[]}).__defineSetter__('x',function(){}); + + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-469405-01.js b/js/src/tests/js1_7/extensions/regress-469405-01.js new file mode 100644 index 000000000..82172c3d3 --- /dev/null +++ b/js/src/tests/js1_7/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 each (a in [{}, {__iterator__: function(){}}]) for (b in a) { } + })(); +} +catch(ex) +{ + print('caught ' + ex); +} + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/js1_7/extensions/regress-469405-02.js b/js/src/tests/js1_7/extensions/regress-469405-02.js new file mode 100644 index 000000000..196557e69 --- /dev/null +++ b/js/src/tests/js1_7/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/js1_7/extensions/regress-470300-01.js b/js/src/tests/js1_7/extensions/regress-470300-01.js new file mode 100644 index 000000000..6558330d1 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-470300-01.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 = 470300; +var summary = 'TM: Do not assert: StackBase(fp) + blockDepth == regs.sp'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + + for (let a = 0; a < 3; ++a) { let b = '' + []; } + + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-470300-02.js b/js/src/tests/js1_7/extensions/regress-470300-02.js new file mode 100644 index 000000000..0ecd368ff --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-470300-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 = 470300; +var summary = 'TM: Do not assert: !fp->blockChain || OBJ_GET_PARENT(cx, obj) == fp->blockChain'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + + for (let a = 0; a < 7; ++a) { let e = 8; if (a > 3) { let x; } } + + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-473282.js b/js/src/tests/js1_7/extensions/regress-473282.js new file mode 100644 index 000000000..c50ac9234 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-473282.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 = 473282; +var summary = 'Do not assert: thing'; +var actual = ''; +var expect = ''; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +this.watch("b", "".substring); +this.__defineGetter__("a", gc); +for each (b in [this, null, null]); +a; + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/js1_7/extensions/regress-474771-01.js b/js/src/tests/js1_7/extensions/regress-474771-01.js new file mode 100644 index 000000000..ca754ba2c --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-474771-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 = 474771; +var summary = 'TM: do not assert: jumpTable == interruptJumpTable'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('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); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-474771-02.js b/js/src/tests/js1_7/extensions/regress-474771-02.js new file mode 100644 index 000000000..127351858 --- /dev/null +++ b/js/src/tests/js1_7/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/js1_7/extensions/regress-476257.js b/js/src/tests/js1_7/extensions/regress-476257.js new file mode 100644 index 000000000..6f2852590 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-476257.js @@ -0,0 +1,57 @@ +// |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 = 476257; +var summary = 'Do not assert: !JS_ON_TRACE(cx)'; +var actual = ''; +var expect = ''; + +printBugNumber(BUGNUMBER); +printStatus (summary); + + +function f1() { + try + { + Object.defineProperty(__proto__, "functional", + { + enumerable: true, configurable: true, + get: function () + { + if (typeof gczeal == 'function') { gczeal(0); } + } + }); + for each (let [[]] in [true, new Boolean(true), new Boolean(true)]) {} + } + catch(ex) + { + } +} + +function f2() { + try + { + Object.defineProperty(__proto__, "functional", + { + enumerable: true, configurable: true, + get: function () + { + if (typeof dis == 'function') { dis(); } + } + }); + for each (let [[]] in [true, new Boolean(true), new Boolean(true)]) {} + } + catch(ex) + { + } +} + +f1(); +f2(); + + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/js1_7/extensions/regress-477048.js b/js/src/tests/js1_7/extensions/regress-477048.js new file mode 100644 index 000000000..638f9f035 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-477048.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 = 477048; +var summary = 'Do not assert: cg->stackDepth == loopDepth'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + try + { + for each (this.__proto__ in x) {} + } + catch(ex) + { + } + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-589112.js b/js/src/tests/js1_7/extensions/regress-589112.js new file mode 100644 index 000000000..db6d1c7c0 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-589112.js @@ -0,0 +1,6 @@ + +f = eval("(function(){return x=Iterator(/x/)})") +for (a in f()) {} +for (d in x) {} + +reportCompare(0, 0, ""); diff --git a/js/src/tests/js1_7/extensions/regress-590813.js b/js/src/tests/js1_7/extensions/regress-590813.js new file mode 100644 index 000000000..ec701ced5 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-590813.js @@ -0,0 +1,23 @@ + +var actual = ''; +var expected = 'A0B1B2C0C1C2'; + +var x = Iterator([1,2,3], true); + +for (var a in x) { + actual += 'A' + a; + for (var b in x) { + actual += 'B' + b; + } +} + +var y = Iterator([1,2,3], true); + +for (var c in y) { + actual += 'C' + c; +} +for (var d in y) { + actual += 'D' + d; +} + +reportCompare(expected, actual, "Handle nested Iterator iteration right"); diff --git a/js/src/tests/js1_7/extensions/regress-591450.js b/js/src/tests/js1_7/extensions/regress-591450.js new file mode 100644 index 000000000..f1ebcf675 --- /dev/null +++ b/js/src/tests/js1_7/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/js1_7/extensions/shell.js b/js/src/tests/js1_7/extensions/shell.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/js1_7/extensions/shell.js |