Bug 1703830 - Add ability to gate SmartBlock shims by specific platform+release branch; r=denschub,webcompat-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D111697
This commit is contained in:
Thomas Wisniewski 2021-04-12 17:38:34 +00:00
Родитель a35b4fa14b
Коммит 5cff0ed8dc
3 изменённых файлов: 28 добавлений и 18 удалений

Просмотреть файл

@ -19,6 +19,7 @@ const AVAILABLE_SHIMS = [
{
id: "MochitestShim",
platform: "all",
branch: ["all:ignoredOtherPlatform"],
name: "Test shim for Mochitests",
bug: "mochitest",
file: "mochitest-shim-1.js",
@ -99,7 +100,7 @@ const AVAILABLE_SHIMS = [
{
id: "AdSafeProtectedGoogleIMAAdapter",
platform: "all",
branches: ["nightly"],
branches: ["nightly:android"],
name: "Ad Safe Protected Google IMA Adapter",
bug: "1508639",
file: "adsafeprotected-ima.js",
@ -138,7 +139,7 @@ const AVAILABLE_SHIMS = [
{
id: "FacebookSDK",
platform: "all",
branches: ["nightly"],
branches: ["nightly:android"],
name: "Facebook SDK",
bug: "1226498",
file: "facebook-sdk.js",

Просмотреть файл

@ -62,20 +62,29 @@ class Shim {
}, pref);
this.ready = Promise.all([
browser.aboutConfigPrefs.getPref(pref).then(value => {
this._disabledPrefValue = value;
}),
platformPromise.then(platform => {
this._disabledByPlatform =
this.platform !== "all" && this.platform !== platform;
return platform;
}),
releaseBranchPromise.then(branch => {
this._disabledByReleaseBranch =
this.branches && !this.branches.includes(branch);
return branch;
}),
]).then(([_, platform, branch]) => {
browser.aboutConfigPrefs.getPref(pref),
platformPromise,
releaseBranchPromise,
]).then(([disabledPrefValue, platform, branch]) => {
this._disabledPrefValue = disabledPrefValue;
this._disabledByPlatform =
this.platform !== "all" && this.platform !== platform;
this._disabledByReleaseBranch = false;
for (const supportedBranchAndPlatform of this.branches || []) {
const [
supportedBranch,
supportedPlatform,
] = supportedBranchAndPlatform.split(":");
if (
(!supportedPlatform || supportedPlatform == platform) &&
supportedBranch != branch
) {
this._disabledByReleaseBranch = true;
}
}
this._preprocessOptions(platform, branch);
this._onEnabledStateChanged();
});
@ -424,7 +433,7 @@ class Shims {
return { cancel: true };
}
debug("allowing", url);
debug("ignoring", url);
return undefined;
}
}

Просмотреть файл

@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "Web Compatibility Interventions",
"description": "Urgent post-release fixes for web compatibility.",
"version": "21.2.0",
"version": "21.3.0",
"applications": {
"gecko": {