"Emulation.setUserAgentOverride" should only affect the current target
Categories
(Remote Protocol :: CDP, enhancement, P1)
Tracking
(firefox74 fixed)
Tracking | Status | |
---|---|---|
firefox74 | --- | fixed |
People
(Reporter: whimboo, Assigned: whimboo)
References
(Depends on 1 open bug, Blocks 2 open bugs)
Details
(Whiteboard: [puppeteer-beta-mvp])
Attachments
(2 files)
With bug 1595697 the Emulation.setUserAgentOverride
implementation currently doesn't only affect the active session, but Firefox globally.
To bound the method to the current session only, network events have to be listened for, and modifications to the request header have to be made. Given that most of those aren't exist yet this work needs to be done at a later time.
Assignee | ||
Updated•5 years ago
|
Assignee | ||
Comment 1•5 years ago
|
||
We should wait with this bug until all the dependencies have been implemented.
Assignee | ||
Comment 2•5 years ago
|
||
I just noticed that Juggler used the following implementation:
async setUserAgent({userAgent}) {
const docShell = this._frameTree.mainFrame().docShell();
docShell.customUserAgent = userAgent;
}
Which basically is:
https://searchfox.org/mozilla-central/rev/690e903ef689a4eca335b96bd903580394864a1c/docshell/base/nsIDocShell.idl#181-184
It means that the custom user agent gets reset with the next navigation, right? We would have to check how Chrome behaves here.
Comment 3•5 years ago
|
||
Good find.
This is also what DevTools uses and from a cursory look over their code they set it each time the docshell is loaded.
Assignee | ||
Comment 4•5 years ago
|
||
In that case we would need an internal property to hold the user agent override string, and then also apply it when the docshell is loaded. Do you have a link to their code? Which kind of event are they listen for?
Assignee | ||
Comment 5•5 years ago
|
||
Device emulation works based on the docshell. As such I have to get this fixed before I can start working on bug 1544417.
A WiP is already working.
Updated•5 years ago
|
Assignee | ||
Comment 6•5 years ago
|
||
Please note that the summary of this bug might be wrong. Setting a custom user agent might only affect the currently active target, and not the whole session. This is something which I will have to check next. I will update the bug as necessary.
Assignee | ||
Comment 7•5 years ago
|
||
Depends on D58162
Assignee | ||
Comment 8•5 years ago
|
||
Depends on D58163
Assignee | ||
Comment 9•5 years ago
|
||
Basically it is not the session which should be affected by setting the user agent, but the current target only. Different sessions actually share the same target scope, which means the set user agent.
Assignee | ||
Comment 10•5 years ago
|
||
Actually I don't think that we should make this change until bug 1605243 has been fixed.
Assignee | ||
Updated•5 years ago
|
Updated•5 years ago
|
Updated•5 years ago
|
Assignee | ||
Updated•5 years ago
|
Comment 11•5 years ago
|
||
Comment 12•5 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/a1d781ba0aa9
https://hg.mozilla.org/mozilla-central/rev/7472a5f9c6c0
Updated•4 years ago
|
Description
•