Closed
Bug 1375829
Opened 7 years ago
Closed 6 years ago
[WebIDL] Replace serializers/jsonifiers with toJSON and [Default] extended attribute
Categories
(Core :: DOM: Bindings (WebIDL), defect, P2)
Core
DOM: Bindings (WebIDL)
Tracking
()
RESOLVED
FIXED
mozilla62
Tracking | Status | |
---|---|---|
firefox62 | --- | fixed |
People
(Reporter: tobie.langel, Assigned: bzbarsky, Mentored)
References
(Blocks 1 open bug)
Details
Attachments
(5 files)
5.58 KB,
patch
|
qdot
:
review+
|
Details | Diff | Splinter Review |
11.60 KB,
patch
|
qdot
:
review+
|
Details | Diff | Splinter Review |
4.17 KB,
patch
|
qdot
:
review+
|
Details | Diff | Splinter Review |
3.83 KB,
patch
|
qdot
:
review+
|
Details | Diff | Splinter Review |
42.34 KB,
patch
|
qdot
:
review+
|
Details | Diff | Splinter Review |
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 Steps to reproduce: We just removed serializers[1] from WebIDL and allowed editors to specify toJSON operations[2] directly instead (WebIDL treated toJSON as a reserved identifier up until now). To deal with common cases, we added a new [Default] extended attribute[3] which triggers the default toJSON operation[4] that behaves *very* similarly to how jsonifier does. All serializer-related productions were removed from the WebIDL grammar. In particular the following non-terminals: * Serializer * Serializer was also removed from the rhs expression of InterfaceMember. * SerializerRest * OperationRest * SerializationPattern * SerializationPatternMap * SerializationPatternList and the following terminals: * "serializer" in ArgumentNameKeyword. As usual, please feel free to reach out if anything needs clarification or if you have questions. Thanks! [1]: https://github.com/heycam/webidl/pull/323 [2]: https://heycam.github.io/webidl/#idl-tojson-operation [3]: https://heycam.github.io/webidl/#Default [4]]: https://heycam.github.io/webidl/#es-default-tojson
Assignee | ||
Comment 1•7 years ago
|
||
So I guess in practice we need to remove "serializer" from keywords and "SERIALIZER" from the ArgumentName production. Then we probaly want to nix jsonifier and implement the [Default] toJSON thing. And check how it differs from what we do right now. This is a pretty good bug for someone who wants to learn about our IDL parser and codegen. I'm happy to mentor.
Mentor: bzbarsky
Status: UNCONFIRMED → NEW
Ever confirmed: true
Assignee | ||
Updated•7 years ago
|
Summary: [WebIDL] Replace serializers with toJSON and [Default] extended attribute → [WebIDL] Replace serializers/jsonifiers with toJSON and [Default] extended attribute
Assignee | ||
Comment 2•7 years ago
|
||
And as an implementation note, we can probably keep most of our infrastructure in place and just make isJsonifier() test true when [Default] is used on a method called toJSON. [Default] used on anything else should fail parsing.
Comment 3•7 years ago
|
||
Hi Eden, this matches your interests. Do you wanna try this one? Hi Boris, I am inferring this is something we'd like to see happening in the near future but not with urgency, correct?
Flags: needinfo?(echuang)
Flags: needinfo?(bzbarsky)
Comment 4•7 years ago
|
||
That looks interesting to me, I will take this bug.
Flags: needinfo?(echuang)
Assignee | ||
Comment 5•7 years ago
|
||
> something we'd like to see happening in the near future but not with urgency
Exactly.
Flags: needinfo?(bzbarsky)
Updated•7 years ago
|
Priority: -- → P2
Updated•7 years ago
|
Assignee: nobody → echuang
Status: NEW → ASSIGNED
Assignee | ||
Comment 6•6 years ago
|
||
Eden is presumably not working on this (account is disabled).
Assignee: echuang → nobody
Status: ASSIGNED → NEW
Assignee | ||
Comment 7•6 years ago
|
||
The spec calls these types "JSON types".
Attachment #8976503 -
Flags: review?(kyle)
Assignee | ||
Updated•6 years ago
|
Assignee: nobody → bzbarsky
Status: NEW → ASSIGNED
Assignee | ||
Comment 8•6 years ago
|
||
Without this, we will start including mozMemory in performance.toJSON() even if the pref for it is not set, once 'object' becomes a JSON type. This changes behavior in the following observable ways: 1) We stop exposing PerformanceResourceTiming's .serverTiming in the JSON serialization in insecure contexts. 2) We stop exposing PerformanceTiming's timeToNonBlankPaint and timeToDOMContentFlushed in the JSON serialization unless the relevant preferences are turned on.
Attachment #8976504 -
Flags: review?(kyle)
Assignee | ||
Comment 9•6 years ago
|
||
Compared to the spec, we had the following differences: * Date was a JSON type in our implementation. It doesn't even exist as a type in the spec. It stops being a JSON type. * Annotated types are not supported yet. Nothing changes here. * Typedef types were not JSON types in our implementation. They become JSON types if the type it's a typedef for is one. * Frozen arrays are not supported yet. nothing changes here. * Records were not JSON types in our implementation. They become JSON types when the value type is a JSON type. * Object was not a JSON type in our implementation. It becomes a JSON type. * Interface types were only JSON types in our implementation if they had a jsonifier. We change to treating them as JSON types if there is a jsonifier anywhere on the inheritance chain. In terms of observable behavior, the following properties now get included by toJSON methods that didn't use to be included: PaymentResponse.details Performance.mozMemory both because they're of type "object".
Attachment #8976505 -
Flags: review?(kyle)
Assignee | ||
Comment 10•6 years ago
|
||
There are two restrictions: such methods must take no arguments and must return a JSON type.
Attachment #8976506 -
Flags: review?(kyle)
Assignee | ||
Comment 11•6 years ago
|
||
Attachment #8976507 -
Flags: review?(kyle)
Updated•6 years ago
|
Attachment #8976503 -
Flags: review?(kyle) → review+
Updated•6 years ago
|
Attachment #8976504 -
Flags: review?(kyle) → review+
Updated•6 years ago
|
Attachment #8976505 -
Flags: review?(kyle) → review+
Updated•6 years ago
|
Attachment #8976506 -
Flags: review?(kyle) → review+
Updated•6 years ago
|
Attachment #8976507 -
Flags: review?(kyle) → review+
Comment 12•6 years ago
|
||
Might be worth filing a followup on this for filling out the JSON type tests. Could be a good-first-bug.
Assignee | ||
Comment 13•6 years ago
|
||
> Might be worth filing a followup on this for filling out the JSON type tests. Could be a good-first-bug. Good point. Filed bug 1462537.
Comment 14•6 years ago
|
||
Pushed by bzbarsky@mozilla.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/db208ef2f3cb part 1. Rename isSerializable() to isJSONType(). r=qdot https://hg.mozilla.org/integration/mozilla-inbound/rev/5a9cdc8de26a part 2. The default binding toJSON should skip over attributes that are not exposed in the current global. r=qdot https://hg.mozilla.org/integration/mozilla-inbound/rev/3db98d12d700 part 3. Align our definition of "JSON type" with the spec. r=qdot https://hg.mozilla.org/integration/mozilla-inbound/rev/23c967ee8611 part 4. Enforce the spec restrictions on methods named toJSON(). r=qdot https://hg.mozilla.org/integration/mozilla-inbound/rev/1f3dbe030f57 part 5. Switch from using "jsonifier" syntax to the spec's "[Default] toJSON" syntax. r=qdot
Comment 15•6 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/db208ef2f3cb https://hg.mozilla.org/mozilla-central/rev/5a9cdc8de26a https://hg.mozilla.org/mozilla-central/rev/3db98d12d700 https://hg.mozilla.org/mozilla-central/rev/23c967ee8611 https://hg.mozilla.org/mozilla-central/rev/1f3dbe030f57
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
status-firefox62:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla62
Assignee | ||
Updated•6 years ago
|
Component: DOM → DOM: Bindings (WebIDL)
You need to log in
before you can comment on or make changes to this bug.
Description
•