Add support for "platform" to Emulation.setUserAgentOverride
Categories
(Remote Protocol :: CDP, task, P3)
Tracking
(firefox80 fixed)
Tracking | Status | |
---|---|---|
firefox80 | --- | fixed |
People
(Reporter: whimboo, Assigned: gl, Mentored)
References
()
Details
(Whiteboard: [lang=js])
Attachments
(1 file)
With bug 1595697 we will get the basic implementation of Emulation.setUserAgentOverride
, which only handles the user agent.
This bug covers the addition of the platform
option. Similar to the userAgent
the platform can be set via a preference. In this case it will be general.platform.override
. It's a string preference so that the option can directly be set.
The file to make the changes can be found at:
https://searchfox.org/mozilla-central/source/remote/domains/parent/Emulation.jsm
https://searchfox.org/mozilla-central/source/remote/test/browser/emulation/browser_setUserAgentOverride.js
To get started please read:
https://firefox-source-docs.mozilla.org/remote/index.html
I will set this as mentored bug once bug 1595697 has been landed.
Reporter | ||
Comment 1•5 years ago
|
||
While testing I noticed that general.platform.override
needs a restart of the browser. This is not what users of the Chrome-DevTools-Protocol would expect.
Olli, what is the reason that the platform is not directly used? Why is a restart of Firefox necessary to actually make it active?
Comment 2•5 years ago
|
||
Needs restarting to get what behavior? Which API should get the new value?
navigator.platfom shouldn't need restart, only reloading the page.
That behavior there is for performance reasons.
We could in theory remove Constant and Cached from https://searchfox.org/mozilla-central/rev/6566d92dd46417a2f57e75c515135ebe84c9cef5/dom/webidl/Navigator.webidl#53-54
or clear the values when pref is changed.
But perhaps this is about some other API?
Reporter | ||
Comment 3•5 years ago
|
||
Ok, you are right. Not sure why it wasn't working for me yesterday. After testing right now inside of the devtools console it works all fine.
But what I basically noticed is that all the values under navigator
are cached and require a reload of the page, while in Chrome they are directly applied. Changing it in Safari's devtools causes even an automated reload of the page. I think reloading the page to get the new values should be fine, given that some website features might depend on the evaluation of those properties (userAgent, platform).
Making it not cached for Firefox would be great, but only as long as it doesn't cause any side-effects for real users.
Comment 4•5 years ago
|
||
It is rather odd from web page point of view if .platform suddenly changes, so reload kind of makes sense.
Without reload some parts of the page might think it is in plaform A but some parts use code for platform B (if there is plaform specific code).
Could we do what Safari does?
Reporter | ||
Comment 5•5 years ago
|
||
In Safari I only tried to change the platform via the devtools. Maybe those are triggering the page load automatically. I doubt that changing the underlying property directly, would be behave the same. But I cannot check that because I don't know how.
As such I would suggest that we keep what we are doing and users of Puppeteer would have to reload the page, or actually trigger a page load after a platform change.
Reporter | ||
Comment 6•5 years ago
|
||
As it turned out there are two implementations. The one from the Network domain simply redirects to the Emulation domain. Updating the bug and dependencies accordingly.
Reporter | ||
Updated•5 years ago
|
Reporter | ||
Updated•5 years ago
|
Reporter | ||
Updated•5 years ago
|
Assignee | ||
Updated•4 years ago
|
Assignee | ||
Comment 7•4 years ago
|
||
Assignee | ||
Comment 8•4 years ago
|
||
Just to circle back my current progress, I am working on a solution for Bug 1647551 since I still haven't made the test pass, and already made enough progress on the platform work that I think we will just block it on that.
Reporter | ||
Comment 9•4 years ago
|
||
Oh wow. That sounds great, and that would be indeed even better!
Assignee | ||
Comment 10•4 years ago
|
||
Comment 11•4 years ago
|
||
Pushed by gluong@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/06435d32c9fe Add support for "platform" to Emulation.setUserAgentOverride r=remote-protocol-reviewers,whimboo
Comment 12•4 years ago
|
||
bugherder |
Updated•3 years ago
|
Description
•