Title: [250323] trunk
Revision
250323
Author
[email protected]
Date
2019-09-24 16:53:25 -0700 (Tue, 24 Sep 2019)

Log Message

[ES6] Come up with a test for Proxy.[[GetOwnProperty]] that tests the isExtensible error when the  result of the trap is undefined
https://bugs.webkit.org/show_bug.cgi?id=154376

Patch by Alexey Shvayka <[email protected]> on 2019-09-24
Reviewed by Ross Kirsling.

JSTests:

Adds 2 test cases:
1. If [[GetOwnProperty]] trap result is `undefined` and Proxy's target is non-extensible, TypeError is thrown.
2. If [[GetOwnProperty]] trap result is `undefined` and Proxy's target is another Proxy, its "isExtensible" trap is called.

* stress/proxy-get-own-property.js:

Source/_javascript_Core:

* runtime/ProxyObject.cpp:
(JSC::ProxyObject::performInternalMethodGetOwnProperty): Remove resolved FIXME comments.

Modified Paths

Diff

Modified: trunk/JSTests/ChangeLog (250322 => 250323)


--- trunk/JSTests/ChangeLog	2019-09-24 23:51:51 UTC (rev 250322)
+++ trunk/JSTests/ChangeLog	2019-09-24 23:53:25 UTC (rev 250323)
@@ -1,3 +1,16 @@
+2019-09-24  Alexey Shvayka  <[email protected]>
+
+        [ES6] Come up with a test for Proxy.[[GetOwnProperty]] that tests the isExtensible error when the  result of the trap is undefined
+        https://bugs.webkit.org/show_bug.cgi?id=154376
+
+        Reviewed by Ross Kirsling.
+
+        Adds 2 test cases:
+        1. If [[GetOwnProperty]] trap result is `undefined` and Proxy's target is non-extensible, TypeError is thrown.
+        2. If [[GetOwnProperty]] trap result is `undefined` and Proxy's target is another Proxy, its "isExtensible" trap is called.
+
+        * stress/proxy-get-own-property.js:
+
 2019-09-24  Caio Lima  <[email protected]>
 
         [BigInt] Add ValueBitRShift into DFG

Modified: trunk/JSTests/stress/proxy-get-own-property.js (250322 => 250323)


--- trunk/JSTests/stress/proxy-get-own-property.js	2019-09-24 23:51:51 UTC (rev 250322)
+++ trunk/JSTests/stress/proxy-get-own-property.js	2019-09-24 23:53:25 UTC (rev 250323)
@@ -69,6 +69,52 @@
 }
 
 {
+    let target = Object.preventExtensions({x: 1});
+    let handler = {
+        getOwnPropertyDescriptor: function(theTarget, propName) {
+            assert(theTarget === target);
+            assert(propName === "x");
+            return undefined;
+        }
+    };
+    let proxy = new Proxy(target, handler);
+    for (let i = 0; i < 500; i++) {
+        let threw = false;
+        try {
+            Object.getOwnPropertyDescriptor(proxy, "x");
+        } catch(e) {
+            assert(e.toString() === "TypeError: When 'getOwnPropertyDescriptor' returns undefined, the 'target' of a Proxy should be extensible");
+            threw = true;
+        }
+        assert(threw);
+    }
+}
+
+{
+    let isExtensibleTrapCalls = 0;
+    let target = new Proxy({x: 1}, {
+        isExtensible: function() {
+            isExtensibleTrapCalls++;
+            return true;
+        }
+    });
+
+    let handler = {
+        getOwnPropertyDescriptor: function(theTarget, propName) {
+            assert(theTarget === target);
+            assert(propName === "x");
+            return undefined;
+        }
+    };
+
+    let proxy = new Proxy(target, handler);
+    for (let i = 1; i <= 500; i++) {
+        assert(Object.getOwnPropertyDescriptor(proxy, "x") === undefined);
+        assert(isExtensibleTrapCalls === i);
+    }
+}
+
+{
     let target = {};
     Object.defineProperty(target, "x", {
         enumerable: true,

Modified: trunk/Source/_javascript_Core/ChangeLog (250322 => 250323)


--- trunk/Source/_javascript_Core/ChangeLog	2019-09-24 23:51:51 UTC (rev 250322)
+++ trunk/Source/_javascript_Core/ChangeLog	2019-09-24 23:53:25 UTC (rev 250323)
@@ -1,3 +1,13 @@
+2019-09-24  Alexey Shvayka  <[email protected]>
+
+        [ES6] Come up with a test for Proxy.[[GetOwnProperty]] that tests the isExtensible error when the  result of the trap is undefined
+        https://bugs.webkit.org/show_bug.cgi?id=154376
+
+        Reviewed by Ross Kirsling.
+
+        * runtime/ProxyObject.cpp:
+        (JSC::ProxyObject::performInternalMethodGetOwnProperty): Remove resolved FIXME comments.
+
 2019-09-24  Alexey Proskuryakov  <[email protected]>
 
         _javascript_Core (still) doesn't unlock the engineering keychain

Modified: trunk/Source/_javascript_Core/runtime/ProxyObject.cpp (250322 => 250323)


--- trunk/Source/_javascript_Core/runtime/ProxyObject.cpp	2019-09-24 23:51:51 UTC (rev 250322)
+++ trunk/Source/_javascript_Core/runtime/ProxyObject.cpp	2019-09-24 23:53:25 UTC (rev 250323)
@@ -259,14 +259,9 @@
             throwVMTypeError(exec, scope, "When the result of 'getOwnPropertyDescriptor' is undefined the target must be configurable"_s);
             return false;
         }
-        // FIXME: this doesn't work if 'target' is another Proxy. We don't have isExtensible implemented in a way that fits w/ Proxys.
-        // https://bugs.webkit.org/show_bug.cgi?id=154375
         bool isExtensible = target->isExtensible(exec);
         RETURN_IF_EXCEPTION(scope, false);
         if (!isExtensible) {
-            // FIXME: Come up with a test for this error. I'm not sure how to because
-            // Object.seal(o) will make all fields [[Configurable]] false.
-            // https://bugs.webkit.org/show_bug.cgi?id=154376
             throwVMTypeError(exec, scope, "When 'getOwnPropertyDescriptor' returns undefined, the 'target' of a Proxy should be extensible"_s);
             return false;
         }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to