diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /js/src/jit-test/tests/basic/typed-array-sealed-frozen.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'js/src/jit-test/tests/basic/typed-array-sealed-frozen.js')
-rw-r--r-- | js/src/jit-test/tests/basic/typed-array-sealed-frozen.js | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/basic/typed-array-sealed-frozen.js b/js/src/jit-test/tests/basic/typed-array-sealed-frozen.js new file mode 100644 index 000000000..90c0b9a35 --- /dev/null +++ b/js/src/jit-test/tests/basic/typed-array-sealed-frozen.js @@ -0,0 +1,85 @@ +// Any copyright is dedicated to the Public Domain. +// http://creativecommons.org/licenses/publicdomain/ + +load(libdir + "asserts.js") + +const constructors = [ + Int8Array, + Uint8Array, + Uint8ClampedArray, + Int16Array, + Uint16Array, + Int32Array, + Uint32Array, + Float32Array, + Float64Array +]; + +for (constructor of constructors) { + print("testing non-empty " + constructor.name); + let a = new constructor(10); + assertEq(Object.isExtensible(a), true); + assertEq(Object.isSealed(a), false); + assertEq(Object.isFrozen(a), false); + + // Should not throw. + Object.seal(a); + + // Should complain that it can't change attributes of indexed typed array properties. + assertThrowsInstanceOf(() => Object.freeze(a), TypeError); +} + +print(); + +for (constructor of constructors) { + print("testing zero-length " + constructor.name); + let a = new constructor(0); + assertEq(Object.isExtensible(a), true); + assertEq(Object.isSealed(a), false); + assertEq(Object.isFrozen(a), false); + + // Should not throw. + Object.seal(a); + Object.freeze(a); +} + +// isSealed and isFrozen should not try to build an array of all the +// property names of a typed array, since they're often especially large. +// This should not throw an allocation error. +let a = new Uint8Array(1 << 24); +Object.isSealed(a); +Object.isFrozen(a); + +for (constructor of constructors) { + print("testing extensibility " + constructor.name); + let a = new constructor(10); + + // New named properties should show up on typed arrays. + a.foo = "twelve"; + assertEq(a.foo, "twelve"); + + // New indexed properties should not show up on typed arrays. + a[20] = "twelve"; + assertEq(a[20], undefined); + + // Watch for especially large indexed properties. + a[-10 >>> 0] = "twelve"; + assertEq(a[-10 >>> 0], undefined); + + // Watch for really large indexed properties too. + a[Math.pow(2, 53)] = "twelve"; + assertEq(a[Math.pow(2, 53)], undefined); + + // Don't define old properties. + Object.defineProperty(a, 5, {value: 3}); + assertEq(a[5], 3); + + // Don't define new properties. + Object.defineProperty(a, 20, {value: 3}); + assertEq(a[20], undefined); + + // Don't delete indexed properties. + a[3] = 3; + delete a[3]; + assertEq(a[3], 3); +} |