-
Notifications
You must be signed in to change notification settings - Fork 43
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
Introduce "browsingContext.setUserAgent" command #602
Conversation
07eeb19
to
e21aeb1
Compare
|
||
1. If |user agent| is not null: | ||
|
||
1. Set |context|'s [=user agent=] to |user agent|. |
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 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?
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.
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?
e21aeb1
to
438c6b7
Compare
438c6b7
to
5a6e8b3
Compare
5a6e8b3
to
db7fc48
Compare
Example patch: #538 |
Bug: #448
Preview | Diff