1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/components/customizableui/test/browser_972267_customizationchange_events.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,47 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +"use strict"; 1.9 + 1.10 +// Create a new window, then move the home button to the menu and check both windows have 1.11 +// customizationchange events fire on the toolbox: 1.12 +add_task(function() { 1.13 + let newWindow = yield openAndLoadWindow(); 1.14 + let otherToolbox = newWindow.gNavToolbox; 1.15 + 1.16 + let handlerCalledCount = 0; 1.17 + let handler = (ev) => { 1.18 + handlerCalledCount++; 1.19 + }; 1.20 + 1.21 + let homeButton = document.getElementById("home-button"); 1.22 + 1.23 + gNavToolbox.addEventListener("customizationchange", handler); 1.24 + otherToolbox.addEventListener("customizationchange", handler); 1.25 + 1.26 + gCustomizeMode.addToPanel(homeButton); 1.27 + 1.28 + is(handlerCalledCount, 2, "Should be called for both windows."); 1.29 + 1.30 + // If the test is run in isolation and the panel has never been open, 1.31 + // the button will be in the palette. Deal with this case: 1.32 + if (homeButton.parentNode.id == "BrowserToolbarPalette") { 1.33 + yield PanelUI.ensureReady(); 1.34 + isnot(homeButton.parentNode.id, "BrowserToolbarPalette", "Home button should now be in panel"); 1.35 + } 1.36 + 1.37 + handlerCalledCount = 0; 1.38 + gCustomizeMode.addToToolbar(homeButton); 1.39 + is(handlerCalledCount, 2, "Should be called for both windows."); 1.40 + 1.41 + gNavToolbox.removeEventListener("customizationchange", handler); 1.42 + otherToolbox.removeEventListener("customizationchange", handler); 1.43 + 1.44 + yield promiseWindowClosed(newWindow); 1.45 +}); 1.46 + 1.47 +add_task(function asyncCleanup() { 1.48 + yield resetCustomization(); 1.49 +}); 1.50 +