Bug 1451487 - remove nsIBlocklistService::isAddonBlocklisted as it's unused, r?Mossop draft
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Wed, 04 Apr 2018 22:01:08 +0100
changeset 777915 c39f4f8880487fd1d95ba4a590a0736e8867c34b
parent 777823 1b258f938525fda65ef80ffa0408bc665d5d8948
child 777923 f3b3525203f482c804d0472edfc9a69bd0205915
push id105329
push userbmo:gijskruitbosch+bugs@gmail.com
push dateThu, 05 Apr 2018 14:27:09 +0000
reviewersMossop
bugs1451487
milestone61.0a1
Bug 1451487 - remove nsIBlocklistService::isAddonBlocklisted as it's unused, r?Mossop MozReview-Commit-ID: Ht9DgjliSoo
browser/base/content/test/plugins/blocklist_proxy.js
toolkit/mozapps/extensions/internal/AddonTestUtils.jsm
toolkit/mozapps/extensions/nsBlocklistService.js
toolkit/mozapps/extensions/test/xpcshell/test_blocklist_osabi.js
toolkit/mozapps/extensions/test/xpcshell/test_overrideblocklist.js
xpcom/system/nsIBlocklistService.idl
--- a/browser/base/content/test/plugins/blocklist_proxy.js
+++ b/browser/base/content/test/plugins/blocklist_proxy.js
@@ -39,20 +39,16 @@ var BlocklistProxy = {
   },
 
   notify(aTimer) {
   },
 
   observe(aSubject, aTopic, aData) {
   },
 
-  isAddonBlocklisted(aAddon, aAppVersion, aToolkitVersion) {
-    return false;
-  },
-
   getAddonBlocklistState(aAddon, aAppVersion, aToolkitVersion) {
     return 0; // STATE_NOT_BLOCKED
   },
 
   getPluginBlocklistState(aPluginTag, aAppVersion, aToolkitVersion) {
     return 0; // STATE_NOT_BLOCKED
   },
 
--- a/toolkit/mozapps/extensions/internal/AddonTestUtils.jsm
+++ b/toolkit/mozapps/extensions/internal/AddonTestUtils.jsm
@@ -135,21 +135,16 @@ class MockBlocklist {
       };
     }
     return null;
   }
 
   getPluginBlocklistState(plugin, version, appVersion, toolkitVersion) {
     return Ci.nsIBlocklistService.STATE_NOT_BLOCKED;
   }
-
-  isAddonBlocklisted(addon, appVersion, toolkitVersion) {
-    return this.getAddonBlocklistState(addon, appVersion, toolkitVersion) ==
-           Ci.nsIBlocklistService.STATE_BLOCKED;
-  }
 }
 
 MockBlocklist.prototype.QueryInterface = XPCOMUtils.generateQI(["nsIBlocklistService"]);
 
 
 /**
  * Escapes any occurrences of &, ", < or > with XML entities.
  *
--- a/toolkit/mozapps/extensions/nsBlocklistService.js
+++ b/toolkit/mozapps/extensions/nsBlocklistService.js
@@ -287,22 +287,16 @@ Blocklist.prototype = {
           this._blocklistUpdated(null, null);
           break;
       }
       break;
     }
   },
 
   /* See nsIBlocklistService */
-  isAddonBlocklisted(addon, appVersion, toolkitVersion) {
-    return this.getAddonBlocklistState(addon, appVersion, toolkitVersion) ==
-                   Ci.nsIBlocklistService.STATE_BLOCKED;
-  },
-
-  /* See nsIBlocklistService */
   getAddonBlocklistState(addon, appVersion, toolkitVersion) {
     if (!this.isLoaded)
       this._loadBlocklist();
     return this._getAddonBlocklistState(addon, this._addonEntries,
                                         appVersion, toolkitVersion);
   },
 
   /**
--- a/toolkit/mozapps/extensions/test/xpcshell/test_blocklist_osabi.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_blocklist_osabi.js
@@ -281,19 +281,22 @@ add_task(async function setup() {
           `Add-on ${id} should not initially be blocked`);
   }
 });
 
 add_task(async function test_1() {
   await loadBlocklist("test_bug393285.xml");
 
   let addons = await getAddons(ADDON_IDS);
+  function isBlocklisted(addon, appVer, toolkitVer) {
+    return Services.blocklist.getAddonBlocklistState(addon, appVer, toolkitVer) != Services.blocklist.STATE_NOT_BLOCKED;
+  }
   for (let [id, options] of Object.entries(ADDONS)) {
     for (let blocklisted of options.blocklisted || []) {
-      ok(Services.blocklist.isAddonBlocklisted(addons.get(id), ...blocklisted),
+      ok(isBlocklisted(addons.get(id), ...blocklisted),
          `Add-on ${id} should be blocklisted in app/platform version ${blocklisted}`);
     }
     for (let notBlocklisted of options.notBlocklisted || []) {
-      ok(!Services.blocklist.isAddonBlocklisted(addons.get(id), ...notBlocklisted),
+      ok(!isBlocklisted(addons.get(id), ...notBlocklisted),
          `Add-on ${id} should not be blocklisted in app/platform version ${notBlocklisted}`);
     }
   }
 });
--- a/toolkit/mozapps/extensions/test/xpcshell/test_overrideblocklist.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_overrideblocklist.js
@@ -79,30 +79,33 @@ function run_test() {
       clearBlocklists();
       appBlocklist.moveTo(gAppDir, FILE_BLOCKLIST);
     });
   }
 
   run_next_test();
 }
 
-// On first run whatever is in the app dir should get copied to the profile
+function isBlocklisted(addon, appVer, toolkitVer) {
+  return Services.blocklist.getAddonBlocklistState(addon, appVer, toolkitVer) != Services.blocklist.STATE_NOT_BLOCKED;
+}
+
+// On first run whataver is in the app dir should get copied to the profile
 add_test(function test_copy() {
   clearBlocklists();
   copyToApp(OLD);
 
   incrementAppVersion();
   startupManager();
 
   reloadBlocklist();
-
-  Assert.ok(!Services.blocklist.isAddonBlocklisted(invalidAddon));
-  Assert.ok(!Services.blocklist.isAddonBlocklisted(ancientAddon));
-  Assert.ok(Services.blocklist.isAddonBlocklisted(oldAddon));
-  Assert.ok(!Services.blocklist.isAddonBlocklisted(newAddon));
+  Assert.ok(!isBlocklisted(invalidAddon));
+  Assert.ok(!isBlocklisted(ancientAddon));
+  Assert.ok(isBlocklisted(oldAddon));
+  Assert.ok(!isBlocklisted(newAddon));
 
   shutdownManager();
 
   run_next_test();
 });
 
 // An ancient blocklist should be ignored
 add_test(function test_ancient() {
@@ -110,20 +113,20 @@ add_test(function test_ancient() {
   copyToApp(ANCIENT);
   copyToProfile(OLD, OLD_TSTAMP);
 
   incrementAppVersion();
   startupManager();
 
   reloadBlocklist();
 
-  Assert.ok(!Services.blocklist.isAddonBlocklisted(invalidAddon));
-  Assert.ok(!Services.blocklist.isAddonBlocklisted(ancientAddon));
-  Assert.ok(Services.blocklist.isAddonBlocklisted(oldAddon));
-  Assert.ok(!Services.blocklist.isAddonBlocklisted(newAddon));
+  Assert.ok(!isBlocklisted(invalidAddon));
+  Assert.ok(!isBlocklisted(ancientAddon));
+  Assert.ok(isBlocklisted(oldAddon));
+  Assert.ok(!isBlocklisted(newAddon));
 
   shutdownManager();
 
   run_next_test();
 });
 
 // A new blocklist should override an old blocklist
 add_test(function test_override() {
@@ -131,20 +134,20 @@ add_test(function test_override() {
   copyToApp(NEW);
   copyToProfile(OLD, OLD_TSTAMP);
 
   incrementAppVersion();
   startupManager();
 
   reloadBlocklist();
 
-  Assert.ok(!Services.blocklist.isAddonBlocklisted(invalidAddon));
-  Assert.ok(!Services.blocklist.isAddonBlocklisted(ancientAddon));
-  Assert.ok(!Services.blocklist.isAddonBlocklisted(oldAddon));
-  Assert.ok(Services.blocklist.isAddonBlocklisted(newAddon));
+  Assert.ok(!isBlocklisted(invalidAddon));
+  Assert.ok(!isBlocklisted(ancientAddon));
+  Assert.ok(!isBlocklisted(oldAddon));
+  Assert.ok(isBlocklisted(newAddon));
 
   shutdownManager();
 
   run_next_test();
 });
 
 // An old blocklist shouldn't override a new blocklist
 add_test(function test_retain() {
@@ -152,20 +155,20 @@ add_test(function test_retain() {
   copyToApp(OLD);
   copyToProfile(NEW, NEW_TSTAMP);
 
   incrementAppVersion();
   startupManager();
 
   reloadBlocklist();
 
-  Assert.ok(!Services.blocklist.isAddonBlocklisted(invalidAddon));
-  Assert.ok(!Services.blocklist.isAddonBlocklisted(ancientAddon));
-  Assert.ok(!Services.blocklist.isAddonBlocklisted(oldAddon));
-  Assert.ok(Services.blocklist.isAddonBlocklisted(newAddon));
+  Assert.ok(!isBlocklisted(invalidAddon));
+  Assert.ok(!isBlocklisted(ancientAddon));
+  Assert.ok(!isBlocklisted(oldAddon));
+  Assert.ok(isBlocklisted(newAddon));
 
   shutdownManager();
 
   run_next_test();
 });
 
 // A missing blocklist in the profile should still load an app-shipped blocklist
 add_test(function test_missing() {
@@ -178,17 +181,17 @@ add_test(function test_missing() {
   shutdownManager();
 
   let blocklist = FileUtils.getFile(KEY_PROFILEDIR, [FILE_BLOCKLIST]);
   blocklist.remove(true);
   startupManager(false);
 
   reloadBlocklist();
 
-  Assert.ok(!Services.blocklist.isAddonBlocklisted(invalidAddon));
-  Assert.ok(!Services.blocklist.isAddonBlocklisted(ancientAddon));
-  Assert.ok(Services.blocklist.isAddonBlocklisted(oldAddon));
-  Assert.ok(!Services.blocklist.isAddonBlocklisted(newAddon));
+  Assert.ok(!isBlocklisted(invalidAddon));
+  Assert.ok(!isBlocklisted(ancientAddon));
+  Assert.ok(isBlocklisted(oldAddon));
+  Assert.ok(!isBlocklisted(newAddon));
 
   shutdownManager();
 
   run_next_test();
 });
--- a/xpcom/system/nsIBlocklistService.idl
+++ b/xpcom/system/nsIBlocklistService.idl
@@ -23,35 +23,16 @@ interface nsIBlocklistService : nsISuppo
   // update available.
   const unsigned long STATE_OUTDATED    = 3;
   // Indicates that the item is vulnerable and there is an update.
   const unsigned long STATE_VULNERABLE_UPDATE_AVAILABLE = 4;
   // Indicates that the item is vulnerable and there is no update.
   const unsigned long STATE_VULNERABLE_NO_UPDATE = 5;
 
   /**
-   * Determine if an item is blocklisted
-   * @param   addon
-   *          The addon item to be checked.
-   * @param   appVersion
-   *          The version of the application we are checking in the blocklist.
-   *          If this parameter is null, the version of the running application
-   *          is used.
-   * @param   toolkitVersion
-   *          The version of the toolkit we are checking in the blocklist.
-   *          If this parameter is null, the version of the running toolkit
-   *          is used.
-   * @returns true if the item is compatible with this version of the
-   *          application or this version of the toolkit, false, otherwise.
-   */
-  boolean isAddonBlocklisted(in jsval addon,
-                             [optional] in AString appVersion,
-                             [optional] in AString toolkitVersion);
-
-  /**
    * Determine the blocklist state of an add-on
    * @param   id
    *          The addon item to be checked.
    * @param   appVersion
    *          The version of the application we are checking in the blocklist.
    *          If this parameter is null, the version of the running application
    *          is used.
    * @param   toolkitVersion