Closed Bug 1595710 Opened 5 years ago Closed 4 years ago

Add support for "platform" to Emulation.setUserAgentOverride

Categories

(Remote Protocol :: CDP, task, P3)

task

Tracking

(firefox80 fixed)

RESOLVED FIXED
Firefox 80
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.

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?

Flags: needinfo?(bugs)

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?

Flags: needinfo?(bugs) → needinfo?(hskupin)

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.

Flags: needinfo?(hskupin) → needinfo?(bugs)

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?

Flags: needinfo?(bugs)

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.

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.

No longer blocks: 1549464
Depends on: 1596097
No longer depends on: 1595697
Summary: Add support for "platform" to Network.setUserAgentOverride → Add support for "platform" to Emulation.setUserAgentOverride
Mentor: hskupin
Whiteboard: [lang=js]
Blocks: 1596097
Depends on: 1595697
No longer depends on: 1596097
Component: Network → Emulation
Blocks: 1596136
Assignee: nobody → gl
Status: NEW → ASSIGNED
Blocks: 1647551

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.

Oh wow. That sounds great, and that would be indeed even better!

Blocks: 1647972
No longer blocks: 1647551
No longer blocks: 1647972
Depends on: 1647972
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
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 80
Component: CDP: Emulation → CDP
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: