summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Proxy/has
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/Proxy/has')
-rw-r--r--js/src/tests/test262/built-ins/Proxy/has/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/Proxy/has/call-in-prototype-index.js47
-rw-r--r--js/src/tests/test262/built-ins/Proxy/has/call-in-prototype.js45
-rw-r--r--js/src/tests/test262/built-ins/Proxy/has/call-in.js35
-rw-r--r--js/src/tests/test262/built-ins/Proxy/has/call-object-create.js40
-rw-r--r--js/src/tests/test262/built-ins/Proxy/has/call-with.js38
-rw-r--r--js/src/tests/test262/built-ins/Proxy/has/null-handler-using-with.js21
-rw-r--r--js/src/tests/test262/built-ins/Proxy/has/null-handler.js18
-rw-r--r--js/src/tests/test262/built-ins/Proxy/has/return-false-target-not-extensible-using-with.js46
-rw-r--r--js/src/tests/test262/built-ins/Proxy/has/return-false-target-not-extensible.js43
-rw-r--r--js/src/tests/test262/built-ins/Proxy/has/return-false-target-prop-exists-using-with.js31
-rw-r--r--js/src/tests/test262/built-ins/Proxy/has/return-false-target-prop-exists.js27
-rw-r--r--js/src/tests/test262/built-ins/Proxy/has/return-false-targetdesc-not-configurable-using-with.js41
-rw-r--r--js/src/tests/test262/built-ins/Proxy/has/return-false-targetdesc-not-configurable.js38
-rw-r--r--js/src/tests/test262/built-ins/Proxy/has/return-is-abrupt-in.js27
-rw-r--r--js/src/tests/test262/built-ins/Proxy/has/return-is-abrupt-with.js30
-rw-r--r--js/src/tests/test262/built-ins/Proxy/has/return-true-target-prop-exists-using-with.js28
-rw-r--r--js/src/tests/test262/built-ins/Proxy/has/return-true-target-prop-exists.js22
-rw-r--r--js/src/tests/test262/built-ins/Proxy/has/return-true-without-same-target-prop.js19
-rw-r--r--js/src/tests/test262/built-ins/Proxy/has/shell.js33
-rw-r--r--js/src/tests/test262/built-ins/Proxy/has/trap-is-missing-target-is-proxy.js35
-rw-r--r--js/src/tests/test262/built-ins/Proxy/has/trap-is-not-callable-realm.js31
-rw-r--r--js/src/tests/test262/built-ins/Proxy/has/trap-is-not-callable-using-with.js33
-rw-r--r--js/src/tests/test262/built-ins/Proxy/has/trap-is-not-callable.js30
-rw-r--r--js/src/tests/test262/built-ins/Proxy/has/trap-is-null-target-is-proxy.js46
-rw-r--r--js/src/tests/test262/built-ins/Proxy/has/trap-is-undefined-target-is-proxy.js47
-rw-r--r--js/src/tests/test262/built-ins/Proxy/has/trap-is-undefined-using-with.js27
-rw-r--r--js/src/tests/test262/built-ins/Proxy/has/trap-is-undefined.js23
28 files changed, 901 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Proxy/has/browser.js b/js/src/tests/test262/built-ins/Proxy/has/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Proxy/has/browser.js
diff --git a/js/src/tests/test262/built-ins/Proxy/has/call-in-prototype-index.js b/js/src/tests/test262/built-ins/Proxy/has/call-in-prototype-index.js
new file mode 100644
index 0000000000..075cf4b6d2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Proxy/has/call-in-prototype-index.js
@@ -0,0 +1,47 @@
+// Copyright (C) 2019 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-hasproperty-p
+description: >
+ Ordinary [[HasProperty]] forwards call to Proxy "has" trap with correct arguments.
+ (integer index property name)
+info: |
+ OrdinaryHasProperty ( O, P )
+
+ ...
+ 4. Let parent be ? O.[[GetPrototypeOf]]().
+ 5. If parent is not null, then
+ a. Return ? parent.[[HasProperty]](P).
+
+ [[HasProperty]] ( P )
+
+ ...
+ 8. Let booleanTrapResult be ! ToBoolean(? Call(trap, handler, « target, P »)).
+ ...
+ 10. Return booleanTrapResult.
+includes: [proxyTrapsHelper.js]
+features: [Proxy]
+---*/
+
+var _handler, _target, _prop;
+var proto = [14];
+var target = Object.create(proto);
+var handler = allowProxyTraps({
+ has: function(target, prop) {
+ _handler = this;
+ _target = target;
+ _prop = prop;
+
+ return false;
+ },
+});
+var proxy = new Proxy(target, handler);
+var array = [];
+Object.setPrototypeOf(array, proxy);
+
+assert.sameValue(1 in array, false);
+assert.sameValue(_handler, handler, 'handler is context');
+assert.sameValue(_target, target, 'target is the first parameter');
+assert.sameValue(_prop, '1', 'given prop is the second paramter');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Proxy/has/call-in-prototype.js b/js/src/tests/test262/built-ins/Proxy/has/call-in-prototype.js
new file mode 100644
index 0000000000..e6ffeb443e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Proxy/has/call-in-prototype.js
@@ -0,0 +1,45 @@
+// Copyright (C) 2019 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-hasproperty-p
+description: >
+ Ordinary [[HasProperty]] forwards call to Proxy "has" trap with correct arguments.
+info: |
+ OrdinaryHasProperty ( O, P )
+
+ ...
+ 4. Let parent be ? O.[[GetPrototypeOf]]().
+ 5. If parent is not null, then
+ a. Return ? parent.[[HasProperty]](P).
+
+ [[HasProperty]] ( P )
+
+ ...
+ 8. Let booleanTrapResult be ! ToBoolean(? Call(trap, handler, « target, P »)).
+ ...
+ 10. Return booleanTrapResult.
+includes: [proxyTrapsHelper.js]
+features: [Proxy]
+---*/
+
+var _handler, _target, _prop;
+var proto = {prop: 1};
+var target = Object.create(proto);
+var handler = allowProxyTraps({
+ has: function(target, prop) {
+ _handler = this;
+ _target = target;
+ _prop = prop;
+
+ return false;
+ },
+});
+var proxy = new Proxy(target, handler);
+var heir = Object.create(proxy);
+
+assert.sameValue('prop' in heir, false);
+assert.sameValue(_handler, handler, 'handler is context');
+assert.sameValue(_target, target, 'target is the first parameter');
+assert.sameValue(_prop, 'prop', 'given prop is the second paramter');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Proxy/has/call-in.js b/js/src/tests/test262/built-ins/Proxy/has/call-in.js
new file mode 100644
index 0000000000..7159d4feee
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Proxy/has/call-in.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 `in` check trigger trap.call(handler, target, P);
+info: |
+ [[HasProperty]] (P)
+
+ ...
+ 9. Let booleanTrapResult be ToBoolean(Call(trap, handler, «target, P»)).
+ ...
+features: [Proxy]
+---*/
+
+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");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Proxy/has/call-object-create.js b/js/src/tests/test262/built-ins/Proxy/has/call-object-create.js
new file mode 100644
index 0000000000..fcf866b5b5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Proxy/has/call-object-create.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: >
+ `.. 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»)).
+ ...
+features: [Proxy]
+---*/
+
+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");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Proxy/has/call-with.js b/js/src/tests/test262/built-ins/Proxy/has/call-with.js
new file mode 100644
index 0000000000..4169d0a54b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Proxy/has/call-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 `with` variable check trigger trap.call(handler, target, P);
+info: |
+ [[HasProperty]] (P)
+
+ ...
+ 9. Let booleanTrapResult be ToBoolean(Call(trap, handler, «target, P»)).
+ ...
+flags: [noStrict]
+features: [Proxy]
+---*/
+
+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");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Proxy/has/null-handler-using-with.js b/js/src/tests/test262/built-ins/Proxy/has/null-handler-using-with.js
new file mode 100644
index 0000000000..d82edb099e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Proxy/has/null-handler-using-with.js
@@ -0,0 +1,21 @@
+// 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]
+features: [Proxy]
+---*/
+
+var p = Proxy.revocable({}, {});
+
+p.revoke();
+
+assert.throws(TypeError, function() {
+ with(p.proxy) {
+ (attr);
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Proxy/has/null-handler.js b/js/src/tests/test262/built-ins/Proxy/has/null-handler.js
new file mode 100644
index 0000000000..506225e6ec
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Proxy/has/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.7
+description: >
+ Throws a TypeError exception if handler is null.
+features: [Proxy]
+---*/
+
+var p = Proxy.revocable({}, {});
+
+p.revoke();
+
+assert.throws(TypeError, function() {
+ "attr" in p.proxy;
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Proxy/has/return-false-target-not-extensible-using-with.js b/js/src/tests/test262/built-ins/Proxy/has/return-false-target-not-extensible-using-with.js
new file mode 100644
index 0000000000..d3749a6774
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Proxy/has/return-false-target-not-extensible-using-with.js
@@ -0,0 +1,46 @@
+// 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]
+features: [Proxy]
+---*/
+
+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);
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Proxy/has/return-false-target-not-extensible.js b/js/src/tests/test262/built-ins/Proxy/has/return-false-target-not-extensible.js
new file mode 100644
index 0000000000..2cb55fd76f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Proxy/has/return-false-target-not-extensible.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.
+ ...
+features: [Proxy]
+---*/
+
+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;
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Proxy/has/return-false-target-prop-exists-using-with.js b/js/src/tests/test262/built-ins/Proxy/has/return-false-target-prop-exists-using-with.js
new file mode 100644
index 0000000000..c7d81d43cf
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Proxy/has/return-false-target-prop-exists-using-with.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.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]
+features: [Proxy]
+---*/
+
+var target = {
+ attr: 1
+};
+var p = new Proxy(target, {
+ has: function(t, prop) {
+ return false;
+ }
+});
+
+var attr = 0;
+with(p) {
+ assert.sameValue(attr, 0);
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Proxy/has/return-false-target-prop-exists.js b/js/src/tests/test262/built-ins/Proxy/has/return-false-target-prop-exists.js
new file mode 100644
index 0000000000..c67ea4ace0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Proxy/has/return-false-target-prop-exists.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: >
+ 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.
+features: [Proxy]
+---*/
+
+var target = {
+ attr: 1
+};
+var p = new Proxy(target, {
+ has: function(t, prop) {
+ return false;
+ }
+});
+
+assert.sameValue(("attr" in p), false);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Proxy/has/return-false-targetdesc-not-configurable-using-with.js b/js/src/tests/test262/built-ins/Proxy/has/return-false-targetdesc-not-configurable-using-with.js
new file mode 100644
index 0000000000..c7e114a82f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Proxy/has/return-false-targetdesc-not-configurable-using-with.js
@@ -0,0 +1,41 @@
+// 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]
+features: [Proxy]
+---*/
+
+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);
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Proxy/has/return-false-targetdesc-not-configurable.js b/js/src/tests/test262/built-ins/Proxy/has/return-false-targetdesc-not-configurable.js
new file mode 100644
index 0000000000..b77da04378
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Proxy/has/return-false-targetdesc-not-configurable.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.
+ ...
+features: [Proxy]
+---*/
+
+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;
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Proxy/has/return-is-abrupt-in.js b/js/src/tests/test262/built-ins/Proxy/has/return-is-abrupt-in.js
new file mode 100644
index 0000000000..7c38719533
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Proxy/has/return-is-abrupt-in.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: >
+ Trap returns abrupt. Using `prop in obj`.
+info: |
+ [[HasProperty]] (P)
+
+ ...
+ 9. Let booleanTrapResult be ToBoolean(Call(trap, handler, «target, P»)).
+ 10. ReturnIfAbrupt(booleanTrapResult).
+ ...
+features: [Proxy]
+---*/
+
+var p = new Proxy({}, {
+ has: function() {
+ throw new Test262Error();
+ }
+});
+
+assert.throws(Test262Error, function() {
+ "attr" in p;
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Proxy/has/return-is-abrupt-with.js b/js/src/tests/test262/built-ins/Proxy/has/return-is-abrupt-with.js
new file mode 100644
index 0000000000..6958d5b8f5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Proxy/has/return-is-abrupt-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: >
+ Trap returns abrupt. Using `with`.
+info: |
+ [[HasProperty]] (P)
+
+ ...
+ 9. Let booleanTrapResult be ToBoolean(Call(trap, handler, «target, P»)).
+ 10. ReturnIfAbrupt(booleanTrapResult).
+ ...
+flags: [noStrict]
+features: [Proxy]
+---*/
+
+var p = new Proxy({}, {
+ has: function() {
+ throw new Test262Error();
+ }
+});
+
+assert.throws(Test262Error, function() {
+ with(p) {
+ (attr);
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Proxy/has/return-true-target-prop-exists-using-with.js b/js/src/tests/test262/built-ins/Proxy/has/return-true-target-prop-exists-using-with.js
new file mode 100644
index 0000000000..e2df526588
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Proxy/has/return-true-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. True returned when target property exists;
+flags: [noStrict]
+features: [Proxy]
+---*/
+
+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);
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Proxy/has/return-true-target-prop-exists.js b/js/src/tests/test262/built-ins/Proxy/has/return-true-target-prop-exists.js
new file mode 100644
index 0000000000..1cf6201a33
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Proxy/has/return-true-target-prop-exists.js
@@ -0,0 +1,22 @@
+// 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;
+features: [Proxy]
+---*/
+
+var target = {
+ attr: 1
+};
+var p = new Proxy(target, {
+ has: function(t, prop) {
+ return 1;
+ }
+});
+
+assert.sameValue(("attr" in p), true);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Proxy/has/return-true-without-same-target-prop.js b/js/src/tests/test262/built-ins/Proxy/has/return-true-without-same-target-prop.js
new file mode 100644
index 0000000000..a0b5b926b4
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Proxy/has/return-true-without-same-target-prop.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 doesn't exists;
+features: [Proxy]
+---*/
+
+var p = new Proxy({}, {
+ has: function(t, prop) {
+ return true;
+ }
+});
+
+assert.sameValue(("attr" in p), true);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Proxy/has/shell.js b/js/src/tests/test262/built-ins/Proxy/has/shell.js
new file mode 100644
index 0000000000..bc72493f03
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Proxy/has/shell.js
@@ -0,0 +1,33 @@
+// GENERATED, DO NOT EDIT
+// file: proxyTrapsHelper.js
+// Copyright (C) 2016 Jordan Harband. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+description: |
+ Used to assert the correctness of object behavior in the presence
+ and context of Proxy objects.
+defines: [allowProxyTraps]
+---*/
+
+function allowProxyTraps(overrides) {
+ function throwTest262Error(msg) {
+ return function () { throw new Test262Error(msg); };
+ }
+ if (!overrides) { overrides = {}; }
+ return {
+ getPrototypeOf: overrides.getPrototypeOf || throwTest262Error('[[GetPrototypeOf]] trap called'),
+ setPrototypeOf: overrides.setPrototypeOf || throwTest262Error('[[SetPrototypeOf]] trap called'),
+ isExtensible: overrides.isExtensible || throwTest262Error('[[IsExtensible]] trap called'),
+ preventExtensions: overrides.preventExtensions || throwTest262Error('[[PreventExtensions]] trap called'),
+ getOwnPropertyDescriptor: overrides.getOwnPropertyDescriptor || throwTest262Error('[[GetOwnProperty]] trap called'),
+ has: overrides.has || throwTest262Error('[[HasProperty]] trap called'),
+ get: overrides.get || throwTest262Error('[[Get]] trap called'),
+ set: overrides.set || throwTest262Error('[[Set]] trap called'),
+ deleteProperty: overrides.deleteProperty || throwTest262Error('[[Delete]] trap called'),
+ defineProperty: overrides.defineProperty || throwTest262Error('[[DefineOwnProperty]] trap called'),
+ enumerate: throwTest262Error('[[Enumerate]] trap called: this trap has been removed'),
+ ownKeys: overrides.ownKeys || throwTest262Error('[[OwnPropertyKeys]] trap called'),
+ apply: overrides.apply || throwTest262Error('[[Call]] trap called'),
+ construct: overrides.construct || throwTest262Error('[[Construct]] trap called')
+ };
+}
diff --git a/js/src/tests/test262/built-ins/Proxy/has/trap-is-missing-target-is-proxy.js b/js/src/tests/test262/built-ins/Proxy/has/trap-is-missing-target-is-proxy.js
new file mode 100644
index 0000000000..edee560115
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Proxy/has/trap-is-missing-target-is-proxy.js
@@ -0,0 +1,35 @@
+// 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-hasproperty-p
+description: >
+ If "has" trap is null or undefined, [[HasProperty]] call is properly
+ forwarded to [[ProxyTarget]] (which is also a Proxy object).
+info: |
+ [[HasProperty]] ( P )
+
+ [...]
+ 5. Let target be O.[[ProxyTarget]].
+ 6. Let trap be ? GetMethod(handler, "has").
+ 7. If trap is undefined, then
+ a. Return ? target.[[HasProperty]](P).
+features: [Proxy, Symbol.replace, Reflect]
+---*/
+
+var regExp = /(?:)/m;
+var regExpTarget = new Proxy(regExp, {});
+var regExpProxy = new Proxy(regExpTarget, {});
+
+assert(Reflect.has(regExpProxy, "ignoreCase"));
+assert(Symbol.replace in regExpProxy);
+assert("lastIndex" in Object.create(regExpProxy));
+
+
+var functionTarget = new Proxy(function() {}, {});
+var functionProxy = new Proxy(functionTarget, {});
+
+assert("name" in functionProxy);
+assert("length" in Object.create(functionProxy));
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Proxy/has/trap-is-not-callable-realm.js b/js/src/tests/test262/built-ins/Proxy/has/trap-is-not-callable-realm.js
new file mode 100644
index 0000000000..9479a244a8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Proxy/has/trap-is-not-callable-realm.js
@@ -0,0 +1,31 @@
+// 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-hasproperty-p
+description: >
+ Throws if trap is not callable (honoring the Realm of the current execution
+ context)
+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.
+ ...
+features: [cross-realm, Proxy]
+---*/
+
+var OProxy = $262.createRealm().global.Proxy;
+var p = new OProxy({}, {
+ has: {}
+});
+
+assert.throws(TypeError, function() {
+ "attr" in p;
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Proxy/has/trap-is-not-callable-using-with.js b/js/src/tests/test262/built-ins/Proxy/has/trap-is-not-callable-using-with.js
new file mode 100644
index 0000000000..2658804db3
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Proxy/has/trap-is-not-callable-using-with.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.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]
+features: [Proxy]
+---*/
+
+var target = {};
+var p = new Proxy(target, {
+ has: {}
+});
+
+assert.throws(TypeError, function() {
+ with(p) {
+ (attr);
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Proxy/has/trap-is-not-callable.js b/js/src/tests/test262/built-ins/Proxy/has/trap-is-not-callable.js
new file mode 100644
index 0000000000..77067dd42a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Proxy/has/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.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.
+ ...
+features: [Proxy]
+---*/
+
+var target = {};
+var p = new Proxy(target, {
+ has: {}
+});
+
+assert.throws(TypeError, function() {
+ "attr" in p;
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Proxy/has/trap-is-null-target-is-proxy.js b/js/src/tests/test262/built-ins/Proxy/has/trap-is-null-target-is-proxy.js
new file mode 100644
index 0000000000..72b4443c95
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Proxy/has/trap-is-null-target-is-proxy.js
@@ -0,0 +1,46 @@
+// 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-hasproperty-p
+description: >
+ If "has" trap is null or undefined, [[HasProperty]] call is properly
+ forwarded to [[ProxyTarget]] (which is also a Proxy object).
+info: |
+ [[HasProperty]] ( P )
+
+ [...]
+ 5. Let target be O.[[ProxyTarget]].
+ 6. Let trap be ? GetMethod(handler, "has").
+ 7. If trap is undefined, then
+ a. Return ? target.[[HasProperty]](P).
+features: [Proxy, Symbol, Reflect, Array.prototype.includes]
+---*/
+
+var stringTarget = new Proxy(new String("str"), {});
+var stringProxy = new Proxy(stringTarget, {
+ get: null,
+});
+
+assert(Reflect.has(stringProxy, "length"));
+assert(0 in stringProxy);
+assert(!(4 in stringProxy));
+
+
+var sym = Symbol();
+var target = new Proxy({}, {
+ has: function(_target, key) {
+ return [sym, "6", "foo"].includes(key);
+ },
+});
+
+var proxy = new Proxy(target, {
+ get: null,
+});
+
+assert(Reflect.has(proxy, sym));
+assert("6" in proxy);
+assert("foo" in Object.create(proxy));
+assert(!("bar" in proxy));
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Proxy/has/trap-is-undefined-target-is-proxy.js b/js/src/tests/test262/built-ins/Proxy/has/trap-is-undefined-target-is-proxy.js
new file mode 100644
index 0000000000..270a17e158
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Proxy/has/trap-is-undefined-target-is-proxy.js
@@ -0,0 +1,47 @@
+// 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-hasproperty-p
+description: >
+ If "has" trap is null or undefined, [[HasProperty]] call is properly
+ forwarded to [[ProxyTarget]] (which is also a Proxy object).
+info: |
+ [[HasProperty]] ( P )
+
+ [...]
+ 5. Let target be O.[[ProxyTarget]].
+ 6. Let trap be ? GetMethod(handler, "has").
+ 7. If trap is undefined, then
+ a. Return ? target.[[HasProperty]](P).
+features: [Proxy, Reflect]
+---*/
+
+var plainObject = {
+ get 0() {
+ return 1;
+ },
+ foo: 2,
+ set bar(_value) {},
+};
+
+var plainObjectTarget = new Proxy(plainObject, {});
+var plainObjectProxy = new Proxy(plainObjectTarget, {
+ get: undefined,
+});
+
+assert(0 in Object.create(plainObjectProxy));
+assert("foo" in plainObjectProxy);
+assert(Reflect.has(plainObjectProxy, "bar"));
+
+
+var arrayTarget = new Proxy([1, 2], {});
+var arrayProxy = new Proxy(arrayTarget, {
+ get: undefined,
+});
+
+assert("length" in Object.create(arrayProxy));
+assert("1" in arrayProxy);
+assert(!("2" in arrayProxy));
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Proxy/has/trap-is-undefined-using-with.js b/js/src/tests/test262/built-ins/Proxy/has/trap-is-undefined-using-with.js
new file mode 100644
index 0000000000..5fed552af0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Proxy/has/trap-is-undefined-using-with.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: >
+ Return target.[[HasProperty]](P) if trap is undefined.
+info: |
+ [[HasProperty]] (P)
+
+ ...
+ 8. If trap is undefined, then
+ a. Return target.[[HasProperty]](P).
+ ...
+flags: [noStrict]
+features: [Proxy]
+---*/
+
+var target = Object.create(Array.prototype);
+var p = new Proxy(target, {});
+
+var foo = 3;
+with(target) {
+ assert.sameValue(length, 0);
+ assert.sameValue(foo, 3);
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Proxy/has/trap-is-undefined.js b/js/src/tests/test262/built-ins/Proxy/has/trap-is-undefined.js
new file mode 100644
index 0000000000..d19bdefc8e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Proxy/has/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.7
+description: >
+ Return target.[[HasProperty]](P) if trap is undefined.
+info: |
+ [[HasProperty]] (P)
+
+ ...
+ 8. If trap is undefined, then
+ a. Return target.[[HasProperty]](P).
+ ...
+features: [Proxy]
+---*/
+
+var target = Object.create(Array.prototype);
+var p = new Proxy(target, {});
+
+assert.sameValue(("foo" in p), false);
+assert.sameValue(("length" in p), true);
+
+reportCompare(0, 0);