Changeset 247811 in webkit


Ignore:
Timestamp:
Jul 24, 2019 7:09:42 PM (5 years ago)
Author:
commit-queue@webkit.org
Message:

Three checks are missing in Proxy internal methods
https://bugs.webkit.org/show_bug.cgi?id=198630

Patch by Alexey Shvayka <Alexey Shvayka> on 2019-07-24
Reviewed by Darin Adler.

JSTests:

  • stress/proxy-delete.js: Assert isExtensible is called in correct order.
  • test262/expectations.yaml: Mark 6 test cases as passing.

Source/JavaScriptCore:

Add three missing checks in Proxy internal methods.
These checks are necessary to maintain the invariants of the essential internal methods.
(https://github.com/tc39/ecma262/pull/666)

  1. GetOwnProperty? shouldn't return non-configurable and non-writable descriptor when the target's property is writable.
  2. Delete? should return false when the target has property and is not extensible.
  3. DefineOwnProperty? should return true for a non-writable input descriptor when the target's property is non-configurable and writable.

Shipping in SpiderMonkey since https://hg.mozilla.org/integration/autoland/rev/3a06bc818bc4 (version 69)
Shipping in V8 since https://chromium.googlesource.com/v8/v8.git/+/e846ad9fa5109428be50b1989314e0e4e7267919

  • runtime/ProxyObject.cpp:

(JSC::ProxyObject::performInternalMethodGetOwnProperty): Add writability check.
(JSC::ProxyObject::performDelete): Add extensibility check.
(JSC::ProxyObject::performDefineOwnProperty): Add writability check.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r247724 r247811  
     12019-07-24  Alexey Shvayka  <shvaikalesh@gmail.com>
     2
     3        Three checks are missing in Proxy internal methods
     4        https://bugs.webkit.org/show_bug.cgi?id=198630
     5
     6        Reviewed by Darin Adler.
     7
     8        * stress/proxy-delete.js: Assert isExtensible is called in correct order.
     9        * test262/expectations.yaml: Mark 6 test cases as passing.
     10
    1112019-07-23  Justin Michaud  <justin_michaud@apple.com>
    212
  • trunk/JSTests/stress/proxy-delete.js

    r198813 r247811  
    9090        }
    9191        assert(threw);
     92    }
     93}
     94
     95{
     96    let target = new Proxy({}, {
     97        isExtensible: function() {
     98            throw new Error("should not be called if [[GetOwnProperty]] returns undefined");
     99        }
     100    });
     101    let proxy = new Proxy(target, {
     102        deleteProperty: function() {
     103            return true;
     104        }
     105    });
     106    for (let i = 0; i < 500; i++) {
     107        assert(delete proxy.nonExistentProperty);
     108    }
     109}
     110
     111{
     112    let calls;
     113    let target = new Proxy({}, {
     114        getOwnPropertyDescriptor: function() {
     115            calls.push('getOwnPropertyDescriptor');
     116            return { configurable: true };
     117        },
     118        isExtensible: function() {
     119            calls.push('isExtensible');
     120            return true;
     121        }
     122    });
     123    let proxy = new Proxy(target, {
     124        deleteProperty: function() {
     125            calls.push('trap');
     126            return true;
     127        }
     128    });
     129    for (let i = 0; i < 500; i++) {
     130        calls = [];
     131        assert(delete proxy.prop);
     132        assert(calls.join() == 'trap,getOwnPropertyDescriptor,isExtensible');
    92133    }
    93134}
  • trunk/JSTests/test262/expectations.yaml

    r247485 r247811  
    13441344  strict mode: 'Test262Error: Expected a TypeError but got a TypeError'
    13451345test/built-ins/Proxy/create-handler-is-revoked-proxy.js:
    1346   default: 'Test262Error: Expected a TypeError to be thrown but no exception was thrown at all'
    1347   strict mode: 'Test262Error: Expected a TypeError to be thrown but no exception was thrown at all'
    1348 test/built-ins/Proxy/defineProperty/targetdesc-not-configurable-writable-desc-not-writable.js:
    1349   default: 'Test262Error: Expected a TypeError to be thrown but no exception was thrown at all'
    1350   strict mode: 'Test262Error: Expected a TypeError to be thrown but no exception was thrown at all'
    1351 test/built-ins/Proxy/deleteProperty/targetdesc-is-configurable-target-is-not-extensible.js:
    1352   default: 'Test262Error: Expected a TypeError to be thrown but no exception was thrown at all'
    1353   strict mode: 'Test262Error: Expected a TypeError to be thrown but no exception was thrown at all'
    1354 test/built-ins/Proxy/getOwnPropertyDescriptor/resultdesc-is-not-configurable-not-writable-targetdesc-is-writable.js:
    13551346  default: 'Test262Error: Expected a TypeError to be thrown but no exception was thrown at all'
    13561347  strict mode: 'Test262Error: Expected a TypeError to be thrown but no exception was thrown at all'
  • trunk/Source/JavaScriptCore/ChangeLog

    r247801 r247811  
     12019-07-24  Alexey Shvayka  <shvaikalesh@gmail.com>
     2
     3        Three checks are missing in Proxy internal methods
     4        https://bugs.webkit.org/show_bug.cgi?id=198630
     5
     6        Reviewed by Darin Adler.
     7
     8        Add three missing checks in Proxy internal methods.
     9        These checks are necessary to maintain the invariants of the essential internal methods.
     10        (https://github.com/tc39/ecma262/pull/666)
     11
     12        1. [[GetOwnProperty]] shouldn't return non-configurable and non-writable descriptor when the target's property is writable.
     13        2. [[Delete]] should return `false` when the target has property and is not extensible.
     14        3. [[DefineOwnProperty]] should return `true` for a non-writable input descriptor when the target's property is non-configurable and writable.
     15
     16        Shipping in SpiderMonkey since https://hg.mozilla.org/integration/autoland/rev/3a06bc818bc4 (version 69)
     17        Shipping in V8 since https://chromium.googlesource.com/v8/v8.git/+/e846ad9fa5109428be50b1989314e0e4e7267919
     18
     19        * runtime/ProxyObject.cpp:
     20        (JSC::ProxyObject::performInternalMethodGetOwnProperty): Add writability check.
     21        (JSC::ProxyObject::performDelete): Add extensibility check.
     22        (JSC::ProxyObject::performDefineOwnProperty): Add writability check.
     23
    1242019-07-24  Mark Lam  <mark.lam@apple.com>
    225
  • trunk/Source/JavaScriptCore/runtime/ProxyObject.cpp

    r246346 r247811  
    288288            return false;
    289289        }
     290        if (trapResultAsDescriptor.writablePresent() && !trapResultAsDescriptor.writable() && targetPropertyDescriptor.writable()) {
     291            throwVMTypeError(exec, scope, "Result from 'getOwnPropertyDescriptor' can't be non-configurable and non-writable when the target's property is writable"_s);
     292            return false;
     293        }
    290294    }
    291295
     
    663667            return false;
    664668        }
     669        bool targetIsExtensible = target->isExtensible(exec);
     670        RETURN_IF_EXCEPTION(scope, false);
     671        if (!targetIsExtensible) {
     672            throwVMTypeError(exec, scope, "Proxy handler's 'deleteProperty' method should return false when the target has property and is not extensible"_s);
     673            return false;
     674        }
    665675    }
    666676
     
    886896        throwVMTypeError(exec, scope, "Proxy's 'defineProperty' trap did not define a non-configurable property on its target even though the input descriptor to the trap said it must do so"_s);
    887897        return false;
     898    }
     899    if (targetDescriptor.isDataDescriptor() && !targetDescriptor.configurable() && targetDescriptor.writable()) {
     900        if (descriptor.writablePresent() && !descriptor.writable()) {
     901            throwTypeError(exec, scope, "Proxy's 'defineProperty' trap returned true for a non-writable input descriptor when the target's property is non-configurable and writable"_s);
     902            return false;
     903        }
    888904    }
    889905   
Note: See TracChangeset for help on using the changeset viewer.