diff --git a/test/built-ins/Proxy/isExtensible/call-parameters.js b/test/built-ins/Proxy/isExtensible/call-parameters.js new file mode 100644 index 0000000000000000000000000000000000000000..e2e5db3cc3d9a2c8cda8e76582a3b2db450329f6 --- /dev/null +++ b/test/built-ins/Proxy/isExtensible/call-parameters.js @@ -0,0 +1,31 @@ +// 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»)). + ... + +---*/ + +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); diff --git a/test/built-ins/Proxy/isExtensible/null-handler.js b/test/built-ins/Proxy/isExtensible/null-handler.js new file mode 100644 index 0000000000000000000000000000000000000000..d8d14bf7c86dca4ac46307628a1ee1537e93700c --- /dev/null +++ b/test/built-ins/Proxy/isExtensible/null-handler.js @@ -0,0 +1,15 @@ +// 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 +---*/ + +var p = Proxy.revocable({}, {}); + +p.revoke(); + +assert.throws(TypeError, function() { + Object.isExtensible(p.proxy); +}); diff --git a/test/built-ins/Proxy/isExtensible/return-is-abrupt.js b/test/built-ins/Proxy/isExtensible/return-is-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..d288dee824b71c238850278112aa0a1f8a440b78 --- /dev/null +++ b/test/built-ins/Proxy/isExtensible/return-is-abrupt.js @@ -0,0 +1,25 @@ +// 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). + ... +includes: [Test262Error.js] +---*/ + +var p = new Proxy({}, { + isExtensible: function(t) { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + Object.isExtensible(p); +}); diff --git a/test/built-ins/Proxy/isExtensible/return-is-boolean.js b/test/built-ins/Proxy/isExtensible/return-is-boolean.js new file mode 100644 index 0000000000000000000000000000000000000000..29d54369ed8c51d644850898b20d07b61d07face --- /dev/null +++ b/test/built-ins/Proxy/isExtensible/return-is-boolean.js @@ -0,0 +1,24 @@ +// 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. +---*/ + +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); diff --git a/test/built-ins/Proxy/isExtensible/return-is-different-from-target.js b/test/built-ins/Proxy/isExtensible/return-is-different-from-target.js new file mode 100644 index 0000000000000000000000000000000000000000..9c5ee18c99312413bbee1560cedaa922a38916aa --- /dev/null +++ b/test/built-ins/Proxy/isExtensible/return-is-different-from-target.js @@ -0,0 +1,25 @@ +// 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. + ... +---*/ + +var p = new Proxy({}, { + isExtensible: function(t) { + return false; + } +}); + +assert.throws(TypeError, function() { + Object.isExtensible(p); +}); diff --git a/test/built-ins/Proxy/isExtensible/return-same-result-from-target.js b/test/built-ins/Proxy/isExtensible/return-same-result-from-target.js new file mode 100644 index 0000000000000000000000000000000000000000..4858765c37643c0251f37eefb48335e637331819 --- /dev/null +++ b/test/built-ins/Proxy/isExtensible/return-same-result-from-target.js @@ -0,0 +1,20 @@ +// 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. +---*/ + +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); diff --git a/test/built-ins/Proxy/isExtensible/trap-is-not-callable.js b/test/built-ins/Proxy/isExtensible/trap-is-not-callable.js new file mode 100644 index 0000000000000000000000000000000000000000..adca7938336a90e22d6d7020aed968b875054ea4 --- /dev/null +++ b/test/built-ins/Proxy/isExtensible/trap-is-not-callable.js @@ -0,0 +1,30 @@ +// 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. + ... +---*/ + + +var target = {}; +var p = new Proxy(target, { + isExtensible: {} +}); + +assert.throws(TypeError, function() { + Object.isExtensible(p); +}); diff --git a/test/built-ins/Proxy/isExtensible/trap-is-undefined.js b/test/built-ins/Proxy/isExtensible/trap-is-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..a69acac26ddfc5b68765123438f4d187f1064121 --- /dev/null +++ b/test/built-ins/Proxy/isExtensible/trap-is-undefined.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 target.[[IsExtensible]]() if trap is undefined. +info: > + [[IsExtensible]] ( ) + + ... + 7. If trap is undefined, then + a. Return target.[[IsExtensible]](). + ... +---*/ + +var target = {}; +var p = new Proxy(target, {}); + +assert.sameValue(Object.isExtensible(p), true); + +Object.preventExtensions(target); + +assert.sameValue(Object.isExtensible(p), false);