diff --git a/test/built-ins/Proxy/has/call-in.js b/test/built-ins/Proxy/has/call-in.js new file mode 100644 index 0000000000000000000000000000000000000000..380a3c1a2058cf1a844fe92588badb2d69e0c3c1 --- /dev/null +++ b/test/built-ins/Proxy/has/call-in.js @@ -0,0 +1,32 @@ +// 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.7 +description: > + A `in` check trigger trap.call(handler, target, P); +info: > + [[HasProperty]] (P) + + ... + 9. Let booleanTrapResult be ToBoolean(Call(trap, handler, «target, P»)). + ... +---*/ + +var _handler, _target, _prop; +var target = {}; +var handler = { + has: function(t, prop) { + _handler = this; + _target = t; + _prop = prop; + + return prop in t; + } +}; +var p = new Proxy(target, handler); + +"attr" in p; + +assert.sameValue(_handler, handler, "handler is context"); +assert.sameValue(_target, target, "target is the first parameter"); +assert.sameValue(_prop, "attr", "given prop is the second paramter"); diff --git a/test/built-ins/Proxy/has/call-object-create.js b/test/built-ins/Proxy/has/call-object-create.js new file mode 100644 index 0000000000000000000000000000000000000000..90f5199c8f08ada051cb5834360e84d3fec4b1dd --- /dev/null +++ b/test/built-ins/Proxy/has/call-object-create.js @@ -0,0 +1,37 @@ +// 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.7 +description: > + `.. in Object.create(proxy)` triggers trap.call(handler, target, P); +info: > + [[HasProperty]] (P) + + ... + 2. Let handler be the value of the [[ProxyHandler]] internal slot of O. + ... + 5. Let target be the value of the [[ProxyTarget]] internal slot of O. + 6. Let trap be GetMethod(handler, "has"). + ... + 9. Let booleanTrapResult be ToBoolean(Call(trap, handler, «target, P»)). + ... +---*/ + +var _handler, _target, _prop; +var target = {}; +var handler = { + has: function(t, prop) { + _handler = this; + _target = t; + _prop = prop; + + return false; + } +}; +var p = new Proxy(target, handler); + +"attr" in Object.create(p); + +assert.sameValue(_handler, handler, "handler is context"); +assert.sameValue(_target, target, "target is the first parameter"); +assert.sameValue(_prop, "attr", "given prop is the second paramter"); diff --git a/test/built-ins/Proxy/has/call-with.js b/test/built-ins/Proxy/has/call-with.js new file mode 100644 index 0000000000000000000000000000000000000000..53f92ca6997d2daece8886ed4539b6e2ee2d6ef5 --- /dev/null +++ b/test/built-ins/Proxy/has/call-with.js @@ -0,0 +1,35 @@ +// 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.7 +description: > + A `with` variable check trigger trap.call(handler, target, P); +info: > + [[HasProperty]] (P) + + ... + 9. Let booleanTrapResult be ToBoolean(Call(trap, handler, «target, P»)). + ... +flags: [noStrict] +---*/ + +var _handler, _target, _prop; +var target = {}; +var handler = { + has: function(t, prop) { + _handler = this; + _target = t; + _prop = prop; + + return true; + } +}; +var p = new Proxy(target, handler); + +with (p) { + (attr); +} + +assert.sameValue(_handler, handler); +assert.sameValue(_target, target); +assert.sameValue(_prop, "attr"); diff --git a/test/built-ins/Proxy/has/null-handler-using-with.js b/test/built-ins/Proxy/has/null-handler-using-with.js new file mode 100644 index 0000000000000000000000000000000000000000..06bd4eaf0ec94a629b019af8171be06cd6cf8cc8 --- /dev/null +++ b/test/built-ins/Proxy/has/null-handler-using-with.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.7 +description: > + Throws a TypeError exception if handler is null. +flags: [noStrict] +---*/ + +var p = Proxy.revocable({}, {}); + +p.revoke(); + +assert.throws(TypeError, function() { + with (p.proxy) { + (attr); + } +}); diff --git a/test/built-ins/Proxy/has/null-handler.js b/test/built-ins/Proxy/has/null-handler.js new file mode 100644 index 0000000000000000000000000000000000000000..90deca388baa1c2449a8368ce47723eee4979b84 --- /dev/null +++ b/test/built-ins/Proxy/has/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.7 +description: > + Throws a TypeError exception if handler is null. +---*/ + +var p = Proxy.revocable({}, {}); + +p.revoke(); + +assert.throws(TypeError, function() { + "attr" in p.proxy; +}); diff --git a/test/built-ins/Proxy/has/return-false-target-not-extensible-using-with.js b/test/built-ins/Proxy/has/return-false-target-not-extensible-using-with.js new file mode 100644 index 0000000000000000000000000000000000000000..6bc735aba5794a4f5f5e93a2ffa6a5b6889e7921 --- /dev/null +++ b/test/built-ins/Proxy/has/return-false-target-not-extensible-using-with.js @@ -0,0 +1,43 @@ +// 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.7 +description: > + A property cannot be reported as non-existent, if it exists as an own + property of the target object and the target object is not extensible. +info: > + [[HasProperty]] (P) + + ... + 11. If booleanTrapResult is false, then + a. Let targetDesc be target.[[GetOwnProperty]](P). + b. ReturnIfAbrupt(targetDesc). + c. If targetDesc is not undefined, then + ... + ii. Let extensibleTarget be IsExtensible(target). + ... + iv. If extensibleTarget is false, throw a TypeError exception. + ... +flags: [noStrict] +---*/ + +var target = {}; +var handler = { + has: function(t, prop) { + return 0; + } +}; +var p = new Proxy(target, handler); + +Object.defineProperty(target, 'attr', { + configurable: true, + value: 1 +}); + +Object.preventExtensions(target); + +assert.throws(TypeError, function() { + with (p) { + (attr); + } +}); diff --git a/test/built-ins/Proxy/has/return-false-target-not-extensible.js b/test/built-ins/Proxy/has/return-false-target-not-extensible.js new file mode 100644 index 0000000000000000000000000000000000000000..731e22d46a2726545d67ac29836573daa17ae43f --- /dev/null +++ b/test/built-ins/Proxy/has/return-false-target-not-extensible.js @@ -0,0 +1,40 @@ +// 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.7 +description: > + A property cannot be reported as non-existent, if it exists as an own + property of the target object and the target object is not extensible. +info: > + [[HasProperty]] (P) + + ... + 11. If booleanTrapResult is false, then + a. Let targetDesc be target.[[GetOwnProperty]](P). + b. ReturnIfAbrupt(targetDesc). + c. If targetDesc is not undefined, then + ... + ii. Let extensibleTarget be IsExtensible(target). + ... + iv. If extensibleTarget is false, throw a TypeError exception. + ... +---*/ + +var target = {}; +var handler = { + has: function(t, prop) { + return 0; + } +}; +var p = new Proxy(target, handler); + +Object.defineProperty(target, "attr", { + configurable: true, + value: 1 +}); + +Object.preventExtensions(target); + +assert.throws(TypeError, function() { + "attr" in p; +}); diff --git a/test/built-ins/Proxy/has/return-false-target-prop-exists-using-with.js b/test/built-ins/Proxy/has/return-false-target-prop-exists-using-with.js new file mode 100644 index 0000000000000000000000000000000000000000..94f253acb164375e894ac5ddd9d96be071a21d16 --- /dev/null +++ b/test/built-ins/Proxy/has/return-false-target-prop-exists-using-with.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.7 +description: > + The result of [[HasProperty]] is a Boolean value and will affect has + checkings. False returned when target property exists; +info: > + [[HasProperty]] (P) + + ... + 12. Return booleanTrapResult. +flags: [noStrict] +---*/ + +var target = { + attr: 1 +}; +var p = new Proxy(target, { + has: function(t, prop) { + return false; + } +}); + +var attr = 0; +with (p) { + assert.sameValue(attr, 0); +} diff --git a/test/built-ins/Proxy/has/return-false-target-prop-exists.js b/test/built-ins/Proxy/has/return-false-target-prop-exists.js new file mode 100644 index 0000000000000000000000000000000000000000..eff332a66a37009a935c889870aef5eef4f87947 --- /dev/null +++ b/test/built-ins/Proxy/has/return-false-target-prop-exists.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.7 +description: > + The result of [[HasProperty]] is a Boolean value and will affect has + checkings. False returned when target property exists; +info: > + [[HasProperty]] (P) + + ... + 12. Return booleanTrapResult. +---*/ + +var target = { + attr: 1 +}; +var p = new Proxy(target, { + has: function(t, prop) { + return false; + } +}); + +assert.sameValue(("attr" in p), false); diff --git a/test/built-ins/Proxy/has/return-false-targetdesc-not-configurable-using-with.js b/test/built-ins/Proxy/has/return-false-targetdesc-not-configurable-using-with.js new file mode 100644 index 0000000000000000000000000000000000000000..2ecf01cd6f0420daef9fae84726c4cb6438c0f47 --- /dev/null +++ b/test/built-ins/Proxy/has/return-false-targetdesc-not-configurable-using-with.js @@ -0,0 +1,38 @@ +// 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.7 +description: > + A property cannot be reported as non-existent, if it exists as a + non-configurable own property of the target object. +info: > + [[HasProperty]] (P) + + ... + 11. If booleanTrapResult is false, then + ... + c. If targetDesc is not undefined, then + i. If targetDesc.[[Configurable]] is false, throw a TypeError + exception. + ... +flags: [noStrict] +---*/ + +var target = {}; +var handler = { + has: function(t, prop) { + return 0; + } +}; +var p = new Proxy(target, handler); + +Object.defineProperty(target, "attr", { + configurable: false, + value: 1 +}); + +assert.throws(TypeError, function() { + with (p) { + (attr); + } +}); diff --git a/test/built-ins/Proxy/has/return-false-targetdesc-not-configurable.js b/test/built-ins/Proxy/has/return-false-targetdesc-not-configurable.js new file mode 100644 index 0000000000000000000000000000000000000000..dce7a6d3906af7060bd1e77e10e68a79b604ec8e --- /dev/null +++ b/test/built-ins/Proxy/has/return-false-targetdesc-not-configurable.js @@ -0,0 +1,35 @@ +// 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.7 +description: > + A property cannot be reported as non-existent, if it exists as a + non-configurable own property of the target object. +info: > + [[HasProperty]] (P) + + ... + 11. If booleanTrapResult is false, then + ... + c. If targetDesc is not undefined, then + i. If targetDesc.[[Configurable]] is false, throw a TypeError + exception. + ... +---*/ + +var target = {}; +var handler = { + has: function(t, prop) { + return 0; + } +}; +var p = new Proxy(target, handler); + +Object.defineProperty(target, "attr", { + configurable: false, + value: 1 +}); + +assert.throws(TypeError, function() { + "attr" in p; +}); diff --git a/test/built-ins/Proxy/has/return-is-abrupt-in.js b/test/built-ins/Proxy/has/return-is-abrupt-in.js new file mode 100644 index 0000000000000000000000000000000000000000..a9ae9f31ee116af0a5de63894acead9a951f0e8c --- /dev/null +++ b/test/built-ins/Proxy/has/return-is-abrupt-in.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.7 +description: > + Trap returns abrupt. Using `prop in obj`. +info: > + [[HasProperty]] (P) + + ... + 9. Let booleanTrapResult be ToBoolean(Call(trap, handler, «target, P»)). + 10. ReturnIfAbrupt(booleanTrapResult). + ... +includes: [Test262Error.js] +---*/ + +var p = new Proxy({}, { + has: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + "attr" in p; +}); diff --git a/test/built-ins/Proxy/has/return-is-abrupt-with.js b/test/built-ins/Proxy/has/return-is-abrupt-with.js new file mode 100644 index 0000000000000000000000000000000000000000..97ff469cd2ff4af2752427a846fca3635d2eae24 --- /dev/null +++ b/test/built-ins/Proxy/has/return-is-abrupt-with.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.7 +description: > + Trap returns abrupt. Using `with`. +info: > + [[HasProperty]] (P) + + ... + 9. Let booleanTrapResult be ToBoolean(Call(trap, handler, «target, P»)). + 10. ReturnIfAbrupt(booleanTrapResult). + ... +flags: [noStrict] +includes: [Test262Error.js] +---*/ + +var p = new Proxy({}, { + has: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + with (p) { + (attr); + } +}); diff --git a/test/built-ins/Proxy/has/return-true-target-prop-exists-using-with.js b/test/built-ins/Proxy/has/return-true-target-prop-exists-using-with.js new file mode 100644 index 0000000000000000000000000000000000000000..145073b72022c4907be9e1f69974f8be928d2891 --- /dev/null +++ b/test/built-ins/Proxy/has/return-true-target-prop-exists-using-with.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.7 +description: > + The result of [[HasProperty]] is a Boolean value and will affect has + checkings. True returned when target property exists; +flags: [noStrict] +---*/ + +var target = { + attr: 1 +}; +var p = new Proxy(target, { + has: function(t, prop) { + if (prop !== "assert") { + return 42; + } + } +}); + +var attr = 0; +with (p) { + assert.sameValue(attr, 1); +} diff --git a/test/built-ins/Proxy/has/return-true-target-prop-exists.js b/test/built-ins/Proxy/has/return-true-target-prop-exists.js new file mode 100644 index 0000000000000000000000000000000000000000..9c5a409da6fd55bdbf09758a607c25b51d11ed00 --- /dev/null +++ b/test/built-ins/Proxy/has/return-true-target-prop-exists.js @@ -0,0 +1,19 @@ +// 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.7 +description: > + The result of [[HasProperty]] is a Boolean value and will affect has + checkings. True returned when target property exists; +---*/ + +var target = { + attr: 1 +}; +var p = new Proxy(target, { + has: function(t, prop) { + return 1; + } +}); + +assert.sameValue(("attr" in p), true); diff --git a/test/built-ins/Proxy/has/return-true-without-same-target-prop.js b/test/built-ins/Proxy/has/return-true-without-same-target-prop.js new file mode 100644 index 0000000000000000000000000000000000000000..9186074a7d2cc4640bc1d180c0ae9ac749a3bf6f --- /dev/null +++ b/test/built-ins/Proxy/has/return-true-without-same-target-prop.js @@ -0,0 +1,16 @@ +// 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.7 +description: > + The result of [[HasProperty]] is a Boolean value and will affect has + checkings. True returned when target property doesn't exists; +---*/ + +var p = new Proxy({}, { + has: function(t, prop) { + return true; + } +}); + +assert.sameValue(("attr" in p), true); diff --git a/test/built-ins/Proxy/has/trap-is-not-callable-using-with.js b/test/built-ins/Proxy/has/trap-is-not-callable-using-with.js new file mode 100644 index 0000000000000000000000000000000000000000..ae837ea9e04b682e9bc11e0c41ace1f3efa46bf0 --- /dev/null +++ b/test/built-ins/Proxy/has/trap-is-not-callable-using-with.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.7 +description: > + Throws a TypeError exception if trap is not callable. +info: > + [[HasProperty]] (P) + + ... + 6. Let trap be GetMethod(handler, "has"). + ... + 7.3.9 GetMethod (O, P) + ... + 2. Let func be GetV(O, P). + 5. If IsCallable(func) is false, throw a TypeError exception. + ... +flags: [noStrict] +---*/ + +var target = {}; +var p = new Proxy(target, { + has: {} +}); + +assert.throws(TypeError, function() { + with (p) { + (attr); + } +}); diff --git a/test/built-ins/Proxy/has/trap-is-not-callable.js b/test/built-ins/Proxy/has/trap-is-not-callable.js new file mode 100644 index 0000000000000000000000000000000000000000..7547fd398ca10a9922e25a2c4932b27f3d5dafa6 --- /dev/null +++ b/test/built-ins/Proxy/has/trap-is-not-callable.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.7 +description: > + Throws a TypeError exception if trap is not callable. +info: > + [[HasProperty]] (P) + + ... + 6. Let trap be GetMethod(handler, "has"). + ... + 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, { + has: {} +}); + +assert.throws(TypeError, function() { + "attr" in p; +}); diff --git a/test/built-ins/Proxy/has/trap-is-undefined-using-with.js b/test/built-ins/Proxy/has/trap-is-undefined-using-with.js new file mode 100644 index 0000000000000000000000000000000000000000..2bba67f3541c981962b1f7605b45927eee946e24 --- /dev/null +++ b/test/built-ins/Proxy/has/trap-is-undefined-using-with.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.7 +description: > + Return target.[[HasProperty]](P) if trap is undefined. +info: > + [[HasProperty]] (P) + + ... + 8. If trap is undefined, then + a. Return target.[[HasProperty]](P). + ... +flags: [noStrict] +---*/ + +var target = Object.create(Array.prototype); +var p = new Proxy(target, {}); + +var foo = 3; +with (target) { + assert.sameValue(length, 0); + assert.sameValue(foo, 3); +} diff --git a/test/built-ins/Proxy/has/trap-is-undefined.js b/test/built-ins/Proxy/has/trap-is-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..1fa90717835c160dcaf1941e2c3d314f94f6a702 --- /dev/null +++ b/test/built-ins/Proxy/has/trap-is-undefined.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.7 +description: > + Return target.[[HasProperty]](P) if trap is undefined. +info: > + [[HasProperty]] (P) + + ... + 8. If trap is undefined, then + a. Return target.[[HasProperty]](P). + ... +---*/ + +var target = Object.create(Array.prototype); +var p = new Proxy(target, {}); + +assert.sameValue(("foo" in p), false); +assert.sameValue(("length" in p), true);