Changeset 254390 in webkit


Ignore:
Timestamp:
Jan 10, 2020 7:17:59 PM (4 years ago)
Author:
Alexey Shvayka
Message:

Object.keys should throw if called on module namespace object with uninitialized binding
https://bugs.webkit.org/show_bug.cgi?id=205983

Reviewed by Yusuke Suzuki.

JSTests:

  • test262/expectations.yaml: Mark 2 test cases as passing.

Source/JavaScriptCore:

If JSModuleNamespaceObject::getOwnPropertyNames method is called by
Object.keys or for/in loop, it should invoke GetOwnProperty? on
every binding so a ReferenceError is thrown if the binding is uninitialized.

Complete call stack of internal methods and abstract ops is in "info" meta of
JSTests/test262/test/language/module-code/namespace/internals/object-keys-binding-uninit.js

  • runtime/JSModuleNamespaceObject.cpp:

(JSC::JSModuleNamespaceObject::getOwnPropertyNames):

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r254349 r254390  
     12020-01-10  Caitlin Potter  <caitp@igalia.com> and Alexey Shvayka  <shvaikalesh@gmail.com>
     2
     3        Object.keys should throw if called on module namespace object with uninitialized binding
     4        https://bugs.webkit.org/show_bug.cgi?id=205983
     5
     6        Reviewed by Yusuke Suzuki.
     7
     8        * test262/expectations.yaml: Mark 2 test cases as passing.
     9
    1102020-01-10  Saam Barati  <sbarati@apple.com>
    211
  • trunk/JSTests/test262/expectations.yaml

    r254205 r254390  
    34783478test/language/module-code/namespace/internals/get-nested-namespace-props-nrml.js:
    34793479  module: "SyntaxError: Unexpected identifier 'as'. Expected 'from' before exported module name."
    3480 test/language/module-code/namespace/internals/object-keys-binding-uninit.js:
    3481   module: 'Test262Error: Expected a ReferenceError to be thrown but no exception was thrown at all'
    34823480test/language/module-code/namespace/internals/set.js:
    34833481  module: 'Test262Error: Reflect.defineProperty: local1 Expected SameValue(«false», «true») to be true'
  • trunk/Source/JavaScriptCore/ChangeLog

    r254349 r254390  
     12020-01-10  Caitlin Potter  <caitp@igalia.com> and Alexey Shvayka  <shvaikalesh@gmail.com>
     2
     3        Object.keys should throw if called on module namespace object with uninitialized binding
     4        https://bugs.webkit.org/show_bug.cgi?id=205983
     5
     6        Reviewed by Yusuke Suzuki.
     7
     8        If JSModuleNamespaceObject::getOwnPropertyNames method is called by
     9        Object.keys or for/in loop, it should invoke [[GetOwnProperty]] on
     10        every binding so a ReferenceError is thrown if the binding is uninitialized.
     11
     12        Complete call stack of internal methods and abstract ops is in "info" meta of
     13        JSTests/test262/test/language/module-code/namespace/internals/object-keys-binding-uninit.js
     14
     15        * runtime/JSModuleNamespaceObject.cpp:
     16        (JSC::JSModuleNamespaceObject::getOwnPropertyNames):
     17
    1182020-01-10  Saam Barati  <sbarati@apple.com>
    219
  • trunk/Source/JavaScriptCore/runtime/JSModuleNamespaceObject.cpp

    r253865 r254390  
    212212void JSModuleNamespaceObject::getOwnPropertyNames(JSObject* cell, JSGlobalObject* globalObject, PropertyNameArray& propertyNames, EnumerationMode mode)
    213213{
    214     // http://www.ecma-international.org/ecma-262/6.0/#sec-module-namespace-exotic-objects-ownpropertykeys
    215     JSModuleNamespaceObject* thisObject = jsCast<JSModuleNamespaceObject*>(cell);
    216     for (const auto& name : thisObject->m_names)
     214    VM& vm = globalObject->vm();
     215    auto scope = DECLARE_THROW_SCOPE(vm);
     216
     217    // https://tc39.es/ecma262/#sec-module-namespace-exotic-objects-ownpropertykeys
     218    JSModuleNamespaceObject* thisObject = jsCast<JSModuleNamespaceObject*>(cell);
     219    for (const auto& name : thisObject->m_names) {
     220        if (!mode.includeDontEnumProperties()) {
     221            // Perform [[GetOwnProperty]] to throw ReferenceError if binding is uninitialized.
     222            PropertySlot slot(cell, PropertySlot::InternalMethodType::GetOwnProperty);
     223            thisObject->getOwnPropertySlotCommon(globalObject, name.impl(), slot);
     224            RETURN_IF_EXCEPTION(scope, void());
     225        }
    217226        propertyNames.add(name.impl());
    218     return JSObject::getOwnPropertyNames(thisObject, globalObject, propertyNames, mode);
     227    }
     228    JSObject::getOwnPropertyNames(thisObject, globalObject, propertyNames, mode);
    219229}
    220230
Note: See TracChangeset for help on using the changeset viewer.