Bug 1438815 - The main menu stays open after the install of a sideloaded add-on. r=Gijs
authorPaolo Amadini <paolo.mozmail@amadzone.org>
Mon, 05 Mar 2018 15:33:14 +0000
changeset 461604 ea674a01296795588d20377b9e3844523ad6dcb4
parent 461603 f24d341229db8e89186ddee74f7d7ce2a280f2e4
child 461605 e7f2f3b0c920a16f2b312cf92385976d30d1e74f
push id1683
push usersfraser@mozilla.com
push dateThu, 26 Apr 2018 16:43:40 +0000
treeherdermozilla-release@5af6cb21869d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1438815
milestone60.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1438815 - The main menu stays open after the install of a sideloaded add-on. r=Gijs MozReview-Commit-ID: K1Y4JkkQ68c
browser/base/content/browser-addons.js
browser/base/content/test/webextensions/browser_extension_sideloading.js
browser/base/content/test/webextensions/browser_extension_update_background.js
--- a/browser/base/content/browser-addons.js
+++ b/browser/base/content/browser-addons.js
@@ -517,17 +517,17 @@ var gExtensionsNotifications = {
   _createAddonButton(text, icon, callback) {
     let button = document.createElement("toolbarbutton");
     button.setAttribute("label", text);
     const DEFAULT_EXTENSION_ICON =
       "chrome://mozapps/skin/extensions/extensionGeneric.svg";
     button.setAttribute("image", icon || DEFAULT_EXTENSION_ICON);
     button.className = "addon-banner-item";
 
-    button.addEventListener("click", callback);
+    button.addEventListener("command", callback);
     PanelUI.addonNotificationContainer.appendChild(button);
   },
 
   updateAlerts() {
     let sideloaded = ExtensionsUI.sideloaded;
     let updates = ExtensionsUI.updates;
 
     let container = PanelUI.addonNotificationContainer;
@@ -554,16 +554,20 @@ var gExtensionsNotifications = {
       }
       if (!appName) {
         let brandBundle = document.getElementById("bundle_brand");
         appName = brandBundle.getString("brandShortName");
       }
 
       let text = gNavigatorBundle.getFormattedString("webextPerms.sideloadMenuItem", [addon.name, appName]);
       this._createAddonButton(text, addon.iconURL, evt => {
+        // We need to hide the main menu manually because the toolbarbutton is
+        // removed immediately while processing this event, and PanelUI is
+        // unable to identify which panel should be closed automatically.
+        PanelUI.hide();
         ExtensionsUI.showSideloaded(gBrowser, addon);
       });
     }
   },
 };
 
 var LightWeightThemeWebInstaller = {
   init() {
--- a/browser/base/content/test/webextensions/browser_extension_sideloading.js
+++ b/browser/base/content/test/webextensions/browser_extension_sideloading.js
@@ -122,16 +122,19 @@ add_task(async function() {
 
   let addons = PanelUI.addonNotificationContainer;
   is(addons.children.length, 4, "Have 4 menu entries for sideloaded extensions");
 
   // Click the first sideloaded extension
   let popupPromise = promisePopupNotificationShown("addon-webext-permissions");
   addons.children[0].click();
 
+  // The click should hide the main menu. This is currently synchronous.
+  ok(PanelUI.panel.state != "open", "Main menu is closed or closing.");
+
   // When we get the permissions prompt, we should be at the extensions
   // list in about:addons
   let panel = await popupPromise;
   is(gBrowser.currentURI.spec, "about:addons", "Foreground tab is at about:addons");
 
   const VIEW = "addons://list/extension";
   // eslint-disable-next-line mozilla/no-cpows-in-tests
   let win = gBrowser.selectedBrowser.contentWindow;
--- a/browser/base/content/test/webextensions/browser_extension_update_background.js
+++ b/browser/base/content/test/webextensions/browser_extension_update_background.js
@@ -84,16 +84,19 @@ async function backgroundUpdateTest(url,
   let addons = PanelUI.addonNotificationContainer;
   is(addons.children.length, 1, "Have a menu entry for the update");
 
   // Click the menu item
   let tabPromise = BrowserTestUtils.waitForNewTab(gBrowser, "about:addons");
   let popupPromise = promisePopupNotificationShown("addon-webext-permissions");
   addons.children[0].click();
 
+  // The click should hide the main menu. This is currently synchronous.
+  ok(PanelUI.panel.state != "open", "Main menu is closed or closing.");
+
   // about:addons should load and go to the list of extensions
   let tab = await tabPromise;
   is(tab.linkedBrowser.currentURI.spec, "about:addons", "Browser is at about:addons");
 
   const VIEW = "addons://list/extension";
   await promiseViewLoaded(tab, VIEW);
   let win = tab.linkedBrowser.contentWindow;
   ok(!win.gViewController.isLoading, "about:addons view is fully loaded");