mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-01 06:35:42 +00:00
Bug 537873: Re-enable tests for assignments to array lengths in strict mode; add new regression tests. r=brendan
This commit is contained in:
parent
5e80fa16dc
commit
ed912e0cbe
@ -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
|
||||
|
41
js/src/tests/ecma_5/extensions/watch-array-length.js
Normal file
41
js/src/tests/ecma_5/extensions/watch-array-length.js
Normal file
@ -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");
|
@ -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
|
||||
|
33
js/src/tests/ecma_5/strict/regress-599159.js
Normal file
33
js/src/tests/ecma_5/strict/regress-599159.js
Normal file
@ -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);
|
Loading…
Reference in New Issue
Block a user