Closed
Bug 814379
Opened 10 years ago
Closed 9 years ago
Firefox 17 + User agent switcher. The JS "navigator.userAgent" property is broken (it never changes)
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
RESOLVED
FIXED
mozilla23
People
(Reporter: paulo.f.oliveira, Assigned: mitchell.mebane)
References
Details
(Keywords: regression)
Attachments
(1 file, 1 obsolete file)
1.45 KB,
patch
|
dao
:
review+
|
Details | Diff | Splinter Review |
User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.14 Safari/537.17 Steps to reproduce: After an upgrade to Firefox 17.0 (on Ubuntu) I used the extension "User agent switcher" to change the user agent. Actual results: - The user agent reported to the webserver has changed. - The JS "navigator.userAgent" property was NOT changed. Expected results: Both the user agent reported to the webserver and the JS "navigator.userAgent" property should have changed to the new user agent. I tried with other extensions and none of them can change the JS "navigator.userAgent" property In Firefox 16 this worked without problems
Updated•10 years ago
|
Status: UNCONFIRMED → RESOLVED
Closed: 10 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 787798
Comment 2•10 years ago
|
||
>In Firefox 16 this worked without problems
In that case it's not a dupe, sorry
Status: RESOLVED → REOPENED
Ever confirmed: true
Resolution: DUPLICATE → ---
Comment 3•10 years ago
|
||
Same for me. In the web app I am working on, we provide an extension that changes the "general.useragent.override" preference to set it to various mobile devices user agent strings. When doing so, we get the same results: - The user agent reported to the webserver has changed. - The JS "navigator.userAgent" property was NOT changed. It worked fine with FF16 and started to fail with FF17. It still fails with FF18.
Comment 4•10 years ago
|
||
I just saw that this bug was only targeting the x86_64 linux platform. On my side, I also get it on Windows.
This happens also on MacOSX. After restarting the browser, the correct value is returned by (both) navigator.userAgent (and the HTTP header).
After modify preference "general.useragent.override"(some extension just provide a GUI to modify this). The http request header send to server is changed, but not the javascript object "navigator.userAgent", latter need to restart Firefox. Firefox 20 on Window/Linux both have this problem. But inserting, when enable "general.useragent.site_specific_overrides", then add "general.useragent.override.google.com", both http header and "navigator.userAgent" changed immediately, no need to restart.
Updated•10 years ago
|
Component: Untriaged → DOM
Product: Firefox → Core
Comment 7•10 years ago
|
||
Possibly a regression from bug 800157.
Comment 8•10 years ago
|
||
qawanted to confirm, bug 800157 sounds like it already fixed this
Keywords: qawanted
Assignee | ||
Comment 9•9 years ago
|
||
Some testing results * 17.0b1 - working immediately after setting pref * 17.0b2 - working only after restart * 19.0.2 - working only after restart * 20.0.1 - working only after restart * 21.0b6 - working only after restart * 22.0a2 20130503 - working immediately after setting pref Tested by setting general.useragent.override, then opening the Web Console and typing navigator.useragent. I guess User Agent Switcher will be broken until FF 22, because it resets general.useragent.override to default on restart.
Assignee | ||
Comment 10•9 years ago
|
||
Actually, I can't reproduce the Aurora 22 results. Maybe I accidentally restarted the browser earlier during testing. * 22.0a2 20130503 and 20130506 - working only after restart
Assignee | ||
Comment 11•9 years ago
|
||
I managed to get Firefox building, and did some bisecting. Looks like this is the breaking change: http://hg.mozilla.org/mozilla-central/rev/9f28c28e988f Looks like when navigator.userAgent is requested, and there is no site-specific override, the global UA is used. However, this is stored in a const field, so it is never update. I'm not familiar with Mercurial or the Firefox codebase, but the issue seemed simple enough, so I took a stab at a patch. It fixes the issue for me. Hopefully the formatting, etc. is at least halfway right. :)
Comment 12•9 years ago
|
||
Comment on attachment 747404 [details] [diff] [review] patch Thanks Mitchell!
Attachment #747404 -
Flags: review?(dao)
Comment 13•9 years ago
|
||
Comment on attachment 747404 [details] [diff] [review] patch >-const DEFAULT_UA = Cc["@mozilla.org/network/protocol;1?name=http"] >- .getService(Ci.nsIHttpProtocolHandler) >- .userAgent; >+const HTTP_PROTO_HANDLER = Cc["@mozilla.org/network/protocol;1?name=http"] >+ .getService(Ci.nsIHttpProtocolHandler); The last line should be indented with another eight spaces. r=me with that fixed. Thanks!
Attachment #747404 -
Flags: review?(dao) → review+
Assignee | ||
Comment 14•9 years ago
|
||
Added 8 more spaces. Is there a style guide for indentation when splitting over multiple lines? I looked around a bit but didn't see anything.
Attachment #747404 -
Attachment is obsolete: true
Assignee | ||
Updated•9 years ago
|
Attachment #747497 -
Flags: review?(dao)
Updated•9 years ago
|
Attachment #747497 -
Flags: review?(dao) → review+
Comment 15•9 years ago
|
||
(In reply to Mitchell Mebane from comment #14) > Created attachment 747497 [details] [diff] [review] > patch r2: fixed spacing > > Added 8 more spaces. > > Is there a style guide for indentation when splitting over multiple lines? Not that I know of...
Keywords: checkin-needed
Comment 16•9 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/da4ef4dc056b
Keywords: checkin-needed
Comment 17•9 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/da4ef4dc056b
Status: REOPENED → RESOLVED
Closed: 10 years ago → 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla23
Comment 18•9 years ago
|
||
While waiting for a fix... as a hack/workaround... I used an HTTPObserver to set a site specific override for every domain visited by the user (and used an event listener to clear up the resulting mess after the page is unloaded). Its not nice, but it works. observerService.addObserver(myHTTPObserver, "http-on-modify-request", false); And in the observer code; var httpChannel = subject.QueryInterface(Components.interfaces.nsIHttpChannel); prefsGUAP.setCharPref("override." + httpChannel.URI.host, myUserAgent ); Later in the page unload event listener; prefsGUAP.deleteBranch("override."); Looking forward to FF23, nice work Mitchell.
Updated•4 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•