-
Notifications
You must be signed in to change notification settings - Fork 51
Introduce "browsingContext.setUserAgent" command #602
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I am not sure if that would give use desired side effects? I am not sure that is really per-context because it is listed under "System state and capabilities". Also, the default User Agent value is used in https://fetch.spec.whatwg.org/#default-user-agent-value directly. I am not sure if we can redefine it from the BiDi spec or if we need some hooks into other spec. Perhaps we can use https://w3c.github.io/webdriver-bidi/#patches for that?
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.
I made some experiments and the user agent seems to be individual per context.
For example, given a page with an iframe, changing the userAgent in the iframe does not change it in the top-level context. And vice-versa.
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.
Hm, what do you mean by changing? CDP implementation is per-context but I don't think this spec change would specify that.
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.
Changing the user agent = calling https://chromedevtools.github.io/devtools-protocol/tot/Emulation/#method-setUserAgentOverride
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.
I'm not quite sure what is the AI here. Should I just change the prose to mention
fetch
?Or should we restrict it to top-level contexts only?
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.
I don't think we need to restrict to the top-level context.
I would try to define patches to the Fetch and HTML specs with hooks that would provide the fetch parameters' browsing context and the browser context of the navigator's window.
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.
@jgraham what do you think of the approach proposed by @OrKoN? Should I look into it?
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.
So FWIW it looks like gecko does restrict to the top level context. Obviously that could be changed if there's a use case for it.
I think the patch that would make sense would be to have a UA override defined on a (top-level) navigable. Then when asked to get the user agent in a specific Window you get the corresponding navigable and then (depending on the semantics we want) either go directly to it's top-level traversable and check if that has an override set, or maybe walk the parent tree looking for something with an override set. If there's no override you fall back to the default.
I think that works for requests that are kicked off from navigations or scripts running in a window. I don't know what implementations currently do for scripts running in workers, especially service workers or shared workers which could be associated with > 1 (top-level) navigable.
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.
I would find it hard to differentiate which override applies to all browsing contexts of a tab or just a specific one when we have more emulation. Maybe we should consider to only set it per top-level browsing context and that the setting bubbles down into frames as well? Here I don't see a reason why a frame should have a different user agent. Do you have an example for such a requirement?