diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/non262/object/15.2.3.6-miscellaneous.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | js/src/tests/non262/object/15.2.3.6-miscellaneous.js | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/js/src/tests/non262/object/15.2.3.6-miscellaneous.js b/js/src/tests/non262/object/15.2.3.6-miscellaneous.js new file mode 100644 index 0000000000..9f671c52ce --- /dev/null +++ b/js/src/tests/non262/object/15.2.3.6-miscellaneous.js @@ -0,0 +1,74 @@ +// Any copyright is dedicated to the Public Domain. +// http://creativecommons.org/licenses/publicdomain/ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 430133; +var summary = 'ES5 Object.defineProperty(O, P, Attributes)'; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +var o = []; +Object.defineProperty(o, 0, { value: 17 }); +var desc = Object.getOwnPropertyDescriptor(o, 0); +assertEq(desc !== undefined, true); +assertEq(desc.value, 17); +assertEq(desc.enumerable, false); +assertEq(desc.configurable, false); +assertEq(desc.writable, false); + +desc = Object.getOwnPropertyDescriptor(o, "length"); +assertEq(desc !== undefined, true); +assertEq(desc.enumerable, false); +assertEq(desc.configurable, false); +assertEq(desc.writable, true); +assertEq(desc.value, 1); +assertEq(o.length, 1); + +Object.defineProperty(o, "foobar", + { value: 42, enumerable: false, configurable: true }); +assertEq(o.foobar, 42); +desc = Object.getOwnPropertyDescriptor(o, "foobar"); +assertEq(desc !== undefined, true); +assertEq(desc.value, 42); +assertEq(desc.configurable, true); +assertEq(desc.enumerable, false); +assertEq(desc.writable, false); + +var called = false; +o = { set x(a) { called = true; } }; +Object.defineProperty(o, "x", { get: function() { return "get"; } }); +desc = Object.getOwnPropertyDescriptor(o, "x"); +assertEq("set" in desc, true); +assertEq("get" in desc, true); +assertEq(called, false); +o.x = 13; +assertEq(called, true); + +var toSource = Object.prototype.toSource || function() { }; +toSource.call(o); // a test for this not crashing + +var called = false; +var o = + Object.defineProperty({}, "foo", + { get: function() { return 17; }, + set: function(v) { called = true; } }); + +assertEq(o.foo, 17); +o.foo = 42; +assertEq(called, true); + +/* + * XXX need tests for Object.defineProperty(array, "length", { ... }) when we + * support it! + */ + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("All tests passed!"); |