Changeset 254757 in webkit


Ignore:
Timestamp:
Jan 17, 2020 12:21:57 PM (4 years ago)
Author:
Alexey Shvayka
Message:

JSON.parse should lookup prototype chains during revival
https://bugs.webkit.org/show_bug.cgi?id=205769

Reviewed by Saam Barati.

JSTests:

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

Source/JavaScriptCore:

This patch makes JSON.parse use Get? instead of GetOwnProperty? during revival,
aligning JSC with the spec (step 1 of https://tc39.es/ecma262/#sec-internalizejsonproperty),
SpiderMonkey, and V8.

User-provided reviver can delete properties that are not yet inspected by itself,
making usage GetOwnProperty? non-compliant to the spec.

  • runtime/JSONObject.cpp:

(JSC::Walker::walk):

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r254738 r254757  
     12020-01-17  Alexey Shvayka  <shvaikalesh@gmail.com>
     2
     3        JSON.parse should lookup prototype chains during revival
     4        https://bugs.webkit.org/show_bug.cgi?id=205769
     5
     6        Reviewed by Saam Barati.
     7
     8        * test262/expectations.yaml: Mark 4 test cases as passing.
     9
    1102020-01-16  Robin Morisset  <rmorisset@apple.com>
    211
  • trunk/JSTests/test262/expectations.yaml

    r254626 r254757  
    11201120  default: 'Test262Error: Expected SameValue(«[object GeneratorFunction]», «[object GeneratorFunction]») to be true'
    11211121  strict mode: 'Test262Error: Expected SameValue(«[object GeneratorFunction]», «[object GeneratorFunction]») to be true'
    1122 test/built-ins/JSON/parse/reviver-array-get-prop-from-prototype.js:
    1123   default: 'Test262Error: Expected true but got false'
    1124   strict mode: 'Test262Error: Expected true but got false'
    11251122test/built-ins/JSON/parse/reviver-array-non-configurable-prop-create.js:
    11261123  default: 'Test262Error: Expected SameValue(«22», «2») to be true'
    11271124  strict mode: 'Test262Error: Expected SameValue(«22», «2») to be true'
    1128 test/built-ins/JSON/parse/reviver-object-get-prop-from-prototype.js:
    1129   default: 'Test262Error: Expected true but got false'
    1130   strict mode: 'Test262Error: Expected true but got false'
    11311125test/built-ins/JSON/parse/reviver-object-non-configurable-prop-create.js:
    11321126  default: 'Test262Error: Expected SameValue(«22», «2») to be true'
  • trunk/Source/JavaScriptCore/ChangeLog

    r254748 r254757  
     12020-01-17  Alexey Shvayka  <shvaikalesh@gmail.com>
     2
     3        JSON.parse should lookup prototype chains during revival
     4        https://bugs.webkit.org/show_bug.cgi?id=205769
     5
     6        Reviewed by Saam Barati.
     7
     8        This patch makes JSON.parse use [[Get]] instead of [[GetOwnProperty]] during revival,
     9        aligning JSC with the spec (step 1 of https://tc39.es/ecma262/#sec-internalizejsonproperty),
     10        SpiderMonkey, and V8.
     11
     12        User-provided `reviver` can delete properties that are not yet inspected by itself,
     13        making usage [[GetOwnProperty]] non-compliant to the spec.
     14
     15        * runtime/JSONObject.cpp:
     16        (JSC::Walker::walk):
     17
    1182020-01-17  Caio Lima  <ticaiolima@gmail.com>
    219
  • trunk/Source/JavaScriptCore/runtime/JSONObject.cpp

    r254037 r254757  
    693693                    inValue = array->getIndexQuickly(index);
    694694                else {
    695                     PropertySlot slot(array, PropertySlot::InternalMethodType::Get);
    696                     if (array->methodTable(vm)->getOwnPropertySlotByIndex(array, m_globalObject, index, slot))
    697                         inValue = slot.getValue(m_globalObject, index);
    698                     else
    699                         inValue = jsUndefined();
     695                    inValue = array->get(m_globalObject, index);
    700696                    RETURN_IF_EXCEPTION(scope, { });
    701697                }
    702                    
     698
    703699                if (inValue.isObject()) {
    704700                    stateStack.append(ArrayEndVisitMember);
     
    747743                    break;
    748744                }
    749                 PropertySlot slot(object, PropertySlot::InternalMethodType::Get);
    750                 if (object->methodTable(vm)->getOwnPropertySlot(object, m_globalObject, properties[index], slot))
    751                     inValue = slot.getValue(m_globalObject, properties[index]);
    752                 else
    753                     inValue = jsUndefined();
    754 
     745                inValue = object->get(m_globalObject, properties[index]);
    755746                // The holder may be modified by the reviver function so any lookup may throw
    756747                RETURN_IF_EXCEPTION(scope, { });
Note: See TracChangeset for help on using the changeset viewer.