Closed Bug 1653296 Opened 2 years ago Closed 2 years ago

Change platform in User-Agents when desktop site is requested


(Web Compatibility :: Interventions, defect, P3)



(Not tracked)



(Reporter: petru, Assigned: denschub)




(1 file)

Issue reported on Fenix -

I think there is an experiment going related to UAs since I've seen both
User-Agent: Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) FxQuantum/80.0 AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.111 Mobile Safari/537.36

User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:79.0) Gecko/20100101 Firefox/79.0
being used.

As reported on Fenix, when accessing with the first UA, in desktop mode, only the viewport changes slightly from the mobile UX.
But when using the second UA the full desktop layout is shown.

I verified on Fennec (which allows UA changing addons) that the first UA but without the Android platform correctly gets the desktop mode.

Changing the platform used in UA is also seen on Chrome when requesting desktop mode.
Mozilla/5.0 (Linux; Android 10; Pixel 3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 Mobile Safari/537.36
changes to
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 Safari/537.36

Mike is this an experiment that's going on, or something the compat extension is responsible for changing?

Flags: needinfo?(miket)

Yeah, we ship a UA override for Baidu sites:

I guess it would be nice if our override mechanism could react to Desktop mode, let's move this bug since it seems to be specific to Baidu.

Severity: -- → S3
Component: General → Interventions
Flags: needinfo?(miket)
Priority: -- → P3
Product: GeckoView → Web Compatibility

Tom or Dennis, is it possible for us to also listen to userAgentMode changes and do something intelligent here?

Flags: needinfo?(twisniewski)
Flags: needinfo?(dschubert)

I wonder if we could simply check the value of the header here before we alter it?

That is, we could just not modify it if we notice that it's the "desktop" UA, but we're on Android?

Flags: needinfo?(twisniewski)

Hi, checking in on this -- we are trying to wrap up this work in the current sprint, which is our last sprint for the Sept. Moment release...any update?

For which release is this current sprint?
Dennis is in charge for the next set of release which is 83, with Bug 1663967
He might be able to say if doable or not in this release.

Flags: needinfo?(bfleming)

So, this whole "requesting desktop mode" appears to be happening inside android-components only, there is no real Gecko counterpart. This means that building a "nice" WebExtension API to check if we're in desktop mode is hard and would require us to add some more native code.

However, I agree with Tom here: the best solution is probably to just do User Agent sniffing. For the mobile UA. We do a relatively simple string replacement on the UA, so if we know the product is a mobile browser and the UA contains X11; Linux x86_64, we know it's in desktop mode. That's a simple check to add, so let's do that for the next release.

Assignee: nobody → dschubert
Blocks: 1663967
Flags: needinfo?(dschubert)
Attached file GitHub Pull Request

The attached PR will disable our UA interventions whenever "Request Desktop Site" is enabled.

Flags: needinfo?(bfleming)

Merged upstream.

Closed: 2 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.