diff options
Diffstat (limited to 'js/src/jit-test/tests/realms/array-ctor.js')
-rw-r--r-- | js/src/jit-test/tests/realms/array-ctor.js | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/realms/array-ctor.js b/js/src/jit-test/tests/realms/array-ctor.js new file mode 100644 index 0000000000..b2e0497ae5 --- /dev/null +++ b/js/src/jit-test/tests/realms/array-ctor.js @@ -0,0 +1,35 @@ +function testArrayRealm() { + var g = newGlobal(); + var A = g.Array; + for (var i = 0; i < 100; i++) { + var a; + a = new A(); + assertEq(isSameCompartment(a, g), true); + assertEq(Object.getPrototypeOf(a), A.prototype); + + a = new A(i); + assertEq(isSameCompartment(a, g), true); + assertEq(Object.getPrototypeOf(a), A.prototype); + } +} +testArrayRealm(); + +function testErrorRealm() { + var g = newGlobal(); + var A = g.Array; + for (var i = 50; i > -50; i--) { + var a = null; + var ex = null; + try { + a = new A(i); + } catch (e) { + ex = e; + } + if (i >= 0) { + assertEq(Object.getPrototypeOf(a), A.prototype); + } else { + assertEq(ex instanceof g.RangeError, true); + } + } +} +testErrorRealm(); |