Title: [260621] trunk
Revision
260621
Author
[email protected]
Date
2020-04-23 22:43:33 -0700 (Thu, 23 Apr 2020)

Log Message

Remove revoked Proxy checks from ProxyCreate
https://bugs.webkit.org/show_bug.cgi?id=210862

Reviewed by Ross Kirsling.

JSTests:

Removes expectations for 2 invalid ChakraCore tests.

* ChakraCore.yaml: Mark 2 test cases as passing.
* ChakraCore/test/es6/arraywithproxy.baseline: Removed.
* ChakraCore/test/es6/proxytest9.baseline: Removed.
* stress/proxy-revoke.js: Adjust test.
* test262/expectations.yaml: Mark 12 test cases as passing.

Source/_javascript_Core:

This change removes revoked Proxy checks from ProxyCreate [1], implementing
https://github.com/tc39/ecma262/pull/1814 and aligning JSC with SpiderMonkey.
Also cleans up ProxyObject creation by using isFunction() instead of
isCallable(), which are identical.

[1]: https://tc39.es/ecma262/#sec-proxycreate (steps 2, 4)

* runtime/ProxyObject.cpp:
(JSC::ProxyObject::structureForTarget):
(JSC::ProxyObject::finishCreation):

Modified Paths

Removed Paths

Diff

Deleted: trunk/JSTests/ChakraCore/test/es6/arraywithproxy.baseline (260620 => 260621)


--- trunk/JSTests/ChakraCore/test/es6/arraywithproxy.baseline	2020-04-24 05:14:22 UTC (rev 260620)
+++ trunk/JSTests/ChakraCore/test/es6/arraywithproxy.baseline	2020-04-24 05:43:33 UTC (rev 260621)
@@ -1,33 +0,0 @@
-concat test#1
-get trap: concat
-get trap: constructor
-get trap: length
-concat test#2
-get trap: concat
-get trap: constructor
-get trap: length
-has trap: 0
-get trap: 0
-has trap: 1
-get trap: 1
-has trap: 2
-get trap: 2
-has trap: 3
-get trap: 3
-unshift  test
-get trap: unshift
-get trap: length
-splice test
-get trap: splice
-get trap: length
-get trap: constructor
-has trap: 0
-get trap: 0
-has trap: 1
-get trap: 1
-has trap: 2
-get trap: 2
-has trap: 3
-get trap: 3
-delete trap: 3
-delete trap: 2

Deleted: trunk/JSTests/ChakraCore/test/es6/proxytest9.baseline (260620 => 260621)


--- trunk/JSTests/ChakraCore/test/es6/proxytest9.baseline	2020-04-24 05:14:22 UTC (rev 260620)
+++ trunk/JSTests/ChakraCore/test/es6/proxytest9.baseline	2020-04-24 05:43:33 UTC (rev 260621)
@@ -1,124 +0,0 @@
-test0 : Object.keys with symbols
-0
-test1: Object.prototype.propertyIsEnumerable
-true
-test2: Object.getOwnPropertyDescriptor
-getown
-[object Object]
-proxy getown
-getOwnPropertyDescriptor trap for prop: a
-has trap for prop :enumerable
-has trap for prop :configurable
-has trap for prop :value
-has trap for prop :writable
-has trap for prop :get
-has trap for prop :set
-plain key trap!
-getOwn
-1
-proxy key trap!
-getOwn
-1
-proxy key trap!
-getOwn :a
-1
-get trap : length
-get trap : 0
-get trap : 1
-get trap : 2
-ownKeys trap : 
-getOwnPropertyDescriptor trap : a
-getOwnPropertyDescriptor trap : b
-getOwnPropertyDescriptor trap : Symbol()
-ownKeys trap : 
-getOwnPropertyDescriptor trap : a
-getOwnPropertyDescriptor trap : b
-getOwnPropertyDescriptor trap : Symbol()
-get : bind
-get : length
-get : name
-apply
-bound test
-bound test
-test
-test called
-test called
-test called
-get trap: bind
-getPrototypeOf trap
-getOwnPropertyDescriptor trap: length
-get trap: length
-get trap: name
-true
-true
-get trap :__lookupGetter__
-getOwnPropertyDescriptor trap :A
-get trap :__lookupSetter__
-getOwnPropertyDescriptor trap :A
-123
-my proxy ownKeys
-length
-construct x1
-construct x
-f1:f2
-get trap of
-constructor trap
-1,2
-get trap from
-constructor trap
-1,2
-get trap bind
-get trap bind
-get trap length
-get trap length
-get trap name
-get trap name
-constructor trap
-constructor trap
-get trap prototype
-constructor trap
-constructor trap
-get trap prototype
-constructor trap
-true
-get trap m
-def
-ade
-b
-value : 2
-configurable : true
-writable : false
-enumerable : false
-false
-false
-expected :Proxy argument handler is not a valid object
-expected :Proxy argument target is not a valid object
-Proxy.prototype = false
-done test22
-test23 done.
-*** ownPropertyNames
-a
-*** ownPropertySymbols
-Symbol(b)
-Symbol(c)
-*** ownKeys
-a
-Symbol(b)
-Symbol(c)
-prototype
-1
-prototype
-2
-true
-hasTrap, property : p1
-hasTrap, property : p2
-deleteTrap, property : p3
-getTrap, property : bar123
-getTrap, property : foo123
-foo called
-43
-42
-expected :method  is called on a revoked Proxy object
-expected :method get is called on a revoked Proxy object
-expected :method toObject is called on a revoked Proxy object
-expected :method construct is called on a revoked Proxy object

Modified: trunk/JSTests/ChakraCore.yaml (260620 => 260621)


--- trunk/JSTests/ChakraCore.yaml	2020-04-24 05:14:22 UTC (rev 260620)
+++ trunk/JSTests/ChakraCore.yaml	2020-04-24 05:43:33 UTC (rev 260621)
@@ -1692,8 +1692,7 @@
 - path: ChakraCore/test/es6/ReflectApiTests.js
   cmd: runChakra :pass, "NoException", "", ["../UnitTestFramework/UnitTestFramework.js"]
 - path: ChakraCore/test/es6/proxyTrapConsumeNewTarget.js
-  # Different behavior.
-  cmd: runChakra :skip, "NoException", "", ["../UnitTestFramework/UnitTestFramework.js"]
+  cmd: runChakra :pass, "NoException", "", ["../UnitTestFramework/UnitTestFramework.js"]
 - path: ChakraCore/test/es6/CrossContextSpreadfunctionCall.js
   # LoadScriptFile polyfill doesn't return an object.
   cmd: runChakra :skip, "NoException", "", ["CrossContextSpreadFunction.js", "CrossContextSpreadArguments.js"]
@@ -1743,8 +1742,7 @@
 - path: ChakraCore/test/es6/proxyenumbug.js
   cmd: runChakra :skipDueToOutdatedOrBadTest, "NoException", "", []
 - path: ChakraCore/test/es6/proxy-issue884.js
-  # Different behavior.
-  cmd: runChakra :skip, "NoException", "proxy-issue884.baseline", []
+  cmd: runChakra :pass, "NoException", "proxy-issue884.baseline", []
 - path: ChakraCore/test/es6/nullPropertyDescriptor.js
   cmd: runChakra :pass, "NoException", "", []
 - path: ChakraCore/test/es6/object-is.js
@@ -1848,13 +1846,11 @@
 - path: ChakraCore/test/es6/ProxySetPrototypeOf.js
   cmd: runChakra :pass, "NoException", "", ["../UnitTestFramework/UnitTestFramework.js"]
 - path: ChakraCore/test/es6/arraywithproxy.js
-  # Different behavior, cannot convert Symbol to string. Could be bad test.
-  cmd: runChakra :skip, "NoException", "arraywithproxy.baseline", []
+  cmd: runChakra :skipDueToOutdatedOrBadTest, "NoException", "", []
 - path: ChakraCore/test/es6/proxytest8.js
   cmd: runChakra :baseline, "NoException", "proxytest8.baseline", []
 - path: ChakraCore/test/es6/proxytest9.js
-  # Different behavior.
-  cmd: runChakra :skip, "NoException", "proxytest9.baseline", []
+  cmd: runChakra :skipDueToOutdatedOrBadTest, "NoException", "", []
 - path: ChakraCore/test/es6/ES6Function_bugs.js
   cmd: runChakra :pass, "NoException", "", ["../UnitTestFramework/UnitTestFramework.js"]
 - path: ChakraCore/test/es6/OS_2700778.js

Modified: trunk/JSTests/ChangeLog (260620 => 260621)


--- trunk/JSTests/ChangeLog	2020-04-24 05:14:22 UTC (rev 260620)
+++ trunk/JSTests/ChangeLog	2020-04-24 05:43:33 UTC (rev 260621)
@@ -1,3 +1,18 @@
+2020-04-23  Alexey Shvayka  <[email protected]>
+
+        Remove revoked Proxy checks from ProxyCreate
+        https://bugs.webkit.org/show_bug.cgi?id=210862
+
+        Reviewed by Ross Kirsling.
+
+        Removes expectations for 2 invalid ChakraCore tests.
+
+        * ChakraCore.yaml: Mark 2 test cases as passing.
+        * ChakraCore/test/es6/arraywithproxy.baseline: Removed.
+        * ChakraCore/test/es6/proxytest9.baseline: Removed.
+        * stress/proxy-revoke.js: Adjust test.
+        * test262/expectations.yaml: Mark 12 test cases as passing.
+
 2020-04-23  Ross Kirsling  <[email protected]>
 
         Unreviewed test262 gardening following r260591.

Modified: trunk/JSTests/stress/proxy-revoke.js (260620 => 260621)


--- trunk/JSTests/stress/proxy-revoke.js	2020-04-24 05:14:22 UTC (rev 260620)
+++ trunk/JSTests/stress/proxy-revoke.js	2020-04-24 05:43:33 UTC (rev 260621)
@@ -95,9 +95,8 @@
                 new Proxy(proxy, {});
             } catch(e) {
                 threw = true;
-                assert(e.toString() === "TypeError: A Proxy's 'target' shouldn't be a revoked Proxy");
             }
-            assert(threw);
+            assert(!threw);
         }
         foo();
     }

Modified: trunk/JSTests/test262/expectations.yaml (260620 => 260621)


--- trunk/JSTests/test262/expectations.yaml	2020-04-24 05:14:22 UTC (rev 260620)
+++ trunk/JSTests/test262/expectations.yaml	2020-04-24 05:43:33 UTC (rev 260621)
@@ -1252,15 +1252,6 @@
 test/built-ins/Proxy/construct/trap-is-not-callable-realm.js:
   default: 'Test262Error: Expected a TypeError but got a TypeError'
   strict mode: 'Test262Error: Expected a TypeError but got a TypeError'
-test/built-ins/Proxy/create-handler-is-revoked-proxy.js:
-  default: "TypeError: A Proxy's 'handler' shouldn't be a revoked Proxy"
-  strict mode: "TypeError: A Proxy's 'handler' shouldn't be a revoked Proxy"
-test/built-ins/Proxy/create-target-is-revoked-function-proxy.js:
-  default: "TypeError: A Proxy's 'target' shouldn't be a revoked Proxy"
-  strict mode: "TypeError: A Proxy's 'target' shouldn't be a revoked Proxy"
-test/built-ins/Proxy/create-target-is-revoked-proxy.js:
-  default: "TypeError: A Proxy's 'target' shouldn't be a revoked Proxy"
-  strict mode: "TypeError: A Proxy's 'target' shouldn't be a revoked Proxy"
 test/built-ins/Proxy/get-fn-realm-recursive.js:
   default: 'Test262Error: Expected true but got false'
   strict mode: 'Test262Error: Expected true but got false'
@@ -1273,15 +1264,6 @@
 test/built-ins/Proxy/revocable/builtin.js:
   default: 'Test262Error: Expected SameValue(«true», «false») to be true'
   strict mode: 'Test262Error: Expected SameValue(«true», «false») to be true'
-test/built-ins/Proxy/revocable/handler-is-revoked-proxy.js:
-  default: "TypeError: A Proxy's 'handler' shouldn't be a revoked Proxy"
-  strict mode: "TypeError: A Proxy's 'handler' shouldn't be a revoked Proxy"
-test/built-ins/Proxy/revocable/target-is-revoked-function-proxy.js:
-  default: "TypeError: A Proxy's 'target' shouldn't be a revoked Proxy"
-  strict mode: "TypeError: A Proxy's 'target' shouldn't be a revoked Proxy"
-test/built-ins/Proxy/revocable/target-is-revoked-proxy.js:
-  default: "TypeError: A Proxy's 'target' shouldn't be a revoked Proxy"
-  strict mode: "TypeError: A Proxy's 'target' shouldn't be a revoked Proxy"
 test/built-ins/Reflect/ownKeys/order-after-define-property.js:
   default: 'Test262Error: Expected [Symbol(b), Symbol(a)] and [Symbol(a), Symbol(b)] to have the same contents. '
   strict mode: 'Test262Error: Expected [Symbol(b), Symbol(a)] and [Symbol(a), Symbol(b)] to have the same contents. '

Modified: trunk/Source/_javascript_Core/ChangeLog (260620 => 260621)


--- trunk/Source/_javascript_Core/ChangeLog	2020-04-24 05:14:22 UTC (rev 260620)
+++ trunk/Source/_javascript_Core/ChangeLog	2020-04-24 05:43:33 UTC (rev 260621)
@@ -1,3 +1,21 @@
+2020-04-23  Alexey Shvayka  <[email protected]>
+
+        Remove revoked Proxy checks from ProxyCreate
+        https://bugs.webkit.org/show_bug.cgi?id=210862
+
+        Reviewed by Ross Kirsling.
+
+        This change removes revoked Proxy checks from ProxyCreate [1], implementing
+        https://github.com/tc39/ecma262/pull/1814 and aligning JSC with SpiderMonkey.
+        Also cleans up ProxyObject creation by using isFunction() instead of
+        isCallable(), which are identical.
+
+        [1]: https://tc39.es/ecma262/#sec-proxycreate (steps 2, 4)
+
+        * runtime/ProxyObject.cpp:
+        (JSC::ProxyObject::structureForTarget):
+        (JSC::ProxyObject::finishCreation):
+
 2020-04-22  Keith Miller  <[email protected]>
 
         Fix OSR exiting/iterator object checks in for-of bytecodes

Modified: trunk/Source/_javascript_Core/runtime/ProxyObject.cpp (260620 => 260621)


--- trunk/Source/_javascript_Core/runtime/ProxyObject.cpp	2020-04-24 05:14:22 UTC (rev 260620)
+++ trunk/Source/_javascript_Core/runtime/ProxyObject.cpp	2020-04-24 05:43:33 UTC (rev 260621)
@@ -71,14 +71,8 @@
 
 Structure* ProxyObject::structureForTarget(JSGlobalObject* globalObject, JSValue target)
 {
-    if (!target.isObject())
-        return globalObject->proxyObjectStructure();
-
-    JSObject* targetAsObject = jsCast<JSObject*>(target);
-    CallData ignoredCallData;
     VM& vm = globalObject->vm();
-    bool isCallable = targetAsObject->methodTable(vm)->getCallData(targetAsObject, ignoredCallData) != CallType::None;
-    return isCallable ? globalObject->callableProxyObjectStructure() : globalObject->proxyObjectStructure();
+    return target.isFunction(vm) ? globalObject->callableProxyObjectStructure() : globalObject->proxyObjectStructure();
 }
 
 void ProxyObject::finishCreation(VM& vm, JSGlobalObject* globalObject, JSValue target, JSValue handler)
@@ -90,33 +84,20 @@
         throwTypeError(globalObject, scope, "A Proxy's 'target' should be an Object"_s);
         return;
     }
-    if (ProxyObject* targetAsProxy = jsDynamicCast<ProxyObject*>(vm, target)) {
-        if (targetAsProxy->isRevoked()) {
-            throwTypeError(globalObject, scope, "A Proxy's 'target' shouldn't be a revoked Proxy"_s);
-            return;
-        }
-    }
     if (!handler.isObject()) {
         throwTypeError(globalObject, scope, "A Proxy's 'handler' should be an Object"_s);
         return;
     }
-    if (ProxyObject* handlerAsProxy = jsDynamicCast<ProxyObject*>(vm, handler)) {
-        if (handlerAsProxy->isRevoked()) {
-            throwTypeError(globalObject, scope, "A Proxy's 'handler' shouldn't be a revoked Proxy"_s);
-            return;
-        }
-    }
 
     JSObject* targetAsObject = jsCast<JSObject*>(target);
 
-    CallData ignoredCallData;
-    m_isCallable = targetAsObject->methodTable(vm)->getCallData(targetAsObject, ignoredCallData) != CallType::None;
+    m_isCallable = targetAsObject->isFunction(vm);
     if (m_isCallable) {
         TypeInfo info = structure(vm)->typeInfo();
         RELEASE_ASSERT(info.implementsHasInstance() && info.implementsDefaultHasInstance());
     }
 
-    m_isConstructible = jsCast<JSObject*>(target)->isConstructor(vm);
+    m_isConstructible = targetAsObject->isConstructor(vm);
 
     m_target.set(vm, this, targetAsObject);
     m_handler.set(vm, this, handler);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to