<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[196789] trunk/Source/JavaScriptCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/196789">196789</a></dd>
<dt>Author</dt> <dd>sbarati@apple.com</dd>
<dt>Date</dt> <dd>2016-02-18 17:07:37 -0800 (Thu, 18 Feb 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Implement Proxy.[[HasProperty]]
https://bugs.webkit.org/show_bug.cgi?id=154313

Reviewed by Filip Pizlo.

This patch is a straight forward implementation of
Proxy.[[HasProperty]] with respect to section 9.5.7
of the ECMAScript spec.
https://tc39.github.io/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-hasproperty-p

* runtime/ProxyObject.cpp:
(JSC::ProxyObject::performInternalMethodGetOwnProperty):
(JSC::ProxyObject::performHasProperty):
(JSC::ProxyObject::getOwnPropertySlotCommon):
* runtime/ProxyObject.h:
* tests/es6.yaml:
* tests/stress/proxy-basic.js:
(assert):
(let.handler.has):
* tests/stress/proxy-has-property.js: Added.
(assert):
(throw.new.Error.let.handler.get has):
(throw.new.Error):
(assert.let.handler.has):
(let.handler.has):
(getOwnPropertyDescriptor):
(i.catch):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeProxyObjectcpp">trunk/Source/JavaScriptCore/runtime/ProxyObject.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeProxyObjecth">trunk/Source/JavaScriptCore/runtime/ProxyObject.h</a></li>
<li><a href="#trunkSourceJavaScriptCoretestses6yaml">trunk/Source/JavaScriptCore/tests/es6.yaml</a></li>
<li><a href="#trunkSourceJavaScriptCoretestsstressproxybasicjs">trunk/Source/JavaScriptCore/tests/stress/proxy-basic.js</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoretestsstressproxyhaspropertyjs">trunk/Source/JavaScriptCore/tests/stress/proxy-has-property.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (196788 => 196789)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-02-19 01:03:13 UTC (rev 196788)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-02-19 01:07:37 UTC (rev 196789)
</span><span class="lines">@@ -1,5 +1,35 @@
</span><span class="cx"> 2016-02-18  Saam Barati  &lt;sbarati@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Implement Proxy.[[HasProperty]]
+        https://bugs.webkit.org/show_bug.cgi?id=154313
+
+        Reviewed by Filip Pizlo.
+
+        This patch is a straight forward implementation of
+        Proxy.[[HasProperty]] with respect to section 9.5.7
+        of the ECMAScript spec.
+        https://tc39.github.io/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-hasproperty-p
+
+        * runtime/ProxyObject.cpp:
+        (JSC::ProxyObject::performInternalMethodGetOwnProperty):
+        (JSC::ProxyObject::performHasProperty):
+        (JSC::ProxyObject::getOwnPropertySlotCommon):
+        * runtime/ProxyObject.h:
+        * tests/es6.yaml:
+        * tests/stress/proxy-basic.js:
+        (assert):
+        (let.handler.has):
+        * tests/stress/proxy-has-property.js: Added.
+        (assert):
+        (throw.new.Error.let.handler.get has):
+        (throw.new.Error):
+        (assert.let.handler.has):
+        (let.handler.has):
+        (getOwnPropertyDescriptor):
+        (i.catch):
+
+2016-02-18  Saam Barati  &lt;sbarati@apple.com&gt;
+
</ins><span class="cx">         Proxy's don't properly handle Symbols as PropertyKeys.
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=154385
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeProxyObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/ProxyObject.cpp (196788 => 196789)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/ProxyObject.cpp        2016-02-19 01:03:13 UTC (rev 196788)
+++ trunk/Source/JavaScriptCore/runtime/ProxyObject.cpp        2016-02-19 01:07:37 UTC (rev 196789)
</span><span class="lines">@@ -210,18 +210,72 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool ProxyObject::performHasProperty(ExecState* exec, PropertyName propertyName, PropertySlot&amp; slot)
+{
+    VM&amp; vm = exec-&gt;vm();
+    slot.setValue(this, None, jsUndefined()); // Nobody should rely on our value, but be safe and protect against any bad actors reading our value.
+    
+    JSValue handlerValue = this-&gt;handler();
+    if (handlerValue.isNull()) {
+        throwVMTypeError(exec, ASCIILiteral(&quot;Proxy 'handler' is null. It should be an Object.&quot;));
+        return false;
+    }
+
+    JSObject* handler = jsCast&lt;JSObject*&gt;(handlerValue);
+    CallData callData;
+    CallType callType;
+    JSValue hasMethod = handler-&gt;getMethod(exec, callData, callType, vm.propertyNames-&gt;has, ASCIILiteral(&quot;'has' property of a Proxy's handler should be callable.&quot;));
+    if (exec-&gt;hadException())
+        return false;
+    JSObject* target = this-&gt;target();
+    if (hasMethod.isUndefined())
+        return target-&gt;methodTable(vm)-&gt;getOwnPropertySlot(target, exec, propertyName, slot);
+
+    MarkedArgumentBuffer arguments;
+    arguments.append(target);
+    arguments.append(identifierToSafePublicJSValue(vm, Identifier::fromUid(&amp;vm, propertyName.uid())));
+    if (exec-&gt;hadException())
+        return false;
+    JSValue trapResult = call(exec, hasMethod, callType, callData, handler, arguments);
+    if (exec-&gt;hadException())
+        return false;
+
+    bool trapResultAsBool = trapResult.toBoolean(exec);
+    if (exec-&gt;hadException())
+        return false;
+
+    if (!trapResultAsBool) {
+        PropertyDescriptor descriptor;
+        bool isPropertyDescriptorDefined = target-&gt;getOwnPropertyDescriptor(exec, propertyName, descriptor); 
+        if (exec-&gt;hadException())
+            return false;
+        if (isPropertyDescriptorDefined) {
+            if (!descriptor.configurable()) {
+                throwVMTypeError(exec, ASCIILiteral(&quot;Proxy 'has' must return 'true' for non-configurable properties.&quot;));
+                return false;
+            }
+            if (!target-&gt;isExtensible()) {
+                throwVMTypeError(exec, ASCIILiteral(&quot;Proxy 'has' must return 'true' for a non-extensible 'target' object with a configurable property.&quot;));
+                return false;
+            }
+        }
+    }
+
+    return trapResultAsBool;
+}
+
</ins><span class="cx"> bool ProxyObject::getOwnPropertySlotCommon(ExecState* exec, PropertyName propertyName, PropertySlot&amp; slot)
</span><span class="cx"> {
</span><ins>+    slot.disableCaching();
</ins><span class="cx">     switch (slot.internalMethodType()) {
</span><span class="cx">     case PropertySlot::InternalMethodType::Get:
</span><span class="cx">         slot.setCustom(this, CustomAccessor, performProxyGet);
</span><del>-        slot.disableCaching();
</del><span class="cx">         return true;
</span><span class="cx">     case PropertySlot::InternalMethodType::GetOwnProperty:
</span><span class="cx">         return performInternalMethodGetOwnProperty(exec, propertyName, slot);
</span><ins>+    case PropertySlot::InternalMethodType::HasProperty:
+        return performHasProperty(exec, propertyName, slot);
</ins><span class="cx">     default:
</span><del>-        // FIXME: Implement Proxy.[[HasProperty]].
-        // https://bugs.webkit.org/show_bug.cgi?id=154313
</del><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeProxyObjecth"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/ProxyObject.h (196788 => 196789)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/ProxyObject.h        2016-02-19 01:03:13 UTC (rev 196788)
+++ trunk/Source/JavaScriptCore/runtime/ProxyObject.h        2016-02-19 01:07:37 UTC (rev 196789)
</span><span class="lines">@@ -65,6 +65,7 @@
</span><span class="cx"> 
</span><span class="cx">     bool getOwnPropertySlotCommon(ExecState*, PropertyName, PropertySlot&amp;);
</span><span class="cx">     bool performInternalMethodGetOwnProperty(ExecState*, PropertyName, PropertySlot&amp;);
</span><ins>+    bool performHasProperty(ExecState*, PropertyName, PropertySlot&amp;);
</ins><span class="cx"> 
</span><span class="cx">     WriteBarrier&lt;JSObject&gt; m_target;
</span><span class="cx">     WriteBarrier&lt;Unknown&gt; m_handler;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoretestses6yaml"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/tests/es6.yaml (196788 => 196789)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/es6.yaml        2016-02-19 01:03:13 UTC (rev 196788)
+++ trunk/Source/JavaScriptCore/tests/es6.yaml        2016-02-19 01:07:37 UTC (rev 196789)
</span><span class="lines">@@ -929,9 +929,9 @@
</span><span class="cx"> - path: es6/Proxy_getPrototypeOf_handler.js
</span><span class="cx">   cmd: runES6 :fail
</span><span class="cx"> - path: es6/Proxy_has_handler.js
</span><del>-  cmd: runES6 :fail
</del><ins>+  cmd: runES6 :normal
</ins><span class="cx"> - path: es6/Proxy_has_handler_instances_of_proxies.js
</span><del>-  cmd: runES6 :fail
</del><ins>+  cmd: runES6 :normal
</ins><span class="cx"> - path: es6/Proxy_internal_defineProperty_calls_[[Set]].js
</span><span class="cx">   cmd: runES6 :fail
</span><span class="cx"> - path: es6/Proxy_internal_defineProperty_calls_SetIntegrityLevel.js
</span><span class="lines">@@ -977,7 +977,7 @@
</span><span class="cx"> - path: es6/Proxy_internal_get_calls_Function.prototype.bind.js
</span><span class="cx">   cmd: runES6 :fail
</span><span class="cx"> - path: es6/Proxy_internal_get_calls_HasBinding.js
</span><del>-  cmd: runES6 :fail
</del><ins>+  cmd: runES6 :normal
</ins><span class="cx"> - path: es6/Proxy_internal_get_calls_instanceof_operator.js
</span><span class="cx">   cmd: runES6 :fail
</span><span class="cx"> - path: es6/Proxy_internal_get_calls_IteratorComplete_IteratorValue.js
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoretestsstressproxybasicjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/tests/stress/proxy-basic.js (196788 => 196789)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/stress/proxy-basic.js        2016-02-19 01:03:13 UTC (rev 196788)
+++ trunk/Source/JavaScriptCore/tests/stress/proxy-basic.js        2016-02-19 01:07:37 UTC (rev 196789)
</span><span class="lines">@@ -8,11 +8,63 @@
</span><span class="cx"> assert(Proxy.prototype === undefined);
</span><span class="cx"> 
</span><span class="cx"> {
</span><del>-    for (let i = 0; i &lt; 1000; i++)
</del><ins>+    for (let i = 0; i &lt; 100; i++)
</ins><span class="cx">         assert((new Proxy({}, {})).__proto__ === Object.prototype);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> {
</span><ins>+    for (let i = 0; i &lt; 100; i++) {
+        let threw = false;
+        try {
+            new Proxy({}, 20);
+        } catch(e) {
+            threw = true;
+            assert(e.toString() === &quot;TypeError: A Proxy's 'handler' should be an Object&quot;);
+        }
+        assert(threw);
+    }
+}
+
+{
+    for (let i = 0; i &lt; 100; i++) {
+        let threw = false;
+        try {
+            new Proxy({}, &quot;&quot;);
+        } catch(e) {
+            threw = true;
+            assert(e.toString() === &quot;TypeError: A Proxy's 'handler' should be an Object&quot;);
+        }
+        assert(threw);
+    }
+}
+
+{
+    for (let i = 0; i &lt; 100; i++) {
+        let threw = false;
+        try {
+            new Proxy(20, {});
+        } catch(e) {
+            threw = true;
+            assert(e.toString() === &quot;TypeError: A Proxy's 'target' should be an Object&quot;);
+        }
+        assert(threw);
+    }
+}
+
+{
+    for (let i = 0; i &lt; 100; i++) {
+        let threw = false;
+        try {
+            new Proxy(&quot;&quot;, {});
+        } catch(e) {
+            threw = true;
+            assert(e.toString() === &quot;TypeError: A Proxy's 'target' should be an Object&quot;);
+        }
+        assert(threw);
+    }
+}
+
+{
</ins><span class="cx">     // When we call Proxy it should throw
</span><span class="cx">     for (let i = 0; i &lt; 100; i++) {
</span><span class="cx">         let threw = false;
</span><span class="lines">@@ -282,3 +334,28 @@
</span><span class="cx">         called = false;
</span><span class="cx">     }
</span><span class="cx"> }
</span><ins>+
+{
+    let prop = Symbol();
+    let theTarget = { };
+    Object.defineProperty(theTarget, prop, {
+        enumerable: true,
+        configurable: true
+    });
+    let called = false;
+    let handler = {
+        has: function(target, propName) {
+            assert(prop === propName);
+            called = true;
+            return true;
+        }
+    };
+
+    let proxy = new Proxy(theTarget, handler);
+    for (let i = 0; i &lt; 100; i++) {
+        let result = prop in proxy;
+        assert(result);
+        assert(called);
+        called = false;
+    }
+}
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoretestsstressproxyhaspropertyjs"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/tests/stress/proxy-has-property.js (0 => 196789)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/stress/proxy-has-property.js                                (rev 0)
+++ trunk/Source/JavaScriptCore/tests/stress/proxy-has-property.js        2016-02-19 01:07:37 UTC (rev 196789)
</span><span class="lines">@@ -0,0 +1,369 @@
</span><ins>+function assert(b) {
+    if (!b)
+        throw new Error(&quot;Bad assertion.&quot;);
+}
+
+{
+    let error = null;
+    let target = {
+        x: 40
+    };
+
+    let handler = {
+        get has() {
+            error = new Error();
+            throw error;
+        }
+    };
+
+    let proxy = new Proxy(target, handler);
+    for (let i = 0; i &lt; 500; i++) {
+        let threw = false;
+        try {
+            &quot;x&quot; in proxy;
+        } catch(e) {
+            threw = true;
+            assert(e === error);
+        }
+        assert(threw);
+    }
+}
+
+{
+    let error = null;
+    let target = {
+        x: 40
+    };
+
+    let handler = {
+        has: function() {
+            error = new Error();
+            throw error;
+        }
+    };
+
+    let proxy = new Proxy(target, handler);
+    for (let i = 0; i &lt; 500; i++) {
+        let threw = false;
+        try {
+            &quot;x&quot; in proxy;
+        } catch(e) {
+            threw = true;
+            assert(e === error);
+        }
+        assert(threw);
+    }
+}
+
+{
+    let target = {
+        x: 40
+    };
+
+    let called = false;
+    let handler = {
+        has: function(theTarget, propName) {
+            called = true;
+            return propName in theTarget;
+        }
+    };
+
+    let proxy = new Proxy(target, handler);
+    for (let i = 0; i &lt; 500; i++) {
+        let result = &quot;x&quot; in proxy;
+        assert(result);
+        assert(called);
+        called = false;
+    }
+}
+
+{
+    let target = { };
+    Object.defineProperty(target, &quot;x&quot;, { enumerable: true, configurable: true, value: 45});
+
+    let called = false;
+    let handler = {
+        has: function(theTarget, propName) {
+            called = true;
+            return propName in theTarget;
+        }
+    };
+
+    let proxy = new Proxy(target, handler);
+    for (let i = 0; i &lt; 500; i++) {
+        let result = &quot;x&quot; in proxy;
+        assert(result);
+        assert(called);
+        called = false;
+    }
+}
+
+{
+    let target = { };
+    Object.defineProperty(target, &quot;x&quot;, { enumerable: true, configurable: true, value: 45});
+    let handler = { };
+
+    let proxy = new Proxy(target, handler);
+    for (let i = 0; i &lt; 500; i++) {
+        if (i % 2)
+            handler.has = null;
+        else
+            handler.has = undefined;
+        let result = &quot;x&quot; in proxy;
+        assert(result);
+    }
+}
+
+{
+    let target = { };
+    Object.defineProperty(target, &quot;x&quot;, { enumerable: true, configurable: true, value: 45});
+    let handler = {
+        has: function() {
+            return false;
+        }
+    };
+
+    let proxy = new Proxy(target, handler);
+    for (let i = 0; i &lt; 500; i++) {
+        let result = &quot;x&quot; in proxy;
+        assert(!result);
+    }
+}
+
+{
+    let target = { };
+    Object.defineProperty(target, &quot;x&quot;, { enumerable: true, configurable: false, value: 45});
+    let handler = {
+        has: function() {
+            return false;
+        }
+    };
+
+    let proxy = new Proxy(target, handler);
+    for (let i = 0; i &lt; 500; i++) {
+        let threw = false;
+        try {
+            &quot;x&quot; in proxy;
+        } catch(e) {
+            assert(e.toString() === &quot;TypeError: Proxy 'has' must return 'true' for non-configurable properties.&quot;);
+            threw = true;
+        }
+        assert(threw);
+    }
+}
+
+{
+    let target = { };
+    Object.defineProperty(target, &quot;x&quot;, { enumerable: true, configurable: false, value: 45});
+    let handler = {
+        has: function() {
+            return false;
+        }
+    };
+
+    let proxy = new Proxy(target, handler);
+    for (let i = 0; i &lt; 500; i++) {
+        let threw = false;
+        try {
+            &quot;x&quot; in proxy;
+        } catch(e) {
+            assert(e.toString() === &quot;TypeError: Proxy 'has' must return 'true' for non-configurable properties.&quot;);
+            threw = true;
+        }
+        assert(threw);
+    }
+}
+
+{
+    let target = { };
+    Object.defineProperty(target, &quot;x&quot;, { enumerable: true, configurable: false, value: 45});
+    let handler = {
+        has: function() {
+            return null;
+        }
+    };
+
+    let proxy = new Proxy(target, handler);
+    for (let i = 0; i &lt; 500; i++) {
+        let threw = false;
+        try {
+            &quot;x&quot; in proxy;
+        } catch(e) {
+            assert(e.toString() === &quot;TypeError: Proxy 'has' must return 'true' for non-configurable properties.&quot;);
+            threw = true;
+        }
+        assert(threw);
+    }
+}
+
+{
+    let target = { };
+    Object.defineProperty(target, &quot;x&quot;, { enumerable: true, configurable: false, value: 45});
+    let handler = {
+        has: function() {
+            return undefined;
+        }
+    };
+
+    let proxy = new Proxy(target, handler);
+    for (let i = 0; i &lt; 500; i++) {
+        let threw = false;
+        try {
+            &quot;x&quot; in proxy;
+        } catch(e) {
+            assert(e.toString() === &quot;TypeError: Proxy 'has' must return 'true' for non-configurable properties.&quot;);
+            threw = true;
+        }
+        assert(threw);
+    }
+}
+
+{
+    let target = { };
+    Object.defineProperty(target, &quot;x&quot;, { enumerable: true, configurable: false, value: 45});
+    let handler = {
+        has: function() {
+            return 0;
+        }
+    };
+
+    let proxy = new Proxy(target, handler);
+    for (let i = 0; i &lt; 500; i++) {
+        let threw = false;
+        try {
+            &quot;x&quot; in proxy;
+        } catch(e) {
+            assert(e.toString() === &quot;TypeError: Proxy 'has' must return 'true' for non-configurable properties.&quot;);
+            threw = true;
+        }
+        assert(threw);
+    }
+}
+
+{
+    let target = { };
+    Object.defineProperty(target, &quot;x&quot;, { enumerable: true, configurable: false, value: 45});
+    let called = false;
+    let handler = {
+        has: function() {
+            called = true;
+            return 1;
+        }
+    };
+
+    let proxy = new Proxy(target, handler);
+    for (let i = 0; i &lt; 500; i++) {
+        let result = &quot;x&quot; in proxy;
+        assert(result);
+        assert(called);
+        called = false;
+    }
+}
+
+{
+    let target = { };
+    Object.defineProperty(target, &quot;x&quot;, { enumerable: true, configurable: false, value: 45});
+    let called = false;
+    let handler = {
+        has: function() {
+            called = true;
+            return &quot;hello&quot;;
+        }
+    };
+
+    let proxy = new Proxy(target, handler);
+    for (let i = 0; i &lt; 500; i++) {
+        let result = &quot;x&quot; in proxy;
+        assert(result);
+        assert(called);
+        called = false;
+    }
+}
+
+{
+    let target = { };
+    let called = false;
+    let handler = {
+        has: function() {
+            called = true;
+            return true
+        }
+    };
+
+    let proxy = new Proxy(target, handler);
+    for (let i = 0; i &lt; 500; i++) {
+        let result = &quot;x&quot; in proxy;
+        assert(result);
+        assert(called);
+        called = false;
+    }
+}
+
+{
+    let proto = {x: 20};
+    let target = Object.create(proto);
+    assert(target.__proto__ === proto);
+    let called = false;
+    let handler = {
+        has: function(target, propName) {
+            called = true;
+            return propName in target;
+        }
+    };
+
+    let proxy = new Proxy(target, handler);
+    for (let i = 0; i &lt; 500; i++) {
+        let result = &quot;x&quot; in proxy;
+        assert(result);
+        assert(called);
+        called = false;
+    }
+}
+
+{
+    let target = {x: 20};
+    let handler = {
+        has: function(theTarget, propName) {
+            assert(theTarget === target);
+            called = true;
+            return propName in theTarget;
+        }
+    };
+    let proxy = new Proxy(target, handler);
+    let obj = Object.create(proxy);
+    assert(Reflect.getPrototypeOf(obj) === proxy);
+    let called = false;
+
+    for (let i = 0; i &lt; 500; i++) {
+        let result = &quot;x&quot; in obj;
+        assert(result);
+        assert(called);
+        called = false;
+    }
+}
+
+{
+    let error = null;
+    let target = new Proxy({}, {
+        getOwnPropertyDescriptor: function() {
+            error = new Error();
+            throw error;
+        }
+    });
+    let handler = {
+        has: function(theTarget, propName) {
+            return false;
+        }
+    };
+    let proxy = new Proxy(target, handler);
+    for (let i = 0; i &lt; 500; i++) {
+        let threw = false;
+        try {
+            &quot;foo&quot; in proxy;
+        } catch(e) {
+            assert(e === error);
+            threw = true;
+        }
+        assert(threw);
+    }
+}
</ins></span></pre>
</div>
</div>

</body>
</html>