Bug 1451743 - remove getAddonBlocklistURL from nsIBlocklistService, r?florian draft
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Thu, 05 Apr 2018 15:05:28 +0100
changeset 777923 f3b3525203f482c804d0472edfc9a69bd0205915
parent 777915 c39f4f8880487fd1d95ba4a590a0736e8867c34b
push id105335
push userbmo:gijskruitbosch+bugs@gmail.com
push dateThu, 05 Apr 2018 14:53:15 +0000
reviewersflorian
bugs1451743
milestone61.0a1
Bug 1451743 - remove getAddonBlocklistURL from nsIBlocklistService, r?florian MozReview-Commit-ID: HSrOHIZ1MA
browser/base/content/test/plugins/blocklist_proxy.js
toolkit/mozapps/extensions/nsBlocklistService.js
toolkit/mozapps/extensions/test/xpcshell/test_blocklist_severities.js
xpcom/system/nsIBlocklistService.idl
--- a/browser/base/content/test/plugins/blocklist_proxy.js
+++ b/browser/base/content/test/plugins/blocklist_proxy.js
@@ -47,20 +47,16 @@ var BlocklistProxy = {
   getAddonBlocklistState(aAddon, aAppVersion, aToolkitVersion) {
     return 0; // STATE_NOT_BLOCKED
   },
 
   getPluginBlocklistState(aPluginTag, aAppVersion, aToolkitVersion) {
     return 0; // STATE_NOT_BLOCKED
   },
 
-  getAddonBlocklistURL(aAddon, aAppVersion, aToolkitVersion) {
-    return "";
-  },
-
   getPluginBlocklistURL(aPluginTag) {
     return "";
   },
 
   getPluginInfoURL(aPluginTag) {
     return "";
   },
 };
--- a/toolkit/mozapps/extensions/nsBlocklistService.js
+++ b/toolkit/mozapps/extensions/nsBlocklistService.js
@@ -426,25 +426,16 @@ Blocklist.prototype = {
     for (let entry of aAddonEntries) {
       if (checkEntry(entry.attributes, params)) {
          return entry;
        }
      }
      return null;
   },
 
-  /* See nsIBlocklistService */
-  getAddonBlocklistURL(addon, appVersion, toolkitVersion) {
-    if (!this.isLoaded)
-      this._loadBlocklist();
-
-    let entry = this._getAddonBlocklistEntry(addon, this._addonEntries);
-    return entry && entry.url;
-  },
-
   _createBlocklistURL(id) {
     let url = Services.urlFormatter.formatURLPref(PREF_BLOCKLIST_ITEM_URL);
     url = url.replace(/%blockID%/g, id);
 
     return url;
   },
 
   notify(aTimer) {
@@ -1287,24 +1278,25 @@ Blocklist.prototype = {
           // softDisabled at the same time as userDisabled to make it clear
           // which was the original cause of the add-on becoming disabled in a
           // way that the user can change.
           if (state == Ci.nsIBlocklistService.STATE_SOFTBLOCKED && !addon.userDisabled)
             addon.softDisabled = true;
           continue;
         }
 
+        let entry = this._getAddonBlocklistEntry(addon, this._addonEntries);
         addonList.push({
           name: addon.name,
           version: addon.version,
           icon: addon.iconURL,
           disable: false,
           blocked: state == Ci.nsIBlocklistService.STATE_BLOCKED,
           item: addon,
-          url: this.getAddonBlocklistURL(addon),
+          url: entry && entry.url,
         });
       }
 
       AddonManagerPrivate.updateAddonAppDisabledStates();
 
       var phs = Cc["@mozilla.org/plugin/host;1"].
                 getService(Ci.nsIPluginHost);
       var plugins = phs.getPluginTags();
--- a/toolkit/mozapps/extensions/test/xpcshell/test_blocklist_severities.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_blocklist_severities.js
@@ -9,16 +9,21 @@ ChromeUtils.import("resource://testing-c
 
 var gTestserver = AddonTestUtils.createHttpServer({hosts: ["example.com"]});
 gTestserver.registerDirectory("/data/", do_get_file("data"));
 
 // Workaround for Bug 658720 - URL formatter can leak during xpcshell tests
 const PREF_BLOCKLIST_ITEM_URL = "extensions.blocklist.itemURL";
 Services.prefs.setCharPref(PREF_BLOCKLIST_ITEM_URL, "http://example.com/blocklist/%blockID%");
 
+function getAddonBlocklistURL(addon) {
+  let entry = Services.blocklist.getAddonBlocklistEntry(addon);
+  return entry && entry.url;
+}
+
 var ADDONS = [{
   // Tests how the blocklist affects a disabled add-on
   id: "test_bug455906_1@tests.mozilla.org",
   name: "Bug 455906 Addon Test 1",
   version: "5",
   appVersion: "3"
 }, {
   // Tests how the blocklist affects an enabled add-on
@@ -356,21 +361,21 @@ add_task(async function test_pt3() {
   equal(check_plugin_state(PLUGINS[2]), "false,true");
   equal(check_plugin_state(PLUGINS[3]), "true,true");
   equal(check_plugin_state(PLUGINS[4]), "false,true");
 
   // Should have gained the blocklist state but no longer be soft disabled
   checkAddonState(addons[3], {userDisabled: false, softDisabled: false, appDisabled: true});
 
   // Check blockIDs are correct
-  equal(Services.blocklist.getAddonBlocklistURL(addons[0]), create_blocklistURL(addons[0].id));
-  equal(Services.blocklist.getAddonBlocklistURL(addons[1]), create_blocklistURL(addons[1].id));
-  equal(Services.blocklist.getAddonBlocklistURL(addons[2]), create_blocklistURL(addons[2].id));
-  equal(Services.blocklist.getAddonBlocklistURL(addons[3]), create_blocklistURL(addons[3].id));
-  equal(Services.blocklist.getAddonBlocklistURL(addons[4]), create_blocklistURL(addons[4].id));
+  equal(getAddonBlocklistURL(addons[0]), create_blocklistURL(addons[0].id));
+  equal(getAddonBlocklistURL(addons[1]), create_blocklistURL(addons[1].id));
+  equal(getAddonBlocklistURL(addons[2]), create_blocklistURL(addons[2].id));
+  equal(getAddonBlocklistURL(addons[3]), create_blocklistURL(addons[3].id));
+  equal(getAddonBlocklistURL(addons[4]), create_blocklistURL(addons[4].id));
 
   // All plugins have the same blockID on the test
   equal(Services.blocklist.getPluginBlocklistURL(PLUGINS[0]), create_blocklistURL("test_bug455906_plugin"));
   equal(Services.blocklist.getPluginBlocklistURL(PLUGINS[1]), create_blocklistURL("test_bug455906_plugin"));
   equal(Services.blocklist.getPluginBlocklistURL(PLUGINS[2]), create_blocklistURL("test_bug455906_plugin"));
   equal(Services.blocklist.getPluginBlocklistURL(PLUGINS[3]), create_blocklistURL("test_bug455906_plugin"));
   equal(Services.blocklist.getPluginBlocklistURL(PLUGINS[4]), create_blocklistURL("test_bug455906_plugin"));
 
--- a/xpcom/system/nsIBlocklistService.idl
+++ b/xpcom/system/nsIBlocklistService.idl
@@ -59,26 +59,16 @@ interface nsIBlocklistService : nsISuppo
    *          is used.
    * @returns The STATE constant.
    */
   unsigned long getPluginBlocklistState(in nsIPluginTag plugin,
                                         [optional] in AString appVersion,
                                         [optional] in AString toolkitVersion);
 
   /**
-   * Determine the blocklist web page of an add-on.
-   * @param   addon
-   *          The addon item whose url is required.
-   * @returns The URL of the description page.
-   */
-  AString getAddonBlocklistURL(in jsval addon,
-                              [optional] in AString appVersion,
-                              [optional] in AString toolkitVersion);
-
-  /**
    * Returns the blocklist entry, as an object with `state` and `url`
    * properties, if a blocklist entry for the add-on exists, or null
    * othereise.
 
    * @param   addon
    *          The addon object to match.
    * @param   appVersion
    *          The version of the application we are checking in the blocklist.