Bug 1260595 - Clear the lightweight themes menu in popupshowing instead of popuphidden to prevent duplicates in certain scenarios. r=jaws
☠☠ backed out by 005449bf12df ☠ ☠
authorKatie Broida <kbroida@gmail.com>
Thu, 21 Apr 2016 18:59:43 -0700
changeset 332187 c7544b24989db41199a53b12982e0a696aea3e27
parent 332186 fe77c894cb9ab23dc3b232f831261be76e4d6aa9
child 332188 4fa5909cf1e73939ee823442f2c69b0a86474489
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws
bugs1260595
milestone48.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 1260595 - Clear the lightweight themes menu in popupshowing instead of popuphidden to prevent duplicates in certain scenarios. r=jaws MozReview-Commit-ID: 8wejtWMx3sd
browser/components/customizableui/CustomizeMode.jsm
browser/components/customizableui/content/customizeMode.inc.xul
browser/components/customizableui/test/browser_1007336_lwthemes_in_customize_mode.js
--- a/browser/components/customizableui/CustomizeMode.jsm
+++ b/browser/components/customizableui/CustomizeMode.jsm
@@ -1336,16 +1336,18 @@ CustomizeMode.prototype = {
     let getMoreURL = Services.urlFormatter.formatURLPref("lightweightThemes.getMoreURL");
     this.window.openUILinkIn(getMoreURL, "tab");
   },
 
   onLWThemesMenuShowing: function(aEvent) {
     const DEFAULT_THEME_ID = "{972ce4c6-7e08-4474-a285-3208198ce6fd}";
     const RECENT_LWT_COUNT = 5;
 
+    this.resetLWThemesMenu(aEvent.target);
+
     function previewTheme(aEvent) {
       LightweightThemeManager.previewTheme(aEvent.target.theme.id != DEFAULT_THEME_ID ?
                                            aEvent.target.theme : null);
     }
 
     function resetPreview() {
       LightweightThemeManager.resetPreview();
     }
@@ -1441,28 +1443,28 @@ CustomizeMode.prototype = {
           element.hidden = true;
           element = element.previousSibling;
         }
       }
       headerLabel.hidden = hideMyThemesSection;
     }.bind(this));
   },
 
-  onLWThemesMenuHidden: function(aEvent) {
-    let doc = aEvent.target.ownerDocument;
+  resetLWThemesMenu: function(target) {
+    let doc = target.ownerDocument;
     let footer = doc.getElementById("customization-lwtheme-menu-footer");
     let recommendedLabel = doc.getElementById("customization-lwtheme-menu-recommended");
     this.swatchForTheme(doc);
     for (let element of [footer, recommendedLabel]) {
       while (element.previousSibling &&
              element.previousSibling.localName == "toolbarbutton") {
         element.previousSibling.remove();
       }
     }
-    aEvent.target.removeAttribute("height");
+    target.removeAttribute("height");
   },
 
   _onUIChange: function() {
     this._changed = true;
     if (!this.resetting) {
       this._updateResetButton();
       this._updateUndoResetButton();
       this._updateEmptyPaletteNotice();
--- a/browser/components/customizableui/content/customizeMode.inc.xul
+++ b/browser/components/customizableui/content/customizeMode.inc.xul
@@ -27,17 +27,16 @@
               oncommand="gCustomizeMode.toggleTitlebar(this.hasAttribute('checked'))"/>
 #endif
       <button id="customization-toolbar-visibility-button" label="&customizeMode.toolbars;" class="customizationmode-button" type="menu">
         <menupopup id="customization-toolbar-menu" onpopupshowing="onViewToolbarsPopupShowing(event)"/>
       </button>
       <button id="customization-lwtheme-button" label="&customizeMode.lwthemes;" class="customizationmode-button" type="menu">
         <panel type="arrow" id="customization-lwtheme-menu"
                onpopupshowing="gCustomizeMode.onLWThemesMenuShowing(event);"
-               onpopuphidden="gCustomizeMode.onLWThemesMenuHidden(event);"
                position="topcenter bottomleft"
                flip="none"
                role="menu">
           <label id="customization-lwtheme-menu-header" value="&customizeMode.lwthemes.myThemes;"/>
           <label id="customization-lwtheme-menu-recommended" value="&customizeMode.lwthemes.recommended;"/>
           <hbox id="customization-lwtheme-menu-footer">
             <toolbarbutton class="customization-lwtheme-menu-footeritem"
                            label="&customizeMode.lwthemes.menuManage;"
--- a/browser/components/customizableui/test/browser_1007336_lwthemes_in_customize_mode.js
+++ b/browser/components/customizableui/test/browser_1007336_lwthemes_in_customize_mode.js
@@ -17,16 +17,26 @@ add_task(function* () {
   let themesButton = document.getElementById("customization-lwtheme-button");
   let popup = document.getElementById("customization-lwtheme-menu");
 
   let popupShownPromise = popupShown(popup);
   EventUtils.synthesizeMouseAtCenter(themesButton, {});
   info("Clicked on themes button");
   yield popupShownPromise;
 
+  // close current tab and re-open Customize menu to confirm correct number of Themes
+  yield endCustomizing();
+  info("Exited customize mode");
+  yield startCustomizing();
+  info("Started customizing a second time");
+  popupShownPromise = popupShown(popup);
+  EventUtils.synthesizeMouseAtCenter(themesButton, {});
+  info("Clicked on themes button a second time");
+  yield popupShownPromise;
+
   let header = document.getElementById("customization-lwtheme-menu-header");
   let recommendedHeader = document.getElementById("customization-lwtheme-menu-recommended");
 
   is(header.nextSibling.nextSibling, recommendedHeader,
      "There should only be one theme (default) in the 'My Themes' section by default");
   is(header.nextSibling.theme.id, DEFAULT_THEME_ID, "That theme should be the default theme");
 
   let firstLWTheme = recommendedHeader.nextSibling;