зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1386807 - Part 1: Allow platform-specific UA overrides r=Felipe
MozReview-Commit-ID: 8OAVyZ3j9Rn --HG-- extra : rebase_source : 317c8b53d537f7953c47bde4ba21ad6043d10fd4
This commit is contained in:
Родитель
f7c175a667
Коммит
baf9d6f786
|
@ -8,6 +8,10 @@
|
|||
*
|
||||
* * `baseDomain`, required: The base domain that further checks and user
|
||||
* agents override are applied to. This does not include subdomains.
|
||||
* * `applications`: Array of applications this override is valid in.
|
||||
* Defaults to ["firefox"], can be one or more of:
|
||||
* * `firefox`: Firefox Desktop (regardless of the operating system)
|
||||
* * `fennec`: Firefox for Android
|
||||
* * `uriMatcher`: Function that gets the requested URI passed in the first
|
||||
* argument and needs to return boolean whether or not the override should
|
||||
* be applied. If not provided, the user agent override will be applied
|
||||
|
@ -18,20 +22,23 @@
|
|||
*
|
||||
* Examples:
|
||||
*
|
||||
* Gets applied for all requests to mozilla.org and subdomains:
|
||||
* Gets applied for all requests to mozilla.org and subdomains made on
|
||||
* Firefox Desktop:
|
||||
*
|
||||
* ```
|
||||
* {
|
||||
* baseDomain: "mozilla.org",
|
||||
* uriMatcher: (uri) => uri.includes("/app/"),
|
||||
* uaTransformer: (originalUA) => `Ohai Mozilla, it's me, ${originalUA}`
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* Applies to *.example.com/app/*:
|
||||
* Applies to *.example.com/app/* on Firefox for Android:
|
||||
*
|
||||
* ```
|
||||
* {
|
||||
* baseDomain: "example.com",
|
||||
* applications: ["fennec"],
|
||||
* uriMatcher: (uri) => uri.includes("/app/"),
|
||||
* uaTransformer: (originalUA) => originalUA.replace("Firefox", "Otherfox")
|
||||
* }
|
||||
|
@ -49,6 +56,7 @@ const UAOverrides = [
|
|||
*/
|
||||
{
|
||||
baseDomain: "schub.io",
|
||||
applications: ["firefox", "fennec"],
|
||||
uriMatcher: (uri) => uri.includes("webcompat-ua-dummy.schub.io"),
|
||||
uaTransformer: (originalUA) => {
|
||||
let prefix = originalUA.substr(0, originalUA.indexOf(")") + 1);
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
ChromeUtils.defineModuleGetter(this, "Services", "resource://gre/modules/Services.jsm");
|
||||
ChromeUtils.defineModuleGetter(this, "UserAgentOverrides", "resource://gre/modules/UserAgentOverrides.jsm");
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "eTLDService", "@mozilla.org/network/effective-tld-service;1", "nsIEffectiveTLDService");
|
||||
|
||||
|
@ -15,7 +16,26 @@ class UAOverrider {
|
|||
}
|
||||
|
||||
initOverrides(overrides) {
|
||||
// on xpcshell tests, there is no impleentation for nsIXULAppInfo, so this
|
||||
// might fail there. To have all of our test cases running at all times,
|
||||
// assume they are on Desktop for now.
|
||||
let currentApplication = "firefox";
|
||||
try {
|
||||
currentApplication = Services.appinfo.name.toLowerCase();
|
||||
} catch (_) {}
|
||||
|
||||
for (let override of overrides) {
|
||||
// Firefox for Desktop is the default application for all overrides.
|
||||
if (!override.applications) {
|
||||
override.applications = ["firefox"];
|
||||
}
|
||||
|
||||
// If the current application is not targeted by the override in question,
|
||||
// we can skip adding the override to our checks entirely.
|
||||
if (!override.applications.includes(currentApplication)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!this._overrides[override.baseDomain]) {
|
||||
this._overrides[override.baseDomain] = [];
|
||||
}
|
||||
|
|
|
@ -15,8 +15,7 @@
|
|||
<em:bootstrap>true</em:bootstrap>
|
||||
<em:multiprocessCompatible>true</em:multiprocessCompatible>
|
||||
|
||||
<!-- Target Application this extension can install into,
|
||||
with minimum and maximum supported versions. -->
|
||||
<!-- Firefox Desktop -->
|
||||
<em:targetApplication>
|
||||
<Description>
|
||||
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
|
||||
|
@ -25,6 +24,15 @@
|
|||
</Description>
|
||||
</em:targetApplication>
|
||||
|
||||
<!-- Firefox for Android -->
|
||||
<em:targetApplication>
|
||||
<Description>
|
||||
<em:id>{aa3c5121-dab2-40e2-81ca-7ea25febc110}</em:id>
|
||||
<em:minVersion>@MOZ_APP_VERSION@</em:minVersion>
|
||||
<em:maxVersion>@MOZ_APP_MAXVERSION@</em:maxVersion>
|
||||
</Description>
|
||||
</em:targetApplication>
|
||||
|
||||
<!-- Front End MetaData -->
|
||||
<em:name>Web Compat</em:name>
|
||||
<em:description>Urgent post-release fixes for web compatibility.</em:description>
|
||||
|
|
Загрузка…
Ссылка в новой задаче