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();
<rdar://problem/42310909>
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.
but I'm passing in an array of ['code','name','message'] as a replacer to stringify which should pluck those values out?
Ah, I missed the point. The second argument array forces us to emit properties even if it is not an own property.
Created attachment 345235 [details] Patch
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
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
Comment on attachment 345235 [details] Patch r=me
Comment on attachment 345235 [details] Patch Thank you!
Comment on attachment 345235 [details] Patch Clearing flags on attachment: 345235 Committed r233924: <https://trac.webkit.org/changeset/233924>
All reviewed patches have been landed. Closing bug.