diff options
Diffstat (limited to 'js/src/tests/test262/built-ins/Proxy/isExtensible')
14 files changed, 365 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Proxy/isExtensible/browser.js b/js/src/tests/test262/built-ins/Proxy/isExtensible/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Proxy/isExtensible/browser.js diff --git a/js/src/tests/test262/built-ins/Proxy/isExtensible/call-parameters.js b/js/src/tests/test262/built-ins/Proxy/isExtensible/call-parameters.js new file mode 100644 index 0000000000..e6782da76a --- /dev/null +++ b/js/src/tests/test262/built-ins/Proxy/isExtensible/call-parameters.js @@ -0,0 +1,34 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 9.5.3 +description: > + The trap is called with handler on its context and the target object as the + first parabeter +info: | + [[IsExtensible]] ( ) + + ... + 8. Let booleanTrapResult be ToBoolean(Call(trap, handler, «target»)). + ... + +features: [Proxy] +---*/ + +var _target, _handler; +var target = {}; +var handler = { + isExtensible: function(t) { + _handler = this; + _target = t; + return Object.isExtensible(t); + } +} +var p = new Proxy(target, handler); + +Object.isExtensible(p); + +assert.sameValue(_handler, handler); +assert.sameValue(_target, target); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Proxy/isExtensible/null-handler.js b/js/src/tests/test262/built-ins/Proxy/isExtensible/null-handler.js new file mode 100644 index 0000000000..87c5304599 --- /dev/null +++ b/js/src/tests/test262/built-ins/Proxy/isExtensible/null-handler.js @@ -0,0 +1,18 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 9.5.3 +description: > + Throws a TypeError exception if handler is null +features: [Proxy] +---*/ + +var p = Proxy.revocable({}, {}); + +p.revoke(); + +assert.throws(TypeError, function() { + Object.isExtensible(p.proxy); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Proxy/isExtensible/return-is-abrupt.js b/js/src/tests/test262/built-ins/Proxy/isExtensible/return-is-abrupt.js new file mode 100644 index 0000000000..7976c4ee36 --- /dev/null +++ b/js/src/tests/test262/built-ins/Proxy/isExtensible/return-is-abrupt.js @@ -0,0 +1,27 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 9.5.3 +description: > + Trap returns abrupt. +info: | + [[IsExtensible]] ( ) + + ... + 8. Let booleanTrapResult be ToBoolean(Call(trap, handler, «target»)). + 9. ReturnIfAbrupt(booleanTrapResult). + ... +features: [Proxy] +---*/ + +var p = new Proxy({}, { + isExtensible: function(t) { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + Object.isExtensible(p); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Proxy/isExtensible/return-is-boolean.js b/js/src/tests/test262/built-ins/Proxy/isExtensible/return-is-boolean.js new file mode 100644 index 0000000000..127251ac8a --- /dev/null +++ b/js/src/tests/test262/built-ins/Proxy/isExtensible/return-is-boolean.js @@ -0,0 +1,27 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 9.5.3 +description: > + The trap returns a boolean result. +features: [Proxy] +---*/ + +var target = {}; +var p = new Proxy(target, { + isExtensible: function(t) { + if (Object.isExtensible(t)) { + return 1; + } else { + return 0; + } + } +}); + +assert.sameValue(Object.isExtensible(p), true); + +Object.preventExtensions(target); + +assert.sameValue(Object.isExtensible(p), false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Proxy/isExtensible/return-is-different-from-target.js b/js/src/tests/test262/built-ins/Proxy/isExtensible/return-is-different-from-target.js new file mode 100644 index 0000000000..e05b225188 --- /dev/null +++ b/js/src/tests/test262/built-ins/Proxy/isExtensible/return-is-different-from-target.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 9.5.3 +description: > + Throws a TypeError exception if boolean trap result is not the same as + target.[[IsExtensible]]() result +info: | + [[IsExtensible]] ( ) + + ... + 12. If SameValue(booleanTrapResult, targetResult) is false, throw a + TypeError exception. + ... +features: [Proxy] +---*/ + +var p = new Proxy({}, { + isExtensible: function(t) { + return false; + } +}); + +assert.throws(TypeError, function() { + Object.isExtensible(p); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Proxy/isExtensible/return-same-result-from-target.js b/js/src/tests/test262/built-ins/Proxy/isExtensible/return-same-result-from-target.js new file mode 100644 index 0000000000..b4d2155b85 --- /dev/null +++ b/js/src/tests/test262/built-ins/Proxy/isExtensible/return-same-result-from-target.js @@ -0,0 +1,23 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 9.5.3 +description: > + Return trap result. +features: [Proxy] +---*/ + +var target = {}; +var p = new Proxy(target, { + isExtensible: function(t) { + return Object.isExtensible(t); + } +}); + +assert.sameValue(Object.isExtensible(p), true); + +Object.preventExtensions(target); + +assert.sameValue(Object.isExtensible(p), false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Proxy/isExtensible/shell.js b/js/src/tests/test262/built-ins/Proxy/isExtensible/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Proxy/isExtensible/shell.js diff --git a/js/src/tests/test262/built-ins/Proxy/isExtensible/trap-is-missing-target-is-proxy.js b/js/src/tests/test262/built-ins/Proxy/isExtensible/trap-is-missing-target-is-proxy.js new file mode 100644 index 0000000000..266db31b77 --- /dev/null +++ b/js/src/tests/test262/built-ins/Proxy/isExtensible/trap-is-missing-target-is-proxy.js @@ -0,0 +1,33 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-proxy-object-internal-methods-and-internal-slots-isextensible +description: > + If "isExtensible" trap is null or undefined, [[IsExtensible]] call is + properly forwarded to [[ProxyTarget]] (which is also a Proxy object). +info: | + [[IsExtensible]] ( ) + + [...] + 4. Let target be O.[[ProxyTarget]]. + 5. Let trap be ? GetMethod(handler, "isExtensible"). + 6. If trap is undefined, then + a. Return ? IsExtensible(target). + + IsExtensible ( O ) + + 1. Assert: Type(O) is Object. + 2. Return ? O.[[IsExtensible]](). +features: [Proxy] +---*/ + +var regExp = /(?:)/g; +Object.preventExtensions(regExp); + +var regExpTarget = new Proxy(regExp, {}); +var regExpProxy = new Proxy(regExpTarget, {}); + +assert(!Object.isExtensible(regExpProxy)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Proxy/isExtensible/trap-is-not-callable-realm.js b/js/src/tests/test262/built-ins/Proxy/isExtensible/trap-is-not-callable-realm.js new file mode 100644 index 0000000000..8406275aa3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Proxy/isExtensible/trap-is-not-callable-realm.js @@ -0,0 +1,33 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-proxy-object-internal-methods-and-internal-slots-isextensible +description: > + Throws if trap is not callable (honoring the Realm of the current execution + context) +info: | + [[IsExtensible]] ( ) + + ... + 1. Let handler be the value of the [[ProxyHandler]] internal slot of O. + ... + 5. Let trap be GetMethod(handler, "isExtensible"). + ... + 7.3.9 GetMethod (O, P) + ... + 2. Let func be GetV(O, P). + 5. If IsCallable(func) is false, throw a TypeError exception. + ... +features: [cross-realm, Proxy] +---*/ + +var OProxy = $262.createRealm().global.Proxy; +var p = new OProxy({}, { + isExtensible: {} +}); + +assert.throws(TypeError, function() { + Object.isExtensible(p); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Proxy/isExtensible/trap-is-not-callable.js b/js/src/tests/test262/built-ins/Proxy/isExtensible/trap-is-not-callable.js new file mode 100644 index 0000000000..b253fdebf6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Proxy/isExtensible/trap-is-not-callable.js @@ -0,0 +1,33 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 9.5.3 +description: > + Throws a TypeError exception if trap is not callable. +info: | + [[IsExtensible]] ( ) + + ... + 1. Let handler be the value of the [[ProxyHandler]] internal slot of O. + ... + 5. Let trap be GetMethod(handler, "isExtensible"). + ... + 7.3.9 GetMethod (O, P) + ... + 2. Let func be GetV(O, P). + 5. If IsCallable(func) is false, throw a TypeError exception. + ... +features: [Proxy] +---*/ + + +var target = {}; +var p = new Proxy(target, { + isExtensible: {} +}); + +assert.throws(TypeError, function() { + Object.isExtensible(p); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Proxy/isExtensible/trap-is-null-target-is-proxy.js b/js/src/tests/test262/built-ins/Proxy/isExtensible/trap-is-null-target-is-proxy.js new file mode 100644 index 0000000000..406c5969ea --- /dev/null +++ b/js/src/tests/test262/built-ins/Proxy/isExtensible/trap-is-null-target-is-proxy.js @@ -0,0 +1,32 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-proxy-object-internal-methods-and-internal-slots-isextensible +description: > + If "isExtensible" trap is null or undefined, [[IsExtensible]] call is + properly forwarded to [[ProxyTarget]] (which is also a Proxy object). +info: | + [[IsExtensible]] ( ) + + [...] + 4. Let target be O.[[ProxyTarget]]. + 5. Let trap be ? GetMethod(handler, "isExtensible"). + 6. If trap is undefined, then + a. Return ? IsExtensible(target). + + IsExtensible ( O ) + + 1. Assert: Type(O) is Object. + 2. Return ? O.[[IsExtensible]](). +features: [Proxy] +---*/ + +var plainObjectTarget = new Proxy({}, {}); +var plainObjectProxy = new Proxy(plainObjectTarget, { + isExtensible: null, +}); + +assert(Object.isExtensible(plainObjectProxy)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Proxy/isExtensible/trap-is-undefined-target-is-proxy.js b/js/src/tests/test262/built-ins/Proxy/isExtensible/trap-is-undefined-target-is-proxy.js new file mode 100644 index 0000000000..7830be1286 --- /dev/null +++ b/js/src/tests/test262/built-ins/Proxy/isExtensible/trap-is-undefined-target-is-proxy.js @@ -0,0 +1,51 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-proxy-object-internal-methods-and-internal-slots-isextensible +description: > + If "isExtensible" trap is null or undefined, [[IsExtensible]] call is + properly forwarded to [[ProxyTarget]] (which is also a Proxy object). +info: | + [[IsExtensible]] ( ) + + [...] + 4. Let target be O.[[ProxyTarget]]. + 5. Let trap be ? GetMethod(handler, "isExtensible"). + 6. If trap is undefined, then + a. Return ? IsExtensible(target). + + IsExtensible ( O ) + + 1. Assert: Type(O) is Object. + 2. Return ? O.[[IsExtensible]](). + + [[IsExtensible]] ( ) + + [...] + 7. Let booleanTrapResult be ! ToBoolean(? Call(trap, handler, « target »)). + [...] + 10. Return booleanTrapResult. +features: [Proxy] +---*/ + +var array = []; +var arrayExtensible = true; +var arrayTarget = new Proxy(array, { + isExtensible: function() { + return arrayExtensible; + }, +}); + +var arrayProxy = new Proxy(arrayTarget, { + isExtensible: undefined, +}); + +assert(Object.isExtensible(arrayProxy)); + +Object.preventExtensions(array); +arrayExtensible = false; + +assert(!Object.isExtensible(arrayProxy)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Proxy/isExtensible/trap-is-undefined.js b/js/src/tests/test262/built-ins/Proxy/isExtensible/trap-is-undefined.js new file mode 100644 index 0000000000..e95601b80f --- /dev/null +++ b/js/src/tests/test262/built-ins/Proxy/isExtensible/trap-is-undefined.js @@ -0,0 +1,26 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 9.5.3 +description: > + Return target.[[IsExtensible]]() if trap is undefined. +info: | + [[IsExtensible]] ( ) + + ... + 7. If trap is undefined, then + a. Return target.[[IsExtensible]](). + ... +features: [Proxy] +---*/ + +var target = {}; +var p = new Proxy(target, {}); + +assert.sameValue(Object.isExtensible(p), true); + +Object.preventExtensions(target); + +assert.sameValue(Object.isExtensible(p), false); + +reportCompare(0, 0); |