michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: "use strict"; michael@0: michael@0: // Create a new window, then move the home button to the menu and check both windows have michael@0: // customizationchange events fire on the toolbox: michael@0: add_task(function() { michael@0: let newWindow = yield openAndLoadWindow(); michael@0: let otherToolbox = newWindow.gNavToolbox; michael@0: michael@0: let handlerCalledCount = 0; michael@0: let handler = (ev) => { michael@0: handlerCalledCount++; michael@0: }; michael@0: michael@0: let homeButton = document.getElementById("home-button"); michael@0: michael@0: gNavToolbox.addEventListener("customizationchange", handler); michael@0: otherToolbox.addEventListener("customizationchange", handler); michael@0: michael@0: gCustomizeMode.addToPanel(homeButton); michael@0: michael@0: is(handlerCalledCount, 2, "Should be called for both windows."); michael@0: michael@0: // If the test is run in isolation and the panel has never been open, michael@0: // the button will be in the palette. Deal with this case: michael@0: if (homeButton.parentNode.id == "BrowserToolbarPalette") { michael@0: yield PanelUI.ensureReady(); michael@0: isnot(homeButton.parentNode.id, "BrowserToolbarPalette", "Home button should now be in panel"); michael@0: } michael@0: michael@0: handlerCalledCount = 0; michael@0: gCustomizeMode.addToToolbar(homeButton); michael@0: is(handlerCalledCount, 2, "Should be called for both windows."); michael@0: michael@0: gNavToolbox.removeEventListener("customizationchange", handler); michael@0: otherToolbox.removeEventListener("customizationchange", handler); michael@0: michael@0: yield promiseWindowClosed(newWindow); michael@0: }); michael@0: michael@0: add_task(function asyncCleanup() { michael@0: yield resetCustomization(); michael@0: }); michael@0: