summaryrefslogtreecommitdiffstats
path: root/netwerk/protocol
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2017-08-11 13:30:55 +0200
committerwolfbeast <mcwerewolf@gmail.com>2018-02-21 20:14:43 +0100
commit12640bf26e8a47293815670b03eec92a2965fcb6 (patch)
tree2a7fc2f3a60ba7bc385c808f5de352b801b879af /netwerk/protocol
parent580ebc105678c6d01cf64e7d75116d77984024a0 (diff)
downloadUXP-12640bf26e8a47293815670b03eec92a2965fcb6.tar
UXP-12640bf26e8a47293815670b03eec92a2965fcb6.tar.gz
UXP-12640bf26e8a47293815670b03eec92a2965fcb6.tar.lz
UXP-12640bf26e8a47293815670b03eec92a2965fcb6.tar.xz
UXP-12640bf26e8a47293815670b03eec92a2965fcb6.zip
Read Firefox UA compatmode from a pref instead of hard-coded.
In case of a missing pref, a hard-coded value is still used from the ctor.
Diffstat (limited to 'netwerk/protocol')
-rw-r--r--netwerk/protocol/http/nsHttpHandler.cpp30
-rw-r--r--netwerk/protocol/http/nsHttpHandler.h1
2 files changed, 24 insertions, 7 deletions
diff --git a/netwerk/protocol/http/nsHttpHandler.cpp b/netwerk/protocol/http/nsHttpHandler.cpp
index 3c46bbf80..b94728b37 100644
--- a/netwerk/protocol/http/nsHttpHandler.cpp
+++ b/netwerk/protocol/http/nsHttpHandler.cpp
@@ -103,9 +103,6 @@
#define NS_HTTP_PROTOCOL_FLAGS (URI_STD | ALLOWS_PROXY | ALLOWS_PROXY_HTTP | URI_LOADABLE_BY_ANYONE)
-// Firefox compatibility version we claim in our UA by default
-#define MOZILLA_COMPATVERSION "52.9"
-
//-----------------------------------------------------------------------------
namespace mozilla {
@@ -204,6 +201,7 @@ nsHttpHandler::nsHttpHandler()
, mLegacyAppVersion("5.0")
, mProduct("Gecko")
, mCompatFirefoxEnabled(false)
+ , mCompatFirefoxVersion("52.9")
, mUserAgentIsDirty(true)
, mPromptTempRedirect(true)
, mEnablePersistentHttpsCaching(false)
@@ -320,10 +318,12 @@ nsHttpHandler::Init()
nsHttpChannelAuthProvider::InitializePrefs();
// rv: should have the Firefox/Gecko compatversion for web compatibility
- mMisc.AssignLiteral("rv:" MOZILLA_COMPATVERSION);
+ mMisc.AssignLiteral("rv:");
+ mMisc += mCompatFirefoxVersion;
mCompatGecko.AssignLiteral("Gecko/20100101");
- mCompatFirefox.AssignLiteral("Firefox/" MOZILLA_COMPATVERSION);
+ mCompatFirefox.AssignLiteral("Firefox/");
+ mCompatFirefox += mCompatFirefoxVersion;
nsCOMPtr<nsIXULAppInfo> appInfo =
do_GetService("@mozilla.org/xre/app-info;1");
@@ -352,7 +352,7 @@ nsHttpHandler::Init()
appInfo->GetVersion(mAppVersion);
} else {
// Fall back to platform if appInfo is unavailable
- mAppVersion.Assign(MOZILLA_UAVERSION);
+ mAppVersion.AssignLiteral(MOZILLA_UAVERSION);
}
// If there's no override set, set it to the dynamic BuildID
@@ -1015,10 +1015,26 @@ nsHttpHandler::PrefsChanged(nsIPrefBranch *prefs, const char *pref)
mUserAgentIsDirty = true;
}
+ // general.useragent.compatMode.version
+ // This is the version number used in rv: for Gecko compatibility
+ // and in the Firefox/nn.nn slice when compatMode.firefox is enabled.
+ if (PREF_CHANGED(UA_PREF("compatMode.version"))) {
+ prefs->GetCharPref(UA_PREF("compatMode.version"),
+ getter_Copies(mCompatFirefoxVersion));
+
+ // rebuild mMisc and compatMode slice
+ mMisc.AssignLiteral("rv:");
+ mMisc += mCompatFirefoxVersion;
+ mCompatFirefox.AssignLiteral("Firefox/");
+ mCompatFirefox += mCompatFirefoxVersion;
+
+ mUserAgentIsDirty = true;
+ }
+
// general.useragent.override
if (PREF_CHANGED(UA_PREF("override"))) {
prefs->GetCharPref(UA_PREF("override"),
- getter_Copies(mUserAgentOverride));
+ getter_Copies(mUserAgentOverride));
mUserAgentIsDirty = true;
}
diff --git a/netwerk/protocol/http/nsHttpHandler.h b/netwerk/protocol/http/nsHttpHandler.h
index 7121d4bc2..d51662db9 100644
--- a/netwerk/protocol/http/nsHttpHandler.h
+++ b/netwerk/protocol/http/nsHttpHandler.h
@@ -489,6 +489,7 @@ private:
nsCString mCompatGecko;
bool mCompatGeckoEnabled;
nsCString mCompatFirefox;
+ nsCString mCompatFirefoxVersion;
bool mCompatFirefoxEnabled;
nsXPIDLCString mCompatDevice;
nsCString mDeviceModelId;