Changeset 247471 in webkit


Ignore:
Timestamp:
Jul 15, 2019 9:26:06 PM (5 years ago)
Author:
keith_miller@apple.com
Message:

A Possible Issue of Object.create method
https://bugs.webkit.org/show_bug.cgi?id=199744

Reviewed by Yusuke Suzuki.

JSTests:

  • stress/object-create-non-object-properties-parameter.js: Added.

(catch):

Source/JavaScriptCore:

We should call toObject on the properties argument if it was not undefined.
See: https://tc39.es/ecma262/#sec-object.create

  • runtime/ObjectConstructor.cpp:

(JSC::objectConstructorCreate):

LayoutTests:

Rebaseline error message due to change of error point.

  • js/Object-create-expected.txt:
Location:
trunk
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r247469 r247471  
     12019-07-15  Keith Miller  <keith_miller@apple.com>
     2
     3        A Possible Issue of Object.create method
     4        https://bugs.webkit.org/show_bug.cgi?id=199744
     5
     6        Reviewed by Yusuke Suzuki.
     7
     8        * stress/object-create-non-object-properties-parameter.js: Added.
     9        (catch):
     10
    1112019-07-15  Keith Miller  <keith_miller@apple.com>
    212
  • trunk/LayoutTests/ChangeLog

    r247468 r247471  
     12019-07-15  Keith Miller  <keith_miller@apple.com>
     2
     3        A Possible Issue of Object.create method
     4        https://bugs.webkit.org/show_bug.cgi?id=199744
     5
     6        Reviewed by Yusuke Suzuki.
     7
     8        Rebaseline error message due to change of error point.
     9
     10        * js/Object-create-expected.txt:
     11
    1122019-07-15  Saam Barati  <sbarati@apple.com>
    213
  • trunk/LayoutTests/js/Object-create-expected.txt

    r51760 r247471  
    66PASS Object.create() threw exception TypeError: Object prototype may only be an Object or null..
    77PASS Object.create('a string') threw exception TypeError: Object prototype may only be an Object or null..
    8 PASS Object.create({}, 'a string') threw exception TypeError: Property descriptor list must be an Object..
    9 PASS Object.create(null, 'a string') threw exception TypeError: Property descriptor list must be an Object..
     8PASS Object.create({}, 'a string') threw exception TypeError: Property description must be an object..
     9PASS Object.create(null, 'a string') threw exception TypeError: Property description must be an object..
    1010PASS JSON.stringify(Object.create(null,{property:{value:'foo', enumerable:true}, property2:{value:'foo', enumerable:true}})) is '{"property":"foo","property2":"foo"}'
    1111PASS JSON.stringify(Object.create({},{property:{value:'foo', enumerable:true}, property2:{value:'foo', enumerable:true}})) is '{"property":"foo","property2":"foo"}'
  • trunk/Source/JavaScriptCore/ChangeLog

    r247463 r247471  
     12019-07-15  Keith Miller  <keith_miller@apple.com>
     2
     3        A Possible Issue of Object.create method
     4        https://bugs.webkit.org/show_bug.cgi?id=199744
     5
     6        Reviewed by Yusuke Suzuki.
     7
     8        We should call toObject on the properties argument if it was not undefined.
     9        See: https://tc39.es/ecma262/#sec-object.create
     10
     11        * runtime/ObjectConstructor.cpp:
     12        (JSC::objectConstructorCreate):
     13
    1142019-07-15  Saagar Jha  <saagarjha@apple.com>
    215
  • trunk/Source/JavaScriptCore/runtime/ObjectConstructor.cpp

    r244330 r247471  
    670670    if (exec->argument(1).isUndefined())
    671671        return JSValue::encode(newObject);
    672     if (!exec->argument(1).isObject())
    673         return throwVMTypeError(exec, scope, "Property descriptor list must be an Object."_s);
    674     RELEASE_AND_RETURN(scope, JSValue::encode(defineProperties(exec, newObject, asObject(exec->argument(1)))));
     672    JSObject* properties = exec->uncheckedArgument(1).toObject(exec);
     673    RETURN_IF_EXCEPTION(scope, { });
     674
     675    RELEASE_AND_RETURN(scope, JSValue::encode(defineProperties(exec, newObject, properties)));
    675676}
    676677
Note: See TracChangeset for help on using the changeset viewer.