WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
187724
JSON.stringify should emit non own properties if second array argument includes
https://bugs.webkit.org/show_bug.cgi?id=187724
Summary
JSON.stringify should emit non own properties if second array argument includes
zac spitzer
Reported
2018-07-16 19:43:52 PDT
The following test case produces an empty object in Webkit
https://jsbin.com/qiluqen/edit?js,console
Firefox, Edge and Chrome all output an object with three properties function createSyntaxException() { try { // trigger a DOMException document.querySelectorAll("div:foo"); } catch(e) { // this produces an empty object in webkit var err = JSON.parse( JSON.stringify(e, ['code','name','message'] ) ); console.log(err); console.log(JSON.stringify(err)); var err2 = { code: e.code, name: e.name, message: e.message }; console.log(err2); } } throw createSyntaxException();
Attachments
Patch
(8.92 KB, patch)
2018-07-18 04:01 PDT
,
Yusuke Suzuki
no flags
Details
Formatted Diff
Diff
Archive of layout-test-results from ews206 for win-future
(13.11 MB, application/zip)
2018-07-18 05:37 PDT
,
EWS Watchlist
no flags
Details
View All
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2018-07-17 16:56:03 PDT
<
rdar://problem/42310909
>
Yusuke Suzuki
Comment 2
2018-07-17 17:22:14 PDT
It seems that WebKit behavior is correct, but I would like to hear opinions from binding folks. My understanding is the following. According to DOMException's IDL, defined in WebIDL.
https://heycam.github.io/webidl/#idl-DOMException
interface DOMException { // but see below note about ECMAScript binding readonly attribute DOMString name; readonly attribute DOMString message; readonly attribute unsigned short code; const unsigned short INDEX_SIZE_ERR = 1; ... This definition says that "name", "message", and "code" are readonly attributes. So they should be defined as getters in DOMException.prototype. From the point of view of JSC, this makes `JSON.stringify(error)` empty since "name", "message", and "code" are not own properties.
zac spitzer
Comment 3
2018-07-17 20:22:30 PDT
but I'm passing in an array of ['code','name','message'] as a replacer to stringify which should pluck those values out?
Yusuke Suzuki
Comment 4
2018-07-17 23:33:54 PDT
Ah, I missed the point. The second argument array forces us to emit properties even if it is not an own property.
Yusuke Suzuki
Comment 5
2018-07-18 04:01:28 PDT
Created
attachment 345235
[details]
Patch
EWS Watchlist
Comment 6
2018-07-18 05:37:24 PDT
Comment on
attachment 345235
[details]
Patch
Attachment 345235
[details]
did not pass win-ews (win): Output:
https://webkit-queues.webkit.org/results/8573642
New failing tests: http/tests/security/local-video-source-from-remote.html
EWS Watchlist
Comment 7
2018-07-18 05:37:37 PDT
Created
attachment 345237
[details]
Archive of layout-test-results from ews206 for win-future The attached test failures were seen while running run-webkit-tests on the win-ews. Bot: ews206 Port: win-future Platform: CYGWIN_NT-6.1-2.9.0-0.318-5-3-x86_64-64bit
Mark Lam
Comment 8
2018-07-18 11:42:05 PDT
Comment on
attachment 345235
[details]
Patch r=me
Yusuke Suzuki
Comment 9
2018-07-18 11:45:09 PDT
Comment on
attachment 345235
[details]
Patch Thank you!
WebKit Commit Bot
Comment 10
2018-07-18 12:01:41 PDT
Comment on
attachment 345235
[details]
Patch Clearing flags on attachment: 345235 Committed
r233924
: <
https://trac.webkit.org/changeset/233924
>
WebKit Commit Bot
Comment 11
2018-07-18 12:01:43 PDT
All reviewed patches have been landed. Closing bug.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug