Title: [196775] trunk/Source/_javascript_Core
Revision
196775
Author
[email protected]
Date
2016-02-18 13:55:40 -0800 (Thu, 18 Feb 2016)

Log Message

Follow up fix to Implement Proxy.[[GetOwnProperty]]
https://bugs.webkit.org/show_bug.cgi?id=154314

Reviewed by Filip Pizlo.

Part of the implementation was broken because
of how JSObject::getOwnPropertyDescriptor worked.
I've fixed JSObject::getOwnPropertyDescriptor to
be able to handle ProxyObject.

* runtime/JSObject.cpp:
(JSC::JSObject::getOwnPropertyDescriptor):
* runtime/ProxyObject.cpp:
(JSC::ProxyObject::performInternalMethodGetOwnProperty):
* tests/stress/proxy-get-own-property.js:
(assert):
(assert.let.handler.get getOwnPropertyDescriptor):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (196774 => 196775)


--- trunk/Source/_javascript_Core/ChangeLog	2016-02-18 21:30:23 UTC (rev 196774)
+++ trunk/Source/_javascript_Core/ChangeLog	2016-02-18 21:55:40 UTC (rev 196775)
@@ -1,5 +1,25 @@
 2016-02-18  Saam Barati  <[email protected]>
 
+        Follow up fix to Implement Proxy.[[GetOwnProperty]]
+        https://bugs.webkit.org/show_bug.cgi?id=154314
+
+        Reviewed by Filip Pizlo.
+
+        Part of the implementation was broken because
+        of how JSObject::getOwnPropertyDescriptor worked.
+        I've fixed JSObject::getOwnPropertyDescriptor to
+        be able to handle ProxyObject.
+
+        * runtime/JSObject.cpp:
+        (JSC::JSObject::getOwnPropertyDescriptor):
+        * runtime/ProxyObject.cpp:
+        (JSC::ProxyObject::performInternalMethodGetOwnProperty):
+        * tests/stress/proxy-get-own-property.js:
+        (assert):
+        (assert.let.handler.get getOwnPropertyDescriptor):
+
+2016-02-18  Saam Barati  <[email protected]>
+
         Implement Proxy.[[GetOwnProperty]]
         https://bugs.webkit.org/show_bug.cgi?id=154314
 

Modified: trunk/Source/_javascript_Core/runtime/JSObject.cpp (196774 => 196775)


--- trunk/Source/_javascript_Core/runtime/JSObject.cpp	2016-02-18 21:30:23 UTC (rev 196774)
+++ trunk/Source/_javascript_Core/runtime/JSObject.cpp	2016-02-18 21:55:40 UTC (rev 196775)
@@ -46,6 +46,7 @@
 #include "JSCInlines.h"
 #include "PropertyDescriptor.h"
 #include "PropertyNameArray.h"
+#include "ProxyObject.h"
 #include "Reject.h"
 #include "SlotVisitorInlines.h"
 #include <math.h>
@@ -2560,9 +2561,13 @@
     // but getOwnPropertyDescriptor() should only work for 'own' properties so we exit early if we detect that
     // the property is not an own property.
     if (slot.slotBase() != this && slot.slotBase()) {
-        auto* proxy = jsDynamicCast<JSProxy*>(this);
-        if (!proxy || proxy->target() != slot.slotBase())
-            return false;
+        JSProxy* jsProxy = jsDynamicCast<JSProxy*>(this);
+        if (!jsProxy || jsProxy->target() != slot.slotBase()) {
+            // Try ProxyObject.
+            ProxyObject* proxyObject = jsDynamicCast<ProxyObject*>(this);
+            if (!proxyObject || proxyObject->target() != slot.slotBase())
+                return false;
+        }
     }
 
     if (slot.isAccessor())

Modified: trunk/Source/_javascript_Core/runtime/ProxyObject.cpp (196774 => 196775)


--- trunk/Source/_javascript_Core/runtime/ProxyObject.cpp	2016-02-18 21:30:23 UTC (rev 196774)
+++ trunk/Source/_javascript_Core/runtime/ProxyObject.cpp	2016-02-18 21:55:40 UTC (rev 196775)
@@ -143,6 +143,8 @@
     CallData callData;
     CallType callType;
     JSValue getOwnPropertyDescriptorMethod = handler->getMethod(exec, callData, callType, makeIdentifier(vm, "getOwnPropertyDescriptor"), ASCIILiteral("'getOwnPropertyDescriptor' property of a Proxy's handler should be callable."));
+    if (exec->hadException())
+        return false;
     JSObject* target = this->target();
     if (getOwnPropertyDescriptorMethod.isUndefined())
         return target->methodTable(vm)->getOwnPropertySlot(target, exec, propertyName, slot);

Modified: trunk/Source/_javascript_Core/tests/stress/proxy-get-own-property.js (196774 => 196775)


--- trunk/Source/_javascript_Core/tests/stress/proxy-get-own-property.js	2016-02-18 21:30:23 UTC (rev 196774)
+++ trunk/Source/_javascript_Core/tests/stress/proxy-get-own-property.js	2016-02-18 21:55:40 UTC (rev 196775)
@@ -186,3 +186,27 @@
         assert(pDesc.enumerable === true);
     }
 }
+
+{
+    let target = {};
+    let error = null;
+    let handler = { get getOwnPropertyDescriptor() {
+        error = new Error("blah");
+        throw error;
+    }};
+    Object.defineProperty(target, "x", {
+        enumerable: true,
+        configurable: false
+    });
+    let proxy = new Proxy(target, handler);
+    for (let i = 0; i < 500; i++) {
+        let threw = false;
+        try {
+            let pDesc = Object.getOwnPropertyDescriptor(proxy, "x");
+        } catch(e) {
+            threw = true;
+            assert(e === error);
+        }
+        assert(threw);
+    }
+}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to