diff --git a/js/src/tests/ecma_5/extensions/jstests.list b/js/src/tests/ecma_5/extensions/jstests.list index 427cfea606b9..962f4ee99078 100644 --- a/js/src/tests/ecma_5/extensions/jstests.list +++ b/js/src/tests/ecma_5/extensions/jstests.list @@ -22,6 +22,7 @@ script strict-function-statements.js script strict-option-redeclared-parameter.js script string-literal-getter-setter-decompilation.js script uneval-strict-functions.js +script watch-array-length.js script watch-inherited-property.js script watch-replaced-setter.js script watch-setter-become-setter.js diff --git a/js/src/tests/ecma_5/extensions/watch-array-length.js b/js/src/tests/ecma_5/extensions/watch-array-length.js new file mode 100644 index 000000000000..e9b356efa514 --- /dev/null +++ b/js/src/tests/ecma_5/extensions/watch-array-length.js @@ -0,0 +1,41 @@ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +var hitCount; +function watcher(p,o,n) { hitCount++; return n; } + +var a = [1]; +a.watch('length', watcher); +hitCount = 0; +a.length = 0; +reportCompare(1, hitCount, "lenient; configurable: watchpoint hit"); + +var b = Object.defineProperty([1],'0',{configurable:false}); +b.watch('length', watcher); +hitCount = 0; +var result; +try { + b.length = 0; + result = "no error"; +} catch (x) { + result = x.toString(); +} +reportCompare(1, hitCount, "lenient; non-configurable: watchpoint hit"); +reportCompare(1, b.length, "lenient; non-configurable: length unchanged"); +reportCompare("no error", result, "lenient; non-configurable: no error thrown"); + +var c = Object.defineProperty([1],'0',{configurable:false}); +c.watch('length', watcher); +hitCount = 0; +var threwTypeError; +try { + (function(){'use strict'; c.length = 0;})(); + threwTypeError = false; +} catch (x) { + threwTypeError = x instanceof TypeError; +} +reportCompare(1, hitCount, "strict; non-configurable: watchpoint hit"); +reportCompare(1, c.length, "strict; non-configurable: length unchanged"); +reportCompare(true, threwTypeError, "strict; non-configurable: TypeError thrown"); diff --git a/js/src/tests/ecma_5/strict/jstests.list b/js/src/tests/ecma_5/strict/jstests.list index 114265f807e7..5049b8a77ee7 100644 --- a/js/src/tests/ecma_5/strict/jstests.list +++ b/js/src/tests/ecma_5/strict/jstests.list @@ -25,7 +25,7 @@ script 15.4.4.8.js script 15.4.4.9.js script 15.4.4.12.js script 15.4.4.13.js -skip script 15.4.5.1.js # Waiting for bug 537873 to be fully resolved. +script 15.4.5.1.js script 15.5.5.1.js script 15.5.5.2.js script 15.10.7.js @@ -35,6 +35,7 @@ script function-name-arity.js script primitive-this-no-writeback.js script regress-532254.js script regress-532041.js +script regress-599159.js script unbrand-this.js script this-for-function-expression-recursion.js script assign-to-callee-name.js diff --git a/js/src/tests/ecma_5/strict/regress-599159.js b/js/src/tests/ecma_5/strict/regress-599159.js new file mode 100644 index 000000000000..c29b0ebdc154 --- /dev/null +++ b/js/src/tests/ecma_5/strict/regress-599159.js @@ -0,0 +1,33 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ + +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +// Shu's test +function test(makeNonArray) { + function C() {} + C.prototype = [] + if (makeNonArray) + C.prototype.constructor = C + c = new C(); + c.push("foo"); + return c.length +} +assertEq(test(true), 1); +assertEq(test(false), 1); + +// jorendorff's longer test +var a = []; +a.slowify = 1; +var b = Object.create(a); +b.length = 12; +assertEq(b.length, 12); + +// jorendorff's shorter test +var b = Object.create(Array.prototype); +b.length = 12; +assertEq(b.length, 12); + +reportCompare(true, true);