Closed Bug 1436308 Opened 2 years ago Closed 2 years ago

Generate a ToJSON() method for types with records

Categories

(Core :: DOM: Bindings (WebIDL), enhancement)

enhancement
Not set

Tracking

()

RESOLVED FIXED
mozilla60
Tracking Status
firefox60 --- fixed

People

(Reporter: ttaubert, Assigned: ttaubert)

References

Details

Attachments

(1 file)

Over in bug 1406458, we want to implement WebAuthn extensions, with the following WebIDL snippet:

> typedef record<DOMString, DOMString> AuthenticationExtensionsAuthenticatorInputs;
> 
> dictionary CollectedClientData {
>     /* ... */
>     AuthenticationExtensionsAuthenticatorInputs authenticatorExtensions;
> };

CollectedClientData has a ToJSON() method today. With this change to the WebIDL Codegen.py's typeSafeToJSONify() returns false because it doesn't allow record<K, V> members.

It seems to me that records should be safe to convert to JSON, as long as the value type itself is. The key type is always a DOMString, USVString, or ByteString (per spec).
Boris, what do you think? This would be a simple change, if you can confirm this is safe to do.
Attachment #8948943 - Flags: review?(bzbarsky)
Comment on attachment 8948943 [details] [diff] [review]
0001-Bug-1436308-Generate-a-ToJSON-method-for-types-with-.patch

It looks like https://github.com/heycam/webidl/pull/323 stealth-added records to serializable types without notifying anyone. :(

r=me; this looks good.
Attachment #8948943 - Flags: review?(bzbarsky) → review+
Thank you!
Pushed by ttaubert@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/13e0088b85fd
Generate a ToJSON() method for WebIDL types with records r=bz
Assignee: nobody → ttaubert
Status: NEW → ASSIGNED
https://hg.mozilla.org/mozilla-central/rev/13e0088b85fd
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla60
You need to log in before you can comment on or make changes to this bug.