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
>In Firefox 16 this worked without problems In that case it's not a dupe, sorry
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.
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).
Possibly a regression from bug 800157.
qawanted to confirm, bug 800157 sounds like it already fixed this
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.
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
Created attachment 747404 [details] [diff] [review] patch 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 on attachment 747404 [details] [diff] [review] patch Thanks Mitchell!
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!
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? I looked around a bit but didn't see anything.
(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...
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.