-
Notifications
You must be signed in to change notification settings - Fork 53
fix(cddl): fix CDDL syntax for emulation.SetGeolocationOverrideParameters
#914
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
emulation.SetGeolocationOverrideParameters
0822eb3
to
be5410a
Compare
be5410a
to
bcfbc4b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @christian-bromann. Personally I definitely like that better. I've just a question that you can find inline.
CC @sadym-chromium and @jgraham
(coordinates: emulation.GeolocationCoordinates / null) // | ||
(error: emulation.GeolocationPositionError) | ||
), | ||
emulation.SetGeolocationOverrideParameters = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAICS this can stay as a map, or do I miss something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I think this should stay a map
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While it is possible to insert a group into a map, e.g.:
foobar = {
someGroup,
key: value
}
It is not possible to include group choices, because the map expects a single group, not a group choice expression*.
RFC 8610 (Section 3.5) says:
When a group is used as a member of a map, the entries in the group are included at that location in the map.
But that refers to a group, not a group choice. Group choices (//
) are only valid inside a group.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(emulation.SetGeolocationPosition // emulation.GeolocationPositionError)
defines a new group (due to ()
) so it is valid to put it into a map. We have other places where this works. The current PR version does provide any type for the params key.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@OrKoN it is not allowed to have a group choice (//
) between two maps ({ ... }
). This aligns with other places in the spec, e.g.
(browser.ClientWindowNamedState // browser.ClientWindowRectState)
(ref) where bothbrowser.ClientWindowNamedState
andbrowser.ClientWindowRectState
are groups (( ... )
)(network.ContinueWithAuthCredentials // network.ContinueWithAuthNoCredentials)
(ref) where also bothnetwork.ContinueWithAuthCredentials
andnetwork.ContinueWithAuthNoCredentials
are groups
The CDDL specification indirectly defines this in RFC 8610 §3.9 — Group-to-Group Composition:
The operator
//
is used to express a choice between groups. The right-hand side of the operator must be a group.
This means:
A // B
is only valid if both A and B are groups.- A map (
{ ... }
) is a type, not a group, and therefore cannot be used directly in//
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I am not following: both SetGeolocationPosition and GeolocationPositionError are groups, not maps. SetGeolocationOverrideParameters has to remain a map:
emulation.SetGeolocationOverrideParameters = {
? contexts: [+browsingContext.BrowsingContext],
? userContexts: [+browser.UserContext],
(emulation.SetGeolocationPosition // emulation.GeolocationPositionError)
}
I find the current definition of
emulation.SetGeolocationOverrideParameters
somewhat unusual and inconsistent with the style used throughout the rest of the specification.Aside from concerns about whether this is valid CDDL syntax—and the fact that some parsers may or may not support it—I recommend refactoring this definition to better align with the established structure used elsewhere in the spec. Specifically, we typically define separate types for success and error cases, then unify them with a top-level choice. For example:
Applying a similar pattern to the emulation namespace would improve readability, tooling compatibility, and consistency across the specification.
Preview | Diff