diff --git a/js/src/tests/ecma_5/Object/15.2.3.6-dictionary-redefinition-1-of-8.js b/js/src/tests/ecma_5/Object/15.2.3.6-dictionary-redefinition-1-of-8.js new file mode 100644 index 000000000000..ff31648b9a80 --- /dev/null +++ b/js/src/tests/ecma_5/Object/15.2.3.6-dictionary-redefinition-1-of-8.js @@ -0,0 +1,5 @@ +// Any copyright is dedicated to the Public Domain. +// http://creativecommons.org/licenses/publicdomain/ + +load("ecma_5/Object/defineProperty-setup.js"); +runDictionaryPropertyPresentTestsFraction(1, 8); diff --git a/js/src/tests/ecma_5/Object/15.2.3.6-dictionary-redefinition-2-of-8.js b/js/src/tests/ecma_5/Object/15.2.3.6-dictionary-redefinition-2-of-8.js new file mode 100644 index 000000000000..55f4b0da6441 --- /dev/null +++ b/js/src/tests/ecma_5/Object/15.2.3.6-dictionary-redefinition-2-of-8.js @@ -0,0 +1,5 @@ +// Any copyright is dedicated to the Public Domain. +// http://creativecommons.org/licenses/publicdomain/ + +load("ecma_5/Object/defineProperty-setup.js"); +runDictionaryPropertyPresentTestsFraction(2, 8); diff --git a/js/src/tests/ecma_5/Object/15.2.3.6-dictionary-redefinition-3-of-8.js b/js/src/tests/ecma_5/Object/15.2.3.6-dictionary-redefinition-3-of-8.js new file mode 100644 index 000000000000..70faf015e415 --- /dev/null +++ b/js/src/tests/ecma_5/Object/15.2.3.6-dictionary-redefinition-3-of-8.js @@ -0,0 +1,5 @@ +// Any copyright is dedicated to the Public Domain. +// http://creativecommons.org/licenses/publicdomain/ + +load("ecma_5/Object/defineProperty-setup.js"); +runDictionaryPropertyPresentTestsFraction(3, 8); diff --git a/js/src/tests/ecma_5/Object/15.2.3.6-dictionary-redefinition-4-of-8.js b/js/src/tests/ecma_5/Object/15.2.3.6-dictionary-redefinition-4-of-8.js new file mode 100644 index 000000000000..ef4ca378672b --- /dev/null +++ b/js/src/tests/ecma_5/Object/15.2.3.6-dictionary-redefinition-4-of-8.js @@ -0,0 +1,5 @@ +// Any copyright is dedicated to the Public Domain. +// http://creativecommons.org/licenses/publicdomain/ + +load("ecma_5/Object/defineProperty-setup.js"); +runDictionaryPropertyPresentTestsFraction(4, 8); diff --git a/js/src/tests/ecma_5/Object/15.2.3.6-dictionary-redefinition-5-of-8.js b/js/src/tests/ecma_5/Object/15.2.3.6-dictionary-redefinition-5-of-8.js new file mode 100644 index 000000000000..c2be22b97e89 --- /dev/null +++ b/js/src/tests/ecma_5/Object/15.2.3.6-dictionary-redefinition-5-of-8.js @@ -0,0 +1,5 @@ +// Any copyright is dedicated to the Public Domain. +// http://creativecommons.org/licenses/publicdomain/ + +load("ecma_5/Object/defineProperty-setup.js"); +runDictionaryPropertyPresentTestsFraction(5, 8); diff --git a/js/src/tests/ecma_5/Object/15.2.3.6-dictionary-redefinition-6-of-8.js b/js/src/tests/ecma_5/Object/15.2.3.6-dictionary-redefinition-6-of-8.js new file mode 100644 index 000000000000..8b62151f3916 --- /dev/null +++ b/js/src/tests/ecma_5/Object/15.2.3.6-dictionary-redefinition-6-of-8.js @@ -0,0 +1,5 @@ +// Any copyright is dedicated to the Public Domain. +// http://creativecommons.org/licenses/publicdomain/ + +load("ecma_5/Object/defineProperty-setup.js"); +runDictionaryPropertyPresentTestsFraction(6, 8); diff --git a/js/src/tests/ecma_5/Object/15.2.3.6-dictionary-redefinition-7-of-8.js b/js/src/tests/ecma_5/Object/15.2.3.6-dictionary-redefinition-7-of-8.js new file mode 100644 index 000000000000..ab41c070e255 --- /dev/null +++ b/js/src/tests/ecma_5/Object/15.2.3.6-dictionary-redefinition-7-of-8.js @@ -0,0 +1,5 @@ +// Any copyright is dedicated to the Public Domain. +// http://creativecommons.org/licenses/publicdomain/ + +load("ecma_5/Object/defineProperty-setup.js"); +runDictionaryPropertyPresentTestsFraction(7, 8); diff --git a/js/src/tests/ecma_5/Object/15.2.3.6-dictionary-redefinition-8-of-8.js b/js/src/tests/ecma_5/Object/15.2.3.6-dictionary-redefinition-8-of-8.js new file mode 100644 index 000000000000..1d5b57672db0 --- /dev/null +++ b/js/src/tests/ecma_5/Object/15.2.3.6-dictionary-redefinition-8-of-8.js @@ -0,0 +1,5 @@ +// Any copyright is dedicated to the Public Domain. +// http://creativecommons.org/licenses/publicdomain/ + +load("ecma_5/Object/defineProperty-setup.js"); +runDictionaryPropertyPresentTestsFraction(8, 8); diff --git a/js/src/tests/ecma_5/Object/15.2.3.6-middle-redefinition-1-of-8.js b/js/src/tests/ecma_5/Object/15.2.3.6-middle-redefinition-1-of-8.js new file mode 100644 index 000000000000..4d310ea4a1a1 --- /dev/null +++ b/js/src/tests/ecma_5/Object/15.2.3.6-middle-redefinition-1-of-8.js @@ -0,0 +1,5 @@ +// Any copyright is dedicated to the Public Domain. +// http://creativecommons.org/licenses/publicdomain/ + +load("ecma_5/Object/defineProperty-setup.js"); +runNonTerminalPropertyPresentTestsFraction(1, 8); diff --git a/js/src/tests/ecma_5/Object/15.2.3.6-middle-redefinition-2-of-8.js b/js/src/tests/ecma_5/Object/15.2.3.6-middle-redefinition-2-of-8.js new file mode 100644 index 000000000000..40b5c48a113b --- /dev/null +++ b/js/src/tests/ecma_5/Object/15.2.3.6-middle-redefinition-2-of-8.js @@ -0,0 +1,5 @@ +// Any copyright is dedicated to the Public Domain. +// http://creativecommons.org/licenses/publicdomain/ + +load("ecma_5/Object/defineProperty-setup.js"); +runNonTerminalPropertyPresentTestsFraction(2, 8); diff --git a/js/src/tests/ecma_5/Object/15.2.3.6-middle-redefinition-3-of-8.js b/js/src/tests/ecma_5/Object/15.2.3.6-middle-redefinition-3-of-8.js new file mode 100644 index 000000000000..fb75c7779fbb --- /dev/null +++ b/js/src/tests/ecma_5/Object/15.2.3.6-middle-redefinition-3-of-8.js @@ -0,0 +1,5 @@ +// Any copyright is dedicated to the Public Domain. +// http://creativecommons.org/licenses/publicdomain/ + +load("ecma_5/Object/defineProperty-setup.js"); +runNonTerminalPropertyPresentTestsFraction(3, 8); diff --git a/js/src/tests/ecma_5/Object/15.2.3.6-middle-redefinition-4-of-8.js b/js/src/tests/ecma_5/Object/15.2.3.6-middle-redefinition-4-of-8.js new file mode 100644 index 000000000000..73e5d412152b --- /dev/null +++ b/js/src/tests/ecma_5/Object/15.2.3.6-middle-redefinition-4-of-8.js @@ -0,0 +1,5 @@ +// Any copyright is dedicated to the Public Domain. +// http://creativecommons.org/licenses/publicdomain/ + +load("ecma_5/Object/defineProperty-setup.js"); +runNonTerminalPropertyPresentTestsFraction(4, 8); diff --git a/js/src/tests/ecma_5/Object/15.2.3.6-middle-redefinition-5-of-8.js b/js/src/tests/ecma_5/Object/15.2.3.6-middle-redefinition-5-of-8.js new file mode 100644 index 000000000000..d5b90167c77d --- /dev/null +++ b/js/src/tests/ecma_5/Object/15.2.3.6-middle-redefinition-5-of-8.js @@ -0,0 +1,5 @@ +// Any copyright is dedicated to the Public Domain. +// http://creativecommons.org/licenses/publicdomain/ + +load("ecma_5/Object/defineProperty-setup.js"); +runNonTerminalPropertyPresentTestsFraction(5, 8); diff --git a/js/src/tests/ecma_5/Object/15.2.3.6-middle-redefinition-6-of-8.js b/js/src/tests/ecma_5/Object/15.2.3.6-middle-redefinition-6-of-8.js new file mode 100644 index 000000000000..0757ba186f2b --- /dev/null +++ b/js/src/tests/ecma_5/Object/15.2.3.6-middle-redefinition-6-of-8.js @@ -0,0 +1,5 @@ +// Any copyright is dedicated to the Public Domain. +// http://creativecommons.org/licenses/publicdomain/ + +load("ecma_5/Object/defineProperty-setup.js"); +runNonTerminalPropertyPresentTestsFraction(6, 8); diff --git a/js/src/tests/ecma_5/Object/15.2.3.6-middle-redefinition-7-of-8.js b/js/src/tests/ecma_5/Object/15.2.3.6-middle-redefinition-7-of-8.js new file mode 100644 index 000000000000..ecdb3a8d70ab --- /dev/null +++ b/js/src/tests/ecma_5/Object/15.2.3.6-middle-redefinition-7-of-8.js @@ -0,0 +1,5 @@ +// Any copyright is dedicated to the Public Domain. +// http://creativecommons.org/licenses/publicdomain/ + +load("ecma_5/Object/defineProperty-setup.js"); +runNonTerminalPropertyPresentTestsFraction(7, 8); diff --git a/js/src/tests/ecma_5/Object/15.2.3.6-middle-redefinition-8-of-8.js b/js/src/tests/ecma_5/Object/15.2.3.6-middle-redefinition-8-of-8.js new file mode 100644 index 000000000000..86b410398ece --- /dev/null +++ b/js/src/tests/ecma_5/Object/15.2.3.6-middle-redefinition-8-of-8.js @@ -0,0 +1,5 @@ +// Any copyright is dedicated to the Public Domain. +// http://creativecommons.org/licenses/publicdomain/ + +load("ecma_5/Object/defineProperty-setup.js"); +runNonTerminalPropertyPresentTestsFraction(8, 8); diff --git a/js/src/tests/ecma_5/Object/defineProperty-setup.js b/js/src/tests/ecma_5/Object/defineProperty-setup.js index d707fc2afd6a..f4240eb8edac 100644 --- a/js/src/tests/ecma_5/Object/defineProperty-setup.js +++ b/js/src/tests/ecma_5/Object/defineProperty-setup.js @@ -578,7 +578,7 @@ TestRunner.prototype = print("Starting test with old descriptor " + old.toSource() + "..."); for (var j = 0, sz2 = VALID_DESCRIPTORS.length; j < sz2; j++) - self._runSinglePropertyPresentTest(old, VALID_DESCRIPTORS[j]); + self._runSinglePropertyPresentTest(old, VALID_DESCRIPTORS[j], []); } } @@ -587,6 +587,107 @@ TestRunner.prototype = " completed!"); }, + runNonTerminalPropertyPresentTestsFraction: + function runNonTerminalPropertyPresentTestsFraction(part, parts) + { + var self = this; + + /* + * A plain old property to define on the object before redefining the + * originally-added property, to test redefinition of a property that's + * not also lastProperty. NB: we could loop over every possible + * descriptor here if we wanted, even try adding more than one, but we'd + * hit cubic complexity and worse, and SpiderMonkey only distinguishes by + * the mere presence of the middle property, not its precise details. + */ + var middleDefines = + [{ + property: "middle", + descriptor: + { value: 17, writable: true, configurable: true, enumerable: true } + }]; + + function nonTerminalPropertyPresentTests() + { + print("Running non-terminal already-present tests now..."); + + var total = VALID_DESCRIPTORS.length; + var start = Math.floor((part - 1) / parts * total); + var end = Math.floor(part / parts * total); + + for (var i = start; i < end; i++) + { + var old = VALID_DESCRIPTORS[i]; + print("Starting test with old descriptor " + old.toSource() + "..."); + + for (var j = 0, sz2 = VALID_DESCRIPTORS.length; j < sz2; j++) + { + self._runSinglePropertyPresentTest(old, VALID_DESCRIPTORS[j], + middleDefines); + } + } + } + + this._runTestSet(nonTerminalPropertyPresentTests, + "Non-terminal property-present fraction " + + part + " of " + parts + " completed!"); + }, + + runDictionaryPropertyPresentTestsFraction: + function runDictionaryPropertyPresentTestsFraction(part, parts) + { + var self = this; + + /* + * Add and readd properties such that the scope for the object is in + * dictionary mode. + */ + var middleDefines = + [ + { + property: "mid1", + descriptor: + { value: 17, writable: true, configurable: true, enumerable: true } + }, + { + property: "mid2", + descriptor: + { value: 17, writable: true, configurable: true, enumerable: true } + }, + { + property: "mid1", + descriptor: + { get: function g() { }, set: function s(v){}, configurable: false, + enumerable: true } + }, + ]; + + function dictionaryPropertyPresentTests() + { + print("Running dictionary already-present tests now..."); + + var total = VALID_DESCRIPTORS.length; + var start = Math.floor((part - 1) / parts * total); + var end = Math.floor(part / parts * total); + + for (var i = start; i < end; i++) + { + var old = VALID_DESCRIPTORS[i]; + print("Starting test with old descriptor " + old.toSource() + "..."); + + for (var j = 0, sz2 = VALID_DESCRIPTORS.length; j < sz2; j++) + { + self._runSinglePropertyPresentTest(old, VALID_DESCRIPTORS[j], + middleDefines); + } + } + } + + this._runTestSet(dictionaryPropertyPresentTests, + "Dictionary property-present fraction " + + part + " of " + parts + " completed!"); + }, + // HELPERS @@ -600,7 +701,7 @@ TestRunner.prototype = print("Starting test with old descriptor " + old.toSource() + "..."); for (var j = 0, sz2 = VALID_DESCRIPTORS.length; j < sz2; j++) - this._runSinglePropertyPresentTest(old, VALID_DESCRIPTORS[j]); + this._runSinglePropertyPresentTest(old, VALID_DESCRIPTORS[j], []); } }, _runTestSet: function _runTestSet(fun, completeMessage) @@ -724,7 +825,8 @@ TestRunner.prototype = return; } }, - _runSinglePropertyPresentTest: function _runSinglePropertyPresentTest(old, add) + _runSinglePropertyPresentTest: + function _runSinglePropertyPresentTest(old, add, middleDefines) { var nativeObj = NativeTest.newObject(); var reimplObj = ReimplTest.newObject(); @@ -781,6 +883,35 @@ TestRunner.prototype = return; } + // Now add (or even readd) however many properties were specified between + // the original property to add and the new one, to test redefining + // non-last-properties and properties in scopes in dictionary mode. + for (var i = 0, sz = middleDefines.length; i < sz; i++) + { + var middle = middleDefines[i]; + var prop = middle.property; + var desc = middle.descriptor; + + try + { + NativeTest.defineProperty(nativeObj, prop, desc); + ReimplTest.defineProperty(reimplObj, prop, desc); + } + catch (e) + { + this._log("failure defining middle descriptor: " + desc.toSource() + + ", error " + e); + return; + } + + // Sanity check + var nativeDesc = NativeTest.getDescriptor(nativeObj, prop); + var reimplDesc = ReimplTest.getDescriptor(reimplObj, prop); + + compareDescriptors(nativeDesc, reimplDesc); + compareDescriptors(nativeDesc, desc); + } + try { NativeTest.defineProperty(nativeObj, "foo", add); @@ -900,3 +1031,72 @@ TestRunner.prototype = } } }; + +function runDictionaryPropertyPresentTestsFraction(PART, PARTS) +{ + var testfile = + '15.2.3.6-dictionary-redefinition-' + PART + '-of-' + PARTS + '.js'; + var BUGNUMBER = 560566; + var summary = + 'ES5 Object.defineProperty(O, P, Attributes): dictionary redefinition ' + + PART + ' of ' + PARTS; + + print(BUGNUMBER + ": " + summary); + + try + { + new TestRunner().runDictionaryPropertyPresentTestsFraction(PART, PARTS); + } + catch (e) + { + throw "Error thrown during testing: " + e + + " at line " + e.lineNumber + "\n" + + (e.stack + ? "Stack: " + e.stack.split("\n").slice(2).join("\n") + "\n" + : ""); + } + + if (typeof reportCompare === "function") + reportCompare(true, true); + + print("Tests complete!"); +} + +function runNonTerminalPropertyPresentTestsFraction(PART, PARTS) +{ + var PART = 1, PARTS = 4; + + var gTestfile = + '15.2.3.6-middle-redefinition-' + PART + '-of-' + PARTS + '.js'; + var BUGNUMBER = 560566; + var summary = + 'ES5 Object.defineProperty(O, P, Attributes): middle redefinition ' + + PART + ' of ' + PARTS; + + print(BUGNUMBER + ": " + summary); + + + /************** + * BEGIN TEST * + **************/ + + try + { + new TestRunner().runNonTerminalPropertyPresentTestsFraction(PART, PARTS); + } + catch (e) + { + throw "Error thrown during testing: " + e + + " at line " + e.lineNumber + "\n" + + (e.stack + ? "Stack: " + e.stack.split("\n").slice(2).join("\n") + "\n" + : ""); + } + + /******************************************************************************/ + + if (typeof reportCompare === "function") + reportCompare(true, true); + + print("Tests complete!"); +} diff --git a/js/src/tests/ecma_5/Object/jstests.list b/js/src/tests/ecma_5/Object/jstests.list index 92e6d293c87e..07ae554be779 100644 --- a/js/src/tests/ecma_5/Object/jstests.list +++ b/js/src/tests/ecma_5/Object/jstests.list @@ -11,3 +11,19 @@ skip-if(!xulRuntime.shell) script 15.2.3.6-redefinition-3-of-4.js # uses shell l skip-if(!xulRuntime.shell) script 15.2.3.6-redefinition-4-of-4.js # uses shell load() function script 15.2.3.7-01.js script 15.2.3.14-01.js # does not use reportCompare +skip-if(!xulRuntime.shell) script 15.2.3.6-middle-redefinition-1-of-8.js # uses shell load() function +skip-if(!xulRuntime.shell) script 15.2.3.6-middle-redefinition-2-of-8.js # uses shell load() function +skip-if(!xulRuntime.shell) script 15.2.3.6-middle-redefinition-3-of-8.js # uses shell load() function +skip-if(!xulRuntime.shell) script 15.2.3.6-middle-redefinition-4-of-8.js # uses shell load() function +skip-if(!xulRuntime.shell) script 15.2.3.6-middle-redefinition-5-of-8.js # uses shell load() function +skip-if(!xulRuntime.shell) script 15.2.3.6-middle-redefinition-6-of-8.js # uses shell load() function +skip-if(!xulRuntime.shell) script 15.2.3.6-middle-redefinition-7-of-8.js # uses shell load() function +skip-if(!xulRuntime.shell) script 15.2.3.6-middle-redefinition-8-of-8.js # uses shell load() function +skip-if(!xulRuntime.shell) script 15.2.3.6-dictionary-redefinition-1-of-8.js # uses shell load() function +skip-if(!xulRuntime.shell) script 15.2.3.6-dictionary-redefinition-2-of-8.js # uses shell load() function +skip-if(!xulRuntime.shell) script 15.2.3.6-dictionary-redefinition-3-of-8.js # uses shell load() function +skip-if(!xulRuntime.shell) script 15.2.3.6-dictionary-redefinition-4-of-8.js # uses shell load() function +skip-if(!xulRuntime.shell) script 15.2.3.6-dictionary-redefinition-5-of-8.js # uses shell load() function +skip-if(!xulRuntime.shell) script 15.2.3.6-dictionary-redefinition-6-of-8.js # uses shell load() function +skip-if(!xulRuntime.shell) script 15.2.3.6-dictionary-redefinition-7-of-8.js # uses shell load() function +skip-if(!xulRuntime.shell) script 15.2.3.6-dictionary-redefinition-8-of-8.js # uses shell load() function