Closed Bug 768035 Opened 12 years ago Closed 12 years ago

navigator.userAgent property is not changed when requesting desktop site

Categories

(Firefox for Android Graveyard :: General, defect)

ARM
Android
defect
Not set
normal

Tracking

(fennec+)

RESOLVED FIXED
Firefox 22
Tracking Status
fennec + ---

People

(Reporter: xti, Assigned: wesj)

References

()

Details

(Whiteboard: [rdm])

Attachments

(2 files, 4 obsolete files)

Firefox 16.0a1 (2012-06-25) Device: Galaxy Nexus OS: Android 4.0.2 Steps to reproduce: 1. Open Fennec 2. Browse to espn.go.com 3. Tap on Menu > Request Desktop Site Expected result: Desktop site version is loaded after step 3. Actual result: Mobile version is still displayed after step 3.
It's not the same mobile site; it's a less mobile optimized version (i.e, basic HTML).The same thing happens on Stock browser. Requesting the desktop site yields a more basic basic mobile site. I think this is invalid; there might not be any way around this.
This happens because ESPN uses navigator.userAgent to perform the mobile redirection in JS. Request Desktop Site changes the UA when requesting HTTP resources, but it doesn't change the navigator.userAgent property. That property comes from here: http://mxr.mozilla.org/mozilla-central/source/netwerk/protocol/http/nsHttpHandler.cpp#501 To fix this, we need to change this implementation to support tab-based UAs rather than a global preference, or resort to some nasty hack that changes this pref whenever a tab is switched. The stock browser does work correctly if you manually go to "http://espn.go.com" after switching to desktop mode.
Summary: Mobile version is loaded after enabling "Request Desktop Site" for espn.go.com → navigator.userAgent property is not changed when requesting desktop site
Whiteboard: rdm
Whiteboard: rdm → [rdm]
tracking-fennec: --- → ?
tracking-fennec: ? → 18+
Assignee: nobody → bugmail.mozilla
tracking-fennec: 18+ → +
I'm going to steal this if you don't mind. We have built in per URI useragent stuff now, so I'm hoping we can use it?
Assignee: bugmail.mozilla → wjohnston
(In reply to Wesley Johnston (:wesj) from comment #3) > I'm going to steal this if you don't mind. We have built in per URI > useragent stuff now, so I'm hoping we can use it? Is URI fine-grained enough? What is the same page is opened in two different tabs? It seems like we would need a way to set UA per docshell.
Attached patch Patch (obsolete) — Splinter Review
This should work and brings us back closer in line with what desktop/b2g use. Clobbering...
Dang it. Spoke to soon. UserAgentOverrides is called by Navigator.getUserAgent, but only to do the site specific stuff. I'm going to modify it to also do a check based on docshell that we can catch ourselves.
Attached patch Patch 1/2 (obsolete) — Splinter Review
This modifies SitesSpecificUserAgent's getUserAgentForURI to getUserAgentForURIAndDocShell to allow changes to the UA based on either URI or on tab. We made the choice to go with a per-tab request desktop site solution for Fennec at: https://bugzilla.mozilla.org/show_bug.cgi?id=790954#c15. Happy to hear about alternative ways to do this bz.
Attachment #717221 - Attachment is obsolete: true
Attachment #717261 - Flags: review?(bzbarsky)
Attached patch Patch 2/2 (obsolete) — Splinter Review
This implements a custom Fennec version of nsISiteSpecificUseAgent to send user agents based on docshell or uri. It also modifies Fennec to use UserAgentOverrides.jsm like before, so that we're more in line with other Firefox implementations.
Attachment #717262 - Flags: review?(bnicholson)
Comment on attachment 717261 [details] [diff] [review] Patch 1/2 This seems ok, but why not just use the window instead of the docshell? Does the callee actually want the docshell?
Attachment #717261 - Flags: review?(bzbarsky) → review+
Comment on attachment 717262 [details] [diff] [review] Patch 2/2 drive by > observe: function ua_observe(aSubject, aTopic, aData) { >+ let args = JSON.parse(aData); >+ let tab = BrowserApp.getTabForId(args.tabId); >+ if (tab != null) >+ tab.reloadWithMode(args.desktopMode); Can we keep and if or switch for the "DesktopMode:Change" part so we know what topic the code handles? >+ SiteSpecificUserAgent.js \ Forgot to hg add the file?
Comment on attachment 717262 [details] [diff] [review] Patch 2/2 Cancelling review for missing SiteSpecificUserAgent.js.
Attachment #717262 - Flags: review?(bnicholson)
Attached patch Patch 1/2Splinter Review
Sorry for the churn bz. I like using windows better as well.
Attachment #717261 - Attachment is obsolete: true
Attachment #718747 - Flags: review?(bzbarsky)
Attached patch Patch 2/2 (obsolete) — Splinter Review
Updated to use window instead. With missing file.
Attachment #717262 - Attachment is obsolete: true
Attachment #718749 - Flags: review?(bnicholson)
Attached patch Patch 2/2Splinter Review
Grr. Removed extra logging.
Attachment #718749 - Attachment is obsolete: true
Attachment #718749 - Flags: review?(bnicholson)
Attachment #718760 - Flags: review?(bnicholson)
Comment on attachment 718747 [details] [diff] [review] Patch 1/2 r=me
Attachment #718747 - Flags: review?(bzbarsky) → review+
Comment on attachment 718760 [details] [diff] [review] Patch 2/2 Review of attachment 718760 [details] [diff] [review]: ----------------------------------------------------------------- Nice, looks good!
Attachment #718760 - Flags: review?(bnicholson) → review+
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 22
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: