From c505617c8d7d520045b427fa5322055b1d07faf9 Mon Sep 17 00:00:00 2001 From: Gijs Kruitbosch Date: Tue, 27 May 2014 13:43:56 +0100 Subject: [PATCH] Bug 1015494 - allow disabling panel animations during tests, r=mconley --HG-- extra : rebase_source : 3dbdf0da5fbce6e432f5a38ae700957445f4a913 --- .../customizableui/content/panelUI.js | 16 ++++++++++++++++ .../test/browser_988072_sidebar_events.js | 17 ++++++++++++++--- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/browser/components/customizableui/content/panelUI.js b/browser/components/customizableui/content/panelUI.js index c68c32e6ec9b..9097db9ba857 100644 --- a/browser/components/customizableui/content/panelUI.js +++ b/browser/components/customizableui/content/panelUI.js @@ -328,6 +328,9 @@ const PanelUI = { tempPanel.setAttribute("type", "arrow"); tempPanel.setAttribute("id", "customizationui-widget-panel"); tempPanel.setAttribute("class", "cui-widget-panel"); + if (this._disableAnimations) { + tempPanel.setAttribute("animate", "false"); + } tempPanel.setAttribute("context", ""); document.getElementById(CustomizableUI.AREA_NAVBAR).appendChild(tempPanel); // If the view has a footer, set a convenience class on the panel. @@ -363,6 +366,19 @@ const PanelUI = { } }, + /** + * NB: The enable- and disableSingleSubviewPanelAnimations methods only + * affect the hiding/showing animations of single-subview panels (tempPanel + * in the showSubView method). + */ + disableSingleSubviewPanelAnimations: function() { + this._disableAnimations = true; + }, + + enableSingleSubviewPanelAnimations: function() { + this._disableAnimations = false; + }, + onWidgetAfterDOMChange: function(aNode, aNextNode, aContainer, aWasRemoval) { if (aContainer != this.contents) { return; diff --git a/browser/components/customizableui/test/browser_988072_sidebar_events.js b/browser/components/customizableui/test/browser_988072_sidebar_events.js index e4fe5510e848..a893bb53b8cb 100644 --- a/browser/components/customizableui/test/browser_988072_sidebar_events.js +++ b/browser/components/customizableui/test/browser_988072_sidebar_events.js @@ -41,6 +41,16 @@ function createSidebarItem() { gSidebarMenu.insertBefore(gTestSidebarItem, gSidebarMenu.firstChild); } +function addWidget() { + CustomizableUI.addWidgetToArea("sidebar-button", "nav-bar"); + PanelUI.disableSingleSubviewPanelAnimations(); +} + +function removeWidget() { + CustomizableUI.removeWidgetFromArea("sidebar-button"); + PanelUI.enableSingleSubviewPanelAnimations(); +} + // Filters out the trailing menuseparators from the sidebar list function getSidebarList() { let sidebars = [...gSidebarMenu.children]; @@ -76,7 +86,7 @@ let showSidebarPopup = Task.async(function*() { // Check the sidebar widget shows the default items add_task(function*() { - CustomizableUI.addWidgetToArea("sidebar-button", "nav-bar"); + addWidget(); yield showSidebarPopup(); @@ -89,13 +99,14 @@ add_task(function*() { document.getElementById("customizationui-widget-panel").hidePopup(); yield subviewHiddenPromise; - return resetCustomization(); + removeWidget(); }); function add_sidebar_task(description, setup, teardown) { add_task(function*() { info(description); createSidebarItem(); + addWidget(); yield setup(); CustomizableUI.addWidgetToArea("sidebar-button", "nav-bar"); @@ -114,7 +125,7 @@ function add_sidebar_task(description, setup, teardown) { yield teardown(); gTestSidebarItem.remove(); - return resetCustomization(); + removeWidget(); }); }