Bug 1338827 - Only show reload button for temporary add-ons in about:debugging r?jdescottes draft
authorMark Striemer <mstriemer@mozilla.com>
Thu, 18 May 2017 09:30:48 -0500
changeset 581384 2e1cb0db1c06fecfde8ee08c8b76397866ae619f
parent 580499 e5c3fd46d7718b5de5c37b8855e1242a188186db
child 629567 0077f1a679e9ac8b10beac1d37e4d53a9098aa9c
push id59858
push userbmo:mstriemer@mozilla.com
push dateFri, 19 May 2017 20:00:35 +0000
reviewersjdescottes
bugs1338827
milestone55.0a1
Bug 1338827 - Only show reload button for temporary add-ons in about:debugging r?jdescottes MozReview-Commit-ID: m8Le3N4xyg
devtools/client/aboutdebugging/components/addons/target.js
devtools/client/aboutdebugging/test/browser_addons_reload.js
devtools/client/aboutdebugging/test/browser_addons_remove.js
devtools/client/locales/en-US/aboutdebugging.properties
--- a/devtools/client/aboutdebugging/components/addons/target.js
+++ b/devtools/client/aboutdebugging/components/addons/target.js
@@ -75,18 +75,16 @@ module.exports = createClass({
     }).then(() => {}, error => {
       throw new Error(
         "Error reloading addon " + target.addonID + ": " + error);
     });
   },
 
   render() {
     let { target, debugDisabled } = this.props;
-    // Only temporarily installed add-ons can be reloaded.
-    const canBeReloaded = target.temporarilyInstalled;
 
     return dom.li(
       { className: "addon-target-container", "data-addon-id": target.addonID },
       dom.div({ className: "target" },
         dom.img({
           className: "target-icon",
           role: "presentation",
           src: target.icon
@@ -98,23 +96,22 @@ module.exports = createClass({
         ...filePathForTarget(target),
       ),
       dom.div({className: "addon-target-actions"},
         dom.button({
           className: "debug-button addon-target-button",
           onClick: this.debug,
           disabled: debugDisabled,
         }, Strings.GetStringFromName("debug")),
-        dom.button({
-          className: "reload-button addon-target-button",
-          onClick: this.reload,
-          disabled: !canBeReloaded,
-          title: !canBeReloaded ?
-            Strings.GetStringFromName("reloadDisabledTooltip") : ""
-        }, Strings.GetStringFromName("reload")),
+        target.temporarilyInstalled
+          ? dom.button({
+            className: "reload-button addon-target-button",
+            onClick: this.reload,
+          }, Strings.GetStringFromName("reload"))
+          : null,
         target.temporarilyInstalled
           ? dom.button({
             className: "uninstall-button addon-target-button",
             onClick: this.uninstall,
           }, Strings.GetStringFromName("remove"))
           : null,
       ),
     );
--- a/devtools/client/aboutdebugging/test/browser_addons_reload.js
+++ b/devtools/client/aboutdebugging/test/browser_addons_reload.js
@@ -62,17 +62,16 @@ add_task(function* reloadButtonReloadsAd
   yield waitForInitialAddonList(document);
   yield installAddon({
     document,
     path: "addons/unpacked/install.rdf",
     name: ADDON_NAME,
   });
 
   const reloadButton = getReloadButton(document, ADDON_NAME);
-  is(reloadButton.disabled, false, "Reload button should not be disabled");
   is(reloadButton.title, "", "Reload button should not have a tooltip");
   const onInstalled = promiseAddonEvent("onInstalled");
 
   const onBootstrapInstallCalled = new Promise(done => {
     Services.obs.addObserver(function listener() {
       Services.obs.removeObserver(listener, ADDON_NAME);
       info("Add-on was re-installed: " + ADDON_NAME);
       done();
@@ -144,15 +143,13 @@ add_task(function* onlyTempInstalledAddo
   yield waitForInitialAddonList(document);
   const onAddonListUpdated = waitForMutation(getAddonList(document),
                                              { childList: true });
   yield installAddonWithManager(getSupportsFile("addons/bug1273184.xpi").file);
   yield onAddonListUpdated;
   const addon = yield getAddonByID("bug1273184@tests");
 
   const reloadButton = getReloadButton(document, addon.name);
-  ok(reloadButton, "Reload button exists");
-  is(reloadButton.disabled, true, "Reload button should be disabled");
-  ok(reloadButton.title, "Disabled reload button should have a tooltip");
+  ok(!reloadButton, "There should not be a reload button");
 
   yield tearDownAddon(addon);
   yield closeAboutDebugging(tab);
 });
--- a/devtools/client/aboutdebugging/test/browser_addons_remove.js
+++ b/devtools/client/aboutdebugging/test/browser_addons_remove.js
@@ -5,17 +5,17 @@
 function getTargetEl(document, id) {
   return document.querySelector(`[data-addon-id="${id}"]`);
 }
 
 function getRemoveButton(document, id) {
   return document.querySelector(`[data-addon-id="${id}"] .uninstall-button`);
 }
 
-add_task(function* () {
+add_task(function* removeLegacyExtension() {
   const addonID = "test-devtools@mozilla.org";
   const addonName = "test-devtools";
 
   const { tab, document } = yield openAboutDebugging("addons");
   yield waitForInitialAddonList(document);
 
   // Install this add-on, and verify that it appears in the about:debugging UI
   yield installAddon({
@@ -33,16 +33,45 @@ add_task(function* () {
   getRemoveButton(document, addonID).click();
   yield addonListMutation;
 
   ok(!getTargetEl(document, addonID), "add-on is not shown");
 
   yield closeAboutDebugging(tab);
 });
 
+add_task(function* removeWebextension() {
+  const addonID = "test-devtools-webextension@mozilla.org";
+  const addonName = "test-devtools-webextension";
+
+  const { tab, document } = yield openAboutDebugging("addons");
+  yield waitForInitialAddonList(document);
+
+  // Install this add-on, and verify that it appears in the about:debugging UI
+  yield installAddon({
+    document,
+    path: "addons/test-devtools-webextension/manifest.json",
+    name: addonName,
+    isWebExtension: true,
+  });
+
+  ok(getTargetEl(document, addonID), "add-on is shown");
+
+  // Click the remove button and wait for the DOM to change.
+  const addonListMutation = waitForMutation(
+    getTemporaryAddonList(document),
+    { childList: true });
+  getRemoveButton(document, addonID).click();
+  yield addonListMutation;
+
+  ok(!getTargetEl(document, addonID), "add-on is not shown");
+
+  yield closeAboutDebugging(tab);
+});
+
 add_task(function* onlyTempInstalledAddonsCanBeRemoved() {
   const { tab, document } = yield openAboutDebugging("addons");
   yield waitForInitialAddonList(document);
   const onAddonListUpdated = waitForMutation(getAddonList(document),
                                              { childList: true });
   yield installAddonWithManager(getSupportsFile("addons/bug1273184.xpi").file);
   yield onAddonListUpdated;
   const addon = yield getAddonByID("bug1273184@tests");
--- a/devtools/client/locales/en-US/aboutdebugging.properties
+++ b/devtools/client/locales/en-US/aboutdebugging.properties
@@ -82,21 +82,16 @@ webExtTip.learnMore = Learn more
 # This string is displayed as the title of the file picker that appears when
 # the user clicks the 'Load Temporary Add-on' button
 selectAddonFromFile2 = Select Manifest File or Package (.xpi)
 
 # LOCALIZATION NOTE (reload):
 # This string is displayed as a label of the button that reloads a given addon.
 reload = Reload
 
-# LOCALIZATION NOTE (reloadDisabledTooltip):
-# This string is displayed in a tooltip that appears when hovering over a
-# disabled 'reload' button.
-reloadDisabledTooltip = Only temporarily installed add-ons can be reloaded
-
 # LOCALIZATION NOTE (remove):
 # This string is displayed as a label of the button that will remove a given addon.
 remove = Remove
 
 # LOCALIZATION NOTE (location):
 # This string is displayed as a label for the filesystem location of an extension.
 location = Location