Bug 1260595 - Clear the lightweight themes menu in popupshowing instead of popuphidden to prevent duplicates in certain scenarios. r=jaws
authorKatie Broida <kbroida@gmail.com>
Tue, 10 May 2016 08:49:00 -0400
changeset 296874 cee62dcbbef85250c94efa7c4ac9ba7da1a76264
parent 296873 d1e1387b1d1dcb111fab021141054de12a5873d9
child 296875 ff2bd098e48956ce8e8bea4b05e408c688f1ea5e
push id19166
push userryanvm@gmail.com
push dateTue, 10 May 2016 23:20:48 +0000
treeherderfx-team@d8df7fcffeb1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws
bugs1260595
milestone49.0a1
Bug 1260595 - Clear the lightweight themes menu in popupshowing instead of popuphidden to prevent duplicates in certain scenarios. r=jaws
browser/components/customizableui/CustomizeMode.jsm
browser/components/customizableui/content/customizeMode.inc.xul
browser/components/customizableui/test/browser.ini
browser/components/customizableui/test/browser_1007336_lwthemes_in_customize_mode.js
--- a/browser/components/customizableui/CustomizeMode.jsm
+++ b/browser/components/customizableui/CustomizeMode.jsm
@@ -1338,16 +1338,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();
     }
@@ -1443,28 +1445,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.ini
+++ b/browser/components/customizableui/test/browser.ini
@@ -129,16 +129,17 @@ skip-if = os == "linux"
 [browser_989751_subviewbutton_class.js]
 [browser_992747_toggle_noncustomizable_toolbar.js]
 [browser_993322_widget_notoolbar.js]
 [browser_995164_registerArea_during_customize_mode.js]
 [browser_996364_registerArea_different_properties.js]
 [browser_996635_remove_non_widgets.js]
 [browser_1003588_no_specials_in_panel.js]
 [browser_1007336_lwthemes_in_customize_mode.js]
+skip-if = os == "linux" # crashing on Linux due to bug 1271683
 [browser_1008559_anchor_undo_restore.js]
 [browser_1042100_default_placements_update.js]
 [browser_1058573_showToolbarsDropdown.js]
 [browser_1087303_button_fullscreen.js]
 tags = fullscreen
 skip-if = os == "mac"
 [browser_1087303_button_preferences.js]
 [browser_1089591_still_customizable_after_reset.js]
--- 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;