Changeset 254626 in webkit


Ignore:
Timestamp:
Jan 15, 2020 11:57:38 AM (4 years ago)
Author:
Alexey Shvayka
Message:

Object.preventExtensions should throw if not successful
https://bugs.webkit.org/show_bug.cgi?id=206131

Reviewed by Ross Kirsling.

JSTests:

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

Source/JavaScriptCore:

With this change, Object.preventExtensions throws TypeError if PreventExtensions?
returns false. This is possible if Object.preventExtensions is called on a Proxy object.
(step 3 of https://tc39.es/ecma262/#sec-object.preventextensions)

  • runtime/ObjectConstructor.cpp:

(JSC::objectConstructorPreventExtensions):

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r254558 r254626  
     12020-01-15  Alexey Shvayka  <shvaikalesh@gmail.com>
     2
     3        Object.preventExtensions should throw if not successful
     4        https://bugs.webkit.org/show_bug.cgi?id=206131
     5
     6        Reviewed by Ross Kirsling.
     7
     8        * test262/expectations.yaml: Mark 2 test cases as passing.
     9
    1102020-01-14  Commit Queue  <commit-queue@webkit.org>
    211
  • trunk/JSTests/test262/expectations.yaml

    r254390 r254626  
    11661166  default: 'Test262Error: Expected SameValue(«», «x») to be true'
    11671167  strict mode: 'Test262Error: Expected SameValue(«», «x») to be true'
    1168 test/built-ins/Object/preventExtensions/throws-when-false.js:
    1169   default: 'Test262Error: Expected a TypeError to be thrown but no exception was thrown at all'
    1170   strict mode: 'Test262Error: Expected a TypeError to be thrown but no exception was thrown at all'
    11711168test/built-ins/Object/proto-from-ctor-realm.js:
    11721169  default: 'Test262Error: Expected SameValue(«[object Object]», «[object Object]») to be true'
  • trunk/Source/JavaScriptCore/ChangeLog

    r254625 r254626  
     12020-01-15  Alexey Shvayka  <shvaikalesh@gmail.com>
     2
     3        Object.preventExtensions should throw if not successful
     4        https://bugs.webkit.org/show_bug.cgi?id=206131
     5
     6        Reviewed by Ross Kirsling.
     7
     8        With this change, Object.preventExtensions throws TypeError if [[PreventExtensions]]
     9        returns `false`. This is possible if Object.preventExtensions is called on a Proxy object.
     10        (step 3 of https://tc39.es/ecma262/#sec-object.preventextensions)
     11
     12        * runtime/ObjectConstructor.cpp:
     13        (JSC::objectConstructorPreventExtensions):
     14
    1152020-01-15  Jonathan Bedard  <jbedard@apple.com>
    216
  • trunk/Source/JavaScriptCore/runtime/ObjectConstructor.cpp

    r252520 r254626  
    837837{
    838838    VM& vm = globalObject->vm();
     839    auto scope = DECLARE_THROW_SCOPE(vm);
     840
    839841    JSValue argument = callFrame->argument(0);
    840842    if (!argument.isObject())
    841843        return JSValue::encode(argument);
    842844    JSObject* object = asObject(argument);
    843     object->methodTable(vm)->preventExtensions(object, globalObject);
     845    bool status = object->methodTable(vm)->preventExtensions(object, globalObject);
     846    RETURN_IF_EXCEPTION(scope, { });
     847    if (UNLIKELY(!status))
     848        return throwVMTypeError(globalObject, scope, "Unable to prevent extension in Object.preventExtensions"_s);
    844849    return JSValue::encode(object);
    845850}
Note: See TracChangeset for help on using the changeset viewer.