Changeset 248880 in webkit


Ignore:
Timestamp:
Aug 19, 2019 5:56:08 PM (5 years ago)
Author:
commit-queue@webkit.org
Message:

Proxy constructor should throw if handler is revoked Proxy
https://bugs.webkit.org/show_bug.cgi?id=198755

Patch by Alexey Shvayka <Alexey Shvayka> on 2019-08-19
Reviewed by Saam Barati.

JSTests:

  • stress/proxy-revoke.js: Adjust error message.
  • test262/expectations.yaml: Mark 2 test cases as passing.

Source/JavaScriptCore:

Reword error message and check if handler is revoked Proxy.
(step 4 of https://tc39.es/ecma262/#sec-proxycreate)

  • runtime/ProxyObject.cpp:

(JSC::ProxyObject::finishCreation): Add isRevoked check.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r248878 r248880  
     12019-08-19  Alexey Shvayka  <shvaikalesh@gmail.com>
     2
     3        Proxy constructor should throw if handler is revoked Proxy
     4        https://bugs.webkit.org/show_bug.cgi?id=198755
     5
     6        Reviewed by Saam Barati.
     7
     8        * stress/proxy-revoke.js: Adjust error message.
     9        * test262/expectations.yaml: Mark 2 test cases as passing.
     10
    1112019-08-19  Yusuke Suzuki  <ysuzuki@apple.com>
    212
  • trunk/JSTests/stress/proxy-revoke.js

    r201618 r248880  
    9696            } catch(e) {
    9797                threw = true;
    98                 assert(e.toString() === "TypeError: If a Proxy's handler is another Proxy object, the other Proxy should not have been revoked");
     98                assert(e.toString() === "TypeError: A Proxy's 'target' shouldn't be a revoked Proxy");
    9999            }
    100100            assert(threw);
  • trunk/JSTests/test262/expectations.yaml

    r248876 r248880  
    13221322  default: 'Test262Error: Expected a TypeError but got a TypeError'
    13231323  strict mode: 'Test262Error: Expected a TypeError but got a TypeError'
    1324 test/built-ins/Proxy/create-handler-is-revoked-proxy.js:
    1325   default: 'Test262Error: Expected a TypeError to be thrown but no exception was thrown at all'
    1326   strict mode: 'Test262Error: Expected a TypeError to be thrown but no exception was thrown at all'
    13271324test/built-ins/RegExp/named-groups/groups-object-subclass-sans.js:
    13281325  default: 'Test262Error: Expected SameValue(«b», «$<a>») to be true'
  • trunk/Source/JavaScriptCore/ChangeLog

    r248878 r248880  
     12019-08-19  Alexey Shvayka  <shvaikalesh@gmail.com>
     2
     3        Proxy constructor should throw if handler is revoked Proxy
     4        https://bugs.webkit.org/show_bug.cgi?id=198755
     5
     6        Reviewed by Saam Barati.
     7
     8        Reword error message and check if handler is revoked Proxy.
     9        (step 4 of https://tc39.es/ecma262/#sec-proxycreate)
     10
     11        * runtime/ProxyObject.cpp:
     12        (JSC::ProxyObject::finishCreation): Add isRevoked check.
     13
    1142019-08-19  Yusuke Suzuki  <ysuzuki@apple.com>
    215
  • trunk/Source/JavaScriptCore/runtime/ProxyObject.cpp

    r248796 r248880  
    9292    }
    9393    if (ProxyObject* targetAsProxy = jsDynamicCast<ProxyObject*>(vm, target)) {
    94         if (targetAsProxy->handler().isNull()) {
    95             throwTypeError(exec, scope, "If a Proxy's handler is another Proxy object, the other Proxy should not have been revoked"_s);
     94        if (targetAsProxy->isRevoked()) {
     95            throwTypeError(exec, scope, "A Proxy's 'target' shouldn't be a revoked Proxy"_s);
    9696            return;
    9797        }
     
    100100        throwTypeError(exec, scope, "A Proxy's 'handler' should be an Object"_s);
    101101        return;
     102    }
     103    if (ProxyObject* handlerAsProxy = jsDynamicCast<ProxyObject*>(vm, handler)) {
     104        if (handlerAsProxy->isRevoked()) {
     105            throwTypeError(exec, scope, "A Proxy's 'handler' shouldn't be a revoked Proxy"_s);
     106            return;
     107        }
    102108    }
    103109
Note: See TracChangeset for help on using the changeset viewer.