Changeset 273816 in webkit


Ignore:
Timestamp:
Mar 3, 2021 8:37:24 AM (17 months ago)
Author:
Alexey Shvayka
Message:

Add JSModuleNamespaceObject::deletePropertyByIndex() method
https://bugs.webkit.org/show_bug.cgi?id=222611

Reviewed by Yusuke Suzuki.

JSTests:

  • modules/arbitrary-module-names-indexed.js: Added.
  • modules/arbitrary-module-names/export-indexed.js: Added.

Source/JavaScriptCore:

r270923 introduced arbitrary module namespace identifiers, enabling indexed identifiers
to be exported. While they were already handled by getOwnPropertySlotByIndex(), indexed
Delete? override was absent, which prevented TypeError from being thrown.

This patch adds the missing method, aligning JSC with the spec [1].

[1]: https://tc39.es/ecma262/#sec-module-namespace-exotic-objects-delete-p

  • runtime/JSModuleNamespaceObject.cpp:

(JSC::JSModuleNamespaceObject::deleteProperty):
(JSC::JSModuleNamespaceObject::deletePropertyByIndex):

  • runtime/JSModuleNamespaceObject.h:
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r273750 r273816  
     12021-03-03  Alexey Shvayka  <shvaikalesh@gmail.com>
     2
     3        Add JSModuleNamespaceObject::deletePropertyByIndex() method
     4        https://bugs.webkit.org/show_bug.cgi?id=222611
     5
     6        Reviewed by Yusuke Suzuki.
     7
     8        * modules/arbitrary-module-names-indexed.js: Added.
     9        * modules/arbitrary-module-names/export-indexed.js: Added.
     10
    1112021-03-02  Alexey Shvayka  <shvaikalesh@gmail.com>
    212
  • trunk/Source/JavaScriptCore/ChangeLog

    r273814 r273816  
     12021-03-03  Alexey Shvayka  <shvaikalesh@gmail.com>
     2
     3        Add JSModuleNamespaceObject::deletePropertyByIndex() method
     4        https://bugs.webkit.org/show_bug.cgi?id=222611
     5
     6        Reviewed by Yusuke Suzuki.
     7
     8        r270923 introduced arbitrary module namespace identifiers, enabling indexed identifiers
     9        to be exported. While they were already handled by getOwnPropertySlotByIndex(), indexed
     10        [[Delete]] override was absent, which prevented TypeError from being thrown.
     11
     12        This patch adds the missing method, aligning JSC with the spec [1].
     13
     14        [1]: https://tc39.es/ecma262/#sec-module-namespace-exotic-objects-delete-p
     15
     16        * runtime/JSModuleNamespaceObject.cpp:
     17        (JSC::JSModuleNamespaceObject::deleteProperty):
     18        (JSC::JSModuleNamespaceObject::deletePropertyByIndex):
     19        * runtime/JSModuleNamespaceObject.h:
     20
    1212021-03-03  Don Olmstead  <don.olmstead@sony.com>
    222
  • trunk/Source/JavaScriptCore/runtime/JSModuleNamespaceObject.cpp

    r273138 r273816  
    213213bool JSModuleNamespaceObject::deleteProperty(JSCell* cell, JSGlobalObject* globalObject, PropertyName propertyName, DeletePropertySlot& slot)
    214214{
    215     // http://www.ecma-international.org/ecma-262/6.0/#sec-module-namespace-exotic-objects-delete-p
     215    // https://tc39.es/ecma262/#sec-module-namespace-exotic-objects-delete-p
    216216    JSModuleNamespaceObject* thisObject = jsCast<JSModuleNamespaceObject*>(cell);
    217217    if (propertyName.isSymbol())
     
    219219
    220220    return !thisObject->m_exports.contains(propertyName.uid());
     221}
     222
     223bool JSModuleNamespaceObject::deletePropertyByIndex(JSCell* cell, JSGlobalObject* globalObject, unsigned propertyName)
     224{
     225    VM& vm = globalObject->vm();
     226    JSModuleNamespaceObject* thisObject = jsCast<JSModuleNamespaceObject*>(cell);
     227    return !thisObject->m_exports.contains(Identifier::from(vm, propertyName).impl());
    221228}
    222229
  • trunk/Source/JavaScriptCore/runtime/JSModuleNamespaceObject.h

    r273138 r273816  
    5858    JS_EXPORT_PRIVATE static bool putByIndex(JSCell*, JSGlobalObject*, unsigned propertyName, JSValue, bool shouldThrow);
    5959    JS_EXPORT_PRIVATE static bool deleteProperty(JSCell*, JSGlobalObject*, PropertyName, DeletePropertySlot&);
     60    JS_EXPORT_PRIVATE static bool deletePropertyByIndex(JSCell*, JSGlobalObject*, unsigned propertyName);
    6061    JS_EXPORT_PRIVATE static void getOwnPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, DontEnumPropertiesMode);
    6162    JS_EXPORT_PRIVATE static bool defineOwnProperty(JSObject*, JSGlobalObject*, PropertyName, const PropertyDescriptor&, bool shouldThrow);
Note: See TracChangeset for help on using the changeset viewer.