From 5cff0ed8dc2f8d356b9c3d82d5bfe68fe710be12 Mon Sep 17 00:00:00 2001 From: Thomas Wisniewski Date: Mon, 12 Apr 2021 17:38:34 +0000 Subject: [PATCH] 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 --- browser/extensions/webcompat/data/shims.js | 5 +-- browser/extensions/webcompat/lib/shims.js | 39 +++++++++++++--------- browser/extensions/webcompat/manifest.json | 2 +- 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/browser/extensions/webcompat/data/shims.js b/browser/extensions/webcompat/data/shims.js index dd3d27d332bd..1b74d3e4b51a 100644 --- a/browser/extensions/webcompat/data/shims.js +++ b/browser/extensions/webcompat/data/shims.js @@ -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", diff --git a/browser/extensions/webcompat/lib/shims.js b/browser/extensions/webcompat/lib/shims.js index 511c36178892..8885bd180290 100644 --- a/browser/extensions/webcompat/lib/shims.js +++ b/browser/extensions/webcompat/lib/shims.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; } } diff --git a/browser/extensions/webcompat/manifest.json b/browser/extensions/webcompat/manifest.json index 9cf3f6494b70..bbeaebd15e10 100644 --- a/browser/extensions/webcompat/manifest.json +++ b/browser/extensions/webcompat/manifest.json @@ -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": {