Closed
Bug 787798
Opened 13 years ago
Closed 10 years ago
JavaScript: `navigator.userAgent' returns the Firefox default User-Agent, instead of what is given in the `User-Agent'-HTTP-Header.
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
RESOLVED
DUPLICATE
of bug 814379
People
(Reporter: kimabrandt, Unassigned)
Details
User Agent: Mozilla/5.0 (X11; Linux i686; rv:15.0) Gecko/20100101 Firefox/15.0
Build ID: 20120824154833
Steps to reproduce:
I am using an addon to set a user-defined value for the `User-Agent'-HTTP-Header, which is sent to the server.
Actual results:
When a page is loaded and in JavaScript the `navigator.userAgent'-property is called, the Firefox default User-Agent is returned instead.
Expected results:
I was expecting the `navigator.userAgent'-property to return the same value as was sent to the server with the `User-Agent'-HTTP-Header.
Maybe this can be changed, but maybe there is a good reason - which I am not aware of - why this should not be changed!?
Updated•13 years ago
|
Status: UNCONFIRMED → RESOLVED
Closed: 13 years ago
Resolution: --- → DUPLICATE
Comment 3•13 years ago
|
||
This is a regression, this works in 10ESR
Status: RESOLVED → REOPENED
Ever confirmed: true
Resolution: DUPLICATE → ---
Comment 4•13 years ago
|
||
Däo:
Could this be a regression from your recent UA (override) changes ?
The changed UA is only applied after a restart but I failed to find a regression range with mozregression. That looks like this happens only with release builds or that I did something wrong.
Comment 5•13 years ago
|
||
(In reply to Matthias Versen (Matti) from comment #4)
> Däo:
> Could this be a regression from your recent UA (override) changes ?
Possibly bug 800157, but then it doesn't make sense that this bug was reported with Firefox 15.
Comment 6•13 years ago
|
||
(In reply to Dão Gottwald [:dao] from comment #5)
> Possibly bug 800157, but then it doesn't make sense that this bug was
> reported with Firefox 15.
It seems i screwed up with the duping of bug 814379.
Comment 7•10 years ago
|
||
Should this issue be duped to 800157?
@Dão Gottwald [:dao] : can you advise on this matter?
Flags: needinfo?(dao)
Updated•10 years ago
|
Component: Untriaged → DOM
Product: Firefox → Core
Updated•10 years ago
|
Status: REOPENED → RESOLVED
Closed: 13 years ago → 10 years ago
Flags: needinfo?(dao)
Resolution: --- → DUPLICATE
| Reporter | ||
Comment 9•10 years ago
|
||
Sorry to do this, but I'd like to reopen this bug :/ I'm not reopening it myself, since I'm not sure anymore it's really a bug!?
I should have explained exactly what my add-on is doing...
My add-on does not set the `general.useragent.override'-preference - as in bug 814379 - but sets HTTP request-headers (i.e. `User-Agent') by calling the `setRequestHeader'[1]-method on a HTTP channel. What I'm not sure about is: should a HTTP channel have an effect on the JavaScript `navigator.userAgent'-property, once a Web-page is loaded!?
Is there a better/proper way - beside any workarounds[2] - to do what I'm trying to archive?
[1] setRequestHeader() - https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIHttpChannel#setRequestHeader%28%29
[2] Pete's workaround - https://bugzilla.mozilla.org/show_bug.cgi?id=814379#c18
Comment 10•10 years ago
|
||
Apologies for pinging you again Dao. Kim's question clearly exceeds my UA knowledge at the moment.
Flags: needinfo?(dao)
Comment 11•10 years ago
|
||
(In reply to Kim A. Brandt from comment #9)
> Sorry to do this, but I'd like to reopen this bug :/ I'm not reopening it
> myself, since I'm not sure anymore it's really a bug!?
>
> I should have explained exactly what my add-on is doing...
>
> My add-on does not set the `general.useragent.override'-preference - as in
> bug 814379 - but sets HTTP request-headers (i.e. `User-Agent') by calling
> the `setRequestHeader'[1]-method on a HTTP channel. What I'm not sure about
> is: should a HTTP channel have an effect on the JavaScript
> `navigator.userAgent'-property, once a Web-page is loaded!?
No.
> Is there a better/proper way - beside any workarounds[2] - to do what I'm
> trying to archive?
What are you trying to achieve? Why are you not using general.useragent.override?
> [1] setRequestHeader() -
> https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/
> Interface/nsIHttpChannel#setRequestHeader%28%29
> [2] Pete's workaround -
> https://bugzilla.mozilla.org/show_bug.cgi?id=814379#c18
Flags: needinfo?(dao)
| Reporter | ||
Comment 12•10 years ago
|
||
(In reply to Dão Gottwald [:dao] from comment #11)
> ...
> > Is there a better/proper way - beside any workarounds[2] - to do what I'm
> > trying to archive?
>
> What are you trying to achieve? Why are you not using
> general.useragent.override?
> ...
With my add-on I can set HTTP-headers for a single request; using regular-expressions in order to match an URL. This allows me to set headers for certain requests only. I would like to be able to set the `User-Agent'-header in this way, without having to set/override it globally (sets User-Agent for all requests).
Does this make sense, or am I the only one with such an use-case?
Comment 13•10 years ago
|
||
You should use UserAgentOverrides.jsm for that. See for instance the patch in bug 788422 or this code: http://hg.mozilla.org/mozilla-central/annotate/6fa2ab99f52f/mobile/android/chrome/content/browser.js#l3269
| Reporter | ||
Comment 14•10 years ago
|
||
(In reply to Dão Gottwald [:dao] from comment #13)
> You should use UserAgentOverrides.jsm for that. See for instance the patch
> ...
OK. I will use that. Thank you for the links.
| Assignee | ||
Updated•6 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•