Bug 163495

Summary: JSON.parse should modify configurable non-writable properties.
Product: WebKit Reporter: Mark Lam <mark.lam>
Component: JavaScriptCoreAssignee: Mark Lam <mark.lam>
Status: ASSIGNED    
Severity: Normal CC: fpizlo, ggaren, jfbastien, keith_miller, msaboff, saam, ysuzuki
Priority: P2    
Version: WebKit Local Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 163446    
Bug Blocks:    

Mark Lam
Reported 2016-10-15 17:15:19 PDT
This is because the JSON.parse spec (see https://tc39.github.io/ecma262/#sec-json.parse and https://tc39.github.io/ecma262/#sec-internalizejsonproperty) uses CreateDataProperty to set properties that the reviver wants to set. The CreateDataProperty spec (see https://tc39.github.io/ecma262/#sec-createdataproperty) says that it uses [[DefineOwnProperty]] to perform this set. As a result, if the property was configurable to begin with, it's [[Writable]] will be overridden to be true, and the new value should be applied.
Attachments
Mark Lam
Comment 1 2016-10-15 17:17:34 PDT
We can't do this currently achieve this for array like objects, because the existing code path that does the "put" operation does not allow us to indicate that the put with a DefineOwnProperty mode.
Mark Lam
Comment 2 2016-10-15 17:19:35 PDT
A test case in JSTests/stress/json-parse-on-non-configurable-non-writable-property.js (which should land with https://bugs.webkit.org/show_bug.cgi?id=163446) is commented out due to this bug. Please uncomment that test when this is fixed.
Note You need to log in before you can comment on or make changes to this bug.