Evangelism/UA Override List Policy: Difference between revisions

→‎UA Override Capabilities: Update override docs
(→‎UA Override Capabilities: Update override docs)
 
Line 20: Line 20:
==UA Override Capabilities==
==UA Override Capabilities==


UA overrides was previously in a preference file. The list of UA overrides is now updated and stored in a [https://hg.mozilla.org/mozilla-central/file/tip/b2g/app/ua-update.json.in server side file]. It creates more flexibility for managing the list. The code which parses and constructs them is in [http://mxr.mozilla.org/mozilla-central/source/netwerk/protocol/http/UserAgentOverrides.jsm UserAgentOverrides.jsm], and the code which apples them is in [http://mxr.mozilla.org/mozilla-central/source/netwerk/protocol/http/nsHttpHandler.cpp#553 nsHTTPHandler.cpp].
UA overrides are maintained in a [https://hg.mozilla.org/mozilla-central/file/tip/mobile/android/app/ua-update.json.in json file] that lives in mozilla-central, but are served from a CDN. This allows us to push updates to users independent of release dates.
 
'''Note:''' [https://hg.mozilla.org/mozilla-central/file/tip/b2g/app/ua-update.json.in a similar file for B2G] exists, but is basically unmaintained.
 
The code which parses and constructs them is in [http://mxr.mozilla.org/mozilla-central/source/netwerk/protocol/http/UserAgentOverrides.jsm UserAgentOverrides.jsm], and the code which apples them is in [http://mxr.mozilla.org/mozilla-central/source/netwerk/protocol/http/nsHttpHandler.cpp#553 nsHTTPHandler.cpp]. The code for fetching updates lives in [https://dxr.mozilla.org/mozilla-central/source/netwerk/protocol/http/UserAgentUpdates.jsm UserAgentUpdates.jsm]
 
To verify if an override was successfully synced to the CDN, visit:
 
https://dynamicua.cdn.mozilla.net/0/%7Baa3c5121-dab2-40e2-81ca-7ea25febc110%7D
 
It should be there within 24 hours of landing on mozilla-central.


An override applies to the domain given and all subdomains (unless a subdomain has a more specific rule).
An override applies to the domain given and all subdomains (unless a subdomain has a more specific rule).
Line 30: Line 40:
   "globo.com": "\\(Mobile#(Android; Mobile",
   "globo.com": "\\(Mobile#(Android; Mobile",


replaces "(Mobile" with "(Android; Mobile" - i.e. turning the B2G UA into the Firefox for Android UA. The # separates the search part and the replace part, and on the left hand side regexp-special characters - e.g. ( - which you want matched as literals need double-backslash-escaping (the first escapes the backslash for JS, and the second escapes the char in the regexp to make it a literal).
replaces "(Mobile" with "(Android; Mobile" - i.e. turning the B2G UA into the Firefox for Android UA. The # separates the search part and the replace part, and on the left hand side regexp-special characters - e.g. ( - which you want matched as literals need double-backslash-escaping (the first escapes the backslash for JS, and the second escapes the char in the regexp to make it a literal).  
 
Effectively, the following string operation occurs:
 
  "Mozilla/5.0 (Mobile; rv:38.0) Gecko/38.0 Firefox/38.0".replace(new RegExp("\\Mobile", "g"), "(Android; Mobile")


The system also has the ability to entirely replace the UA with another string. So:
The system also has the ability to entirely replace the UA with another string. So:
Line 40: Line 54:


=== Complex UA override ===
=== Complex UA override ===
Lastly, there is also a system for more complex, conditional overrides, but these have to be hard-coded. At time of writing, there is [http://mxr.mozilla.org/mozilla-central/search?string=addComplexOverride only one of these], used to request desktop sites in Firefox for Android.


Lastly, there is also a system for more complex, conditional overrides, but these have to be hard-coded. At time of writing, there are [http://mxr.mozilla.org/mozilla-central/search?string=addComplexOverride only two of these]:
[[Compatibility/Go_Faster_Addon|WebCompat Go Faster]] is being developed to replace any need to hard-code conditional overrides.
 
* The [http://mxr.mozilla.org/mozilla-central/source/browser/components/nsBrowserGlue.js#471 one which fixes the rich text editor in old versions of Moodle in all Firefoxes]. This is done by detecting the Moodle cookie. Old Moodle requires the Gecko date to still be 20100101.
* The [http://mxr.mozilla.org/mozilla-central/source/mobile/android/chrome/content/browser.js#2257 one which requests the mobile version of YouTube in Firefox for Android on tablets] by adding the string "Mobile" before the tablet identifier. (This one could actually be replaced with a non-complex override.)
 


[[Category:Mobile]]
[[Category:Mobile]]
[[Category:Web Compatibility|UA Override]]
[[Category:Web Compatibility|UA Override]]
Confirmed users
796

edits