Closed Bug 1436329 Opened 7 years ago Closed 7 years ago

WebIDL parser doesn't support "partial dictionary"

Categories

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

enhancement

Tracking

()

RESOLVED FIXED
mozilla65
Tracking Status
firefox65 --- fixed

People

(Reporter: ttaubert, Assigned: dpino)

References

Details

Attachments

(1 file, 2 obsolete files)

The term "partial dictionary" is defined here: https://heycam.github.io/webidl/#dfn-partial-dictionary The WebAuthn spec uses it in their extension model, all extensions are optional. https://w3c.github.io/webauthn/#dictdef-authenticationextensionsclientinputs partial dictionary AuthenticationExtensionsClientInputs { USVString appid; };
Priority: -- → P3
Actually, bumping this to P2 since this is blocking WebAuthn. Tim, is this stopping extension definitions from working?
Flags: needinfo?(ttaubert)
Priority: P3 → P2
It's not blocking, but it has made us sort of hack around it. See [1]. [1] https://searchfox.org/mozilla-central/source/dom/webidl/WebAuthentication.webidl#106
Flags: needinfo?(ttaubert)
Attachment #9026331 - Flags: review?(peterv)
Comment on attachment 9026331 [details] [diff] [review] Bug-1436329-Parse-WebIDL-partial-dictionary.patch Review of attachment 9026331 [details] [diff] [review]: ----------------------------------------------------------------- ::: dom/bindings/parser/WebIDL.py @@ +629,2 @@ > > def addExtendedAttributes(self, attrs): I don't think it makes sense to reuse IDLPartialInterfaceOrNamespace, dictionaries don't have extended attributes. Probably better to have a IDLPartialDictionary class. @@ +1845,5 @@ > self.parent = parent > self._finished = False > self.members = list(members) > + self._partialDictionaries = [] > + self._extendedAttrDict = {} Again, dictionaries don't have extended attributes. @@ +1885,5 @@ > > + # Now go ahead and merge in our partial dictionaries. > + for partial in self._partialDictionaries: > + partial.finish(scope) > + self.addExtendedAttributes(partial.propagatedExtendedAttrs) And here. @@ +1996,5 @@ > + def addPartialDictionary(self, partial): > + assert self.identifier.name == partial.identifier.name > + self._partialDictionaries.append(partial) > + > + def getExtendedAttribute(self, name): And here. @@ +5713,5 @@ > [location, identifier, members]) > > + def p_PartialDictionary(self, p): > + """ > + PartialDictionary : DICTIONARY IDENTIFIER Inheritance LBRACE DictionaryMembers RBRACE SEMICOLON This is not what's in the spec. A partial dictionary doesn't provide inheritance: PartialDictionary :: dictionary identifier { DictionaryMembers } ; ::: dom/bindings/parser/tests/test_dictionary.py @@ +49,5 @@ > + harness.check(dict1.members[2].identifier.name, "g", > + "g should come after d") > + harness.check(dict1.members[3].identifier.name, "h", > + "h should be last") > + I think you should also add a test for name duplication across normal and partial dictionary (see following test).
Attachment #9026331 - Flags: review?(peterv) → review-
Thanks for the detailed review. I updated the patch addressing the comments in https://bugzilla.mozilla.org/show_bug.cgi?id=1436329#c4
Attachment #9026331 - Attachment is obsolete: true
Attachment #9028400 - Flags: review?(peterv)
Comment on attachment 9028400 [details] [diff] [review] Bug-1436329-Parse-WebIDL-partial-dictionary.patch Review of attachment 9028400 [details] [diff] [review]: ----------------------------------------------------------------- ::: dom/bindings/parser/WebIDL.py @@ +5666,5 @@ > def handlePartialObject(self, location, identifier, nonPartialConstructor, > nonPartialConstructorArgs, > partialConstructorArgs): > """ > This handles partial objects (interfaces and namespaces) by checking for This comment needs updating (adding dictionary and IDLDictionary in the right places). @@ +5706,5 @@ > + if isinstance(nonPartialObject, IDLDictionary): > + partialDictionary = IDLPartialDictionary( > + *(partialConstructorArgs + [nonPartialObject])) > + return partialDictionary > + else: We usually don't do else after return. Please also assert here that isinstance(nonPartialObject, (IDLInterface, IDLNamespace)). ::: dom/bindings/parser/tests/test_dictionary.py @@ +82,5 @@ > + results = parser.finish() > + except: > + threw = True > + > + harness.ok(threw, "Should not allow name duplication across normal a partial dictionary") s/a/and/
Attachment #9028400 - Flags: review?(peterv) → review+
Addressed comments in latest review.
Attachment #9028400 - Attachment is obsolete: true
Attachment #9028569 - Flags: review?(peterv)
Attachment #9028569 - Flags: review?(peterv) → review+
Try seems Ok. I'd need to get the bug assigned so I can add tag :checkin-needed, or otherwise I'd someone to land it for me.
Assignee: nobody → dpino
Keywords: checkin-needed
Keywords: checkin-needed
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla65
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: