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/TypedArray/object-defineproperty.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/TypedArray/object-defineproperty.js | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/js/src/tests/non262/TypedArray/object-defineproperty.js b/js/src/tests/non262/TypedArray/object-defineproperty.js new file mode 100644 index 0000000000..b19f76b845 --- /dev/null +++ b/js/src/tests/non262/TypedArray/object-defineproperty.js @@ -0,0 +1,68 @@ +var obj = new Int32Array(2); +obj[0] = 100; + +var throws = [ + // Disallow accessors + {get: undefined}, + {set: undefined}, + {get: undefined, set: undefined}, + {get: function() {}}, + {set: function() {}}, + {get: function() {}, set: function() {}}, + + {configurable: false}, + {enumerable: false}, + {writable: false}, + + {configurable: false, writable: true}, + {enumerable: false, configurable: false}, + + {configurable: false, value: 15} +]; + +for (var desc of throws) { + assertThrowsInstanceOf(function() { Object.defineProperty(obj, 0, desc); }, TypeError); + assertThrowsInstanceOf(function() { Object.defineProperties(obj, {0: desc}); }, TypeError); +} + +Object.defineProperty(obj, 0, {}); +Object.defineProperty(obj, 0, {configurable: true}); +Object.defineProperty(obj, 0, {enumerable: true}); +Object.defineProperty(obj, 0, {writable: true}); + +assertEq(obj[0], 100); + +Object.defineProperty(obj, 0, {configurable: true, value: 15}); +assertEq(obj[0], 15); +Object.defineProperty(obj, 0, {enumerable: true, value: 16}); +assertEq(obj[0], 16); +Object.defineProperty(obj, 0, {writable: true, value: 17}); +assertEq(obj[0], 17); +Object.defineProperty(obj, 0, {value: 18}); +assertEq(obj[0], 18); + +var desc = Object.getOwnPropertyDescriptor(obj, 0); +assertEq(desc.configurable, true); +assertEq(desc.enumerable, true); +assertEq(desc.writable, true); +assertEq(desc.value, 18); +assertEq('get' in desc, false); +assertEq('set' in desc, false); + +Object.defineProperties(obj, {0: {value: 20}, 1: {value: 42}}); +assertEq(obj[0], 20); +assertEq(obj[1], 42); + +anyTypedArrayConstructors.forEach(constructor => { + var obj = new constructor(4); + obj[0] = 100; + obj[1] = 200; + + for (var v of [20, 300, -10, Math.pow(2, 32), -Math.pow(2, 32), NaN]) { + Object.defineProperty(obj, 0, {value: v}); + obj[1] = v; + assertEq(obj[0], obj[1]); + } +}); + +reportCompare(true, true, "test"); |