Closed Bug 933959 Opened 6 years ago Closed 6 years ago

general.useragent.override.[domain] (about:config entry) stopped working

Categories

(Firefox :: General, defect)

25 Branch
x86_64
Windows 7
defect
Not set

Tracking

()

VERIFIED WONTFIX
Tracking Status
firefox25 --- affected
firefox-esr17 --- unaffected
firefox-esr24 --- unaffected

People

(Reporter: tustamido, Unassigned)

References

Details

(Keywords: regression)

Attachments

(2 files)

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Firefox/24.0 (Beta/Release)
Build ID: 20130910160258

Steps to reproduce:

- Open about:config and create new string named:
general.useragent.override.useragentstring.com

- Set any value for it.

- Open http://www.useragentstring.com/


Actual results:

http://www.useragentstring.com/ shows Firefox 25 user agent string


Expected results:

Must show the value assigned to general.useragent.override.useragentstring.com

Until Firefox 24, general.useragent.override.[domain] set user agent string for specific domain.

But it doesn't work in Firefox 25.

Only general override (general.useragent.override, without domain) still working.
Regression window(m-c)
Good:
http://hg.mozilla.org/mozilla-central/rev/60bf7ceba890
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20130730 Firefox/25.0 ID:20130730150751
Bad:
http://hg.mozilla.org/mozilla-central/rev/c2b375f3a909
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20130730 Firefox/25.0 ID:20130730183054
Pushlog;
http://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=60bf7ceba890&tochange=c2b375f3a909


Regression window(m-i)
Good:
http://hg.mozilla.org/integration/mozilla-inbound/rev/6c88cddc6d89
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20130730 Firefox/25.0 ID:20130730133950
Bad:
http://hg.mozilla.org/integration/mozilla-inbound/rev/76a31c4050cc
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20130730 Firefox/25.0 ID:20130730135150
Pushlog;
http://hg.mozilla.org/integration/mozilla-inbound/pushloghtml?fromchange=6c88cddc6d89&tochange=76a31c4050cc
Regressed by:
76a31c4050cc	Dão Gottwald — Bug 896114 - Don't initialize UserAgentOverrides on desktop. r=dolske
Blocks: 896114
Status: UNCONFIRMED → NEW
Component: Untriaged → Networking
Ever confirmed: true
Keywords: regression
Product: Firefox → Core
We intentionally don't initialize the UserAgentOverrides module on desktop anymore. If you want to use it, you need an add-on for that.
Status: NEW → RESOLVED
Closed: 6 years ago
Component: Networking → General
Product: Core → Firefox
Resolution: --- → WONTFIX
Duplicate of this bug: 934416
Duplicate of this bug: 936482
Is there a good reason to not reinitialize the module?
(In reply to Dão Gottwald [:dao] from comment #2)
> We intentionally don't initialize the UserAgentOverrides module on desktop
> anymore. If you want to use it, you need an add-on for that.

Please explain this decision, and re-open this bug as a wishlist item.  I shouldn't have to install another memory-hogging extension if this functionality is already built-in to Firefox.  Also, why does the pref "general.useragent.site_specific_overrides" exist as a default on Desktop?  This is extremely confusing.
This seems to have been previously discussed in bug 896114. The reason behind wanting to disable it is that it would take 9% of the load time of a page with 6000 images.

Still, it's a trade-off. I wonder why isn't this disabled *unless* there are domain-specific overrides. Because, yes, it is simpler to get rid of the problem by not shipping the code or not enabling it at all, but that removes the feature...

For example, I don't think I've noticed the user agent overrides slowing down my browsing, but I have noticed, say, Google's AJAX slowing down things. And I tend to disable part of that AJAX by sending a different User-Agent to Google.

I guess someone could try to optimize it, but whether it is worth it depends on whether mozilla is willing to enable it again if someone does that work.
(In reply to Nuno Silva from comment #7)
> This seems to have been previously discussed in bug 896114. The reason
> behind wanting to disable it is that it would take 9% of the load time of a
> page with 6000 images.
> 
> Still, it's a trade-off. I wonder why isn't this disabled *unless* there are
> domain-specific overrides. Because, yes, it is simpler to get rid of the
> problem by not shipping the code or not enabling it at all, but that removes
> the feature...
> 
> For example, I don't think I've noticed the user agent overrides slowing
> down my browsing, but I have noticed, say, Google's AJAX slowing down
> things. And I tend to disable part of that AJAX by sending a different
> User-Agent to Google.
> 
> I guess someone could try to optimize it, but whether it is worth it depends
> on whether mozilla is willing to enable it again if someone does that work.

It seems bug 896114 only don't initialize UserAgentOverrides on desktop, but UserAgentOverrides source code exists in mozilla firefox source code, is there any smarter method to initialize it except reverting bug 896114
This patch fixes this bug by partially reverting changeset 140576 such that bug #896114 will only occur on systems where users enabled site-specific overrides, as is the case on Android. I tested against Firefox 31.3.0.

For some background, changeset 140576 did not remove site specific overrides from Android systems because Android tablets needed them, so instead, it included code to disable site specific overrides in the default situation where they were disabled. Consequently, the portion that removed site-specific overrides was redundant and can safely be reverted.

I noticed site specific override support had been removed when I updated from Firefox 24 to Firefox 31. Being an OSS developer who really liked that feature, I hacked it back into firefox on my system. I imagine that I am not alone in my desire for this feature to be reinstated in firefox. I also imagine that those who want it are willing to accept the performance penalty as I am.
You aren't alone. As the code is already there, it'd be good to have it running by default (at least when there are overrides...).
(In reply to Nuno Silva from comment #10)
> You aren't alone. As the code is already there, it'd be good to have it
> running by default (at least when there are overrides...).

Hope someone write an extension to init it again if the official edition doesn't plan to support it.
It *is* overkill to write an extension to enable code that is already living inside Firefox.

In my case, I actually use pentadactyl to initialize it, as it allows me to run random javascript when starting firefox.

If anything, I vote to make this a feature request. Should we reopen this bug, or file a separate bug report?
Comment on attachment 8543705 [details] [diff] [review]
firefox-31-site-specific-overrides.patch

I did not properly submit this for review last week. I am correcting that now.

https://developer.mozilla.org/en-US/docs/Introduction#Step_4_-_Get_your_code_reviewed
Attachment #8543705 - Flags: review?(dao)
Comment on attachment 8543705 [details] [diff] [review]
firefox-31-site-specific-overrides.patch

>+    if (Services.prefs.getBoolPref("general.useragent.complexOverride.moodle")) {
>+      UserAgentOverrides.addComplexOverride(function (aHttpChannel, aOriginalUA) {
>+        let cookies;
>+        try {
>+          cookies = aHttpChannel.getRequestHeader("Cookie");
>+        } catch (e) { /* no cookie sent */ }
>+        if (cookies && cookies.indexOf("MoodleSession") > -1)
>+          return aOriginalUA.replace(/Gecko\/[^ ]*/, "Gecko/20100101");
>+        return null;
>+      });
>+    }

Why are you adding this code back?

Also, I think UserAgentOverrides.jsm will still add some overhead to HTTP requests when it's initialized even if there aren't any overrides. A patch that would be accepted here should probably prevent that.
Attachment #8543705 - Flags: review?(dao) → review-
I don't think we want to generally support this feature unless we need to use it in Firefox. An add-on to restore this functionality would be quite simple to write - #fx-team on irc.mozilla.org can offer advice.
Status: RESOLVED → VERIFIED
There are clearly at least some people who are interested in having this feature in Firefox. The code, as far as I can understand, is currently in the Firefox codebase. So why not use it?
Comment 14 explains that it introduces overhead to all network requests, and having unused modules loaded also uses memory unnecessarily. We don't load code just because it's there and 1 or 2 or 1000 people might like it - we have an add-ons system for that.
(In reply to :Gavin Sharp [email: gavin@gavinsharp.com] from comment #17)

I don't really see where the big problem is. If you're worried about things like almost unnoticeable memory usage increase, is it really that problematic to disable this feature completely by default and only enable it via about:config and a restart? That way, it shouldn't be loaded at all unless it's explicitly enabled.
(In reply to Dão Gottwald [:dao] (unavailable in February) from comment #14)
> Comment on attachment 8543705 [details] [diff] [review]
> firefox-31-site-specific-overrides.patch
> 
> >+    if (Services.prefs.getBoolPref("general.useragent.complexOverride.moodle")) {
> >+      UserAgentOverrides.addComplexOverride(function (aHttpChannel, aOriginalUA) {
> >+        let cookies;
> >+        try {
> >+          cookies = aHttpChannel.getRequestHeader("Cookie");
> >+        } catch (e) { /* no cookie sent */ }
> >+        if (cookies && cookies.indexOf("MoodleSession") > -1)
> >+          return aOriginalUA.replace(/Gecko\/[^ ]*/, "Gecko/20100101");
> >+        return null;
> >+      });
> >+    }
> 
> Why are you adding this code back?
> 
> Also, I think UserAgentOverrides.jsm will still add some overhead to HTTP
> requests when it's initialized even if there aren't any overrides. A patch
> that would be accepted here should probably prevent that.

But notice how this only initializes it if that pref is enabled during startup?
Hmmmm, please don't remove this small little bit of code from FF, a lot of us use this feature, was it really hurting anything by being there?

Attached image is a shot of my about:config / general.useragent.override settings, yeah, I use this a LOT!
(In reply to jaramat from comment #18)
> (In reply to :Gavin Sharp [email: gavin@gavinsharp.com] from comment #17)
> 
> I don't really see where the big problem is. If you're worried about things
> like almost unnoticeable memory usage increase, is it really that
> problematic to disable this feature completely by default and only enable it
> via about:config and a restart? That way, it shouldn't be loaded at all
> unless it's explicitly enabled.

I totally agree! This should be implemented, this way everyone can be happy.   Yep, make it a default disabled feature and those of us who want it can enable it via about:config.    You have my vote.   Excellent post Gavin, such a simple suggestion but a great solution!
Ok, just did some testing with ff, ff beta and aurora.
Now the general.useragent.override.websitehere.com site specific option is working again.
All of my general.useragent.override custom added sites have been tested and they all work, the feature is fully operational. 
Can someone confirm if this has been put back into ff? Or is this just a temporary re-added g of the feature and I should expect it to disappear again?

I just don't want to re-add old and add new site specific user agent strings only to have the  stop working again, could someone let me know?

I thank you for your attention to this post and look forward to your reply!

Scott
(SouthOkanagan)
(In reply to Daniel from comment #22)
> Ok, just did some testing with ff, ff beta and aurora.
> Now the general.useragent.override.websitehere.com site specific option is
> working again.

would be good news, is it now supported again?
(In reply to Richard Z. from comment #23)
> (In reply to Daniel from comment #22)
> > Ok, just did some testing with ff, ff beta and aurora.
> > Now the general.useragent.override.websitehere.com site specific option is
> > working again.
> 
> would be good news, is it now supported again?

Can anyone comment on this ?

I have this one stupid website which will claim it doesn't support Linux while of course it works perfectly, and I'm not installing a Firefox extension just for that, so for me it's either overriding the user agent for this specific website or overriding it for the whole web.

The specific option doesn't seem to work despite the previous comment, therefore I am wondering if I use it incorrectly or if it's still not supported anymore ?
> 
> The specific option doesn't seem to work despite the previous comment,
> therefore I am wondering if I use it incorrectly or if it's still not
> supported anymore ?

It will work, in addition to adding the general.useragent.override.SITEHERE.COM   I.E. general.useragent.override.google.com you also need to set general.useragent.site_specific_overrides to TRUE.
Restart your browsers completely to be sure, it will work,  im using it on several sites as we speak.

Use the following useragent string for DESKTOP MODE: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:41.0) Gecko/20100101 Firefox/47.0

Daniel.
(In reply to Daniel from comment #26)
> > 
> > The specific option doesn't seem to work despite the previous comment,
> > therefore I am wondering if I use it incorrectly or if it's still not
> > supported anymore ?
> 
> It will work, in addition to adding the
> general.useragent.override.SITEHERE.COM   I.E.
> general.useragent.override.google.com you also need to set
> general.useragent.site_specific_overrides to TRUE.
> Restart your browsers completely to be sure, it will work,  im using it on
> several sites as we speak.
> 
> Use the following useragent string for DESKTOP MODE: Mozilla/5.0 (Windows NT
> 10.0; WOW64; rv:41.0) Gecko/20100101 Firefox/47.0
> 
> Daniel.

Daniel, I did it as you instructed, the site_specific_overrides was already set to TRUE by default, and I added general.useragent.override.useragentstring.com with a string containing an Edge useragent. I restarted the browser, but the website still shows the default useragent.

I don't understand the DESKTOP MODE thing, maybe that's the issue?
oxwivi, it sounds like it's done correctly, it's probably your cache, completely clear your FIREFOX cache? See if that works for ya, if not, I'll try to help further.
I took it to mean the network cache clearable at Advanced > Network in the Preferences. It was a resounding failure.

I've been trialling useragent changes in private mode, so I opened the website in normal session; same result. Similarly, I thought it was the website itself that was weird, but using another useragent checking website yielded the same results.

About the cache, I first cleaned it before quitting the browser. And then tried doing it after restarting the browser before accessing the website. Didn't work.

Maybe the packaging has got to do with it, I'm using Firefox packaged by Ubuntu.
I use it in this https://addons.mozilla.org/en-US/android/addon/corrieredeskagent/ extension and it works for me. Does it work for you? The code is on github, maybe it helps you?
Works in Firefox 57 on Windows 7, 10, Android 7.0.
You need to log in before you can comment on or make changes to this bug.