browser/components/customizableui/test/browser_972267_customizationchange_events.js

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

Ignore runtime configuration files generated during quality assurance.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 "use strict";
michael@0 6
michael@0 7 // Create a new window, then move the home button to the menu and check both windows have
michael@0 8 // customizationchange events fire on the toolbox:
michael@0 9 add_task(function() {
michael@0 10 let newWindow = yield openAndLoadWindow();
michael@0 11 let otherToolbox = newWindow.gNavToolbox;
michael@0 12
michael@0 13 let handlerCalledCount = 0;
michael@0 14 let handler = (ev) => {
michael@0 15 handlerCalledCount++;
michael@0 16 };
michael@0 17
michael@0 18 let homeButton = document.getElementById("home-button");
michael@0 19
michael@0 20 gNavToolbox.addEventListener("customizationchange", handler);
michael@0 21 otherToolbox.addEventListener("customizationchange", handler);
michael@0 22
michael@0 23 gCustomizeMode.addToPanel(homeButton);
michael@0 24
michael@0 25 is(handlerCalledCount, 2, "Should be called for both windows.");
michael@0 26
michael@0 27 // If the test is run in isolation and the panel has never been open,
michael@0 28 // the button will be in the palette. Deal with this case:
michael@0 29 if (homeButton.parentNode.id == "BrowserToolbarPalette") {
michael@0 30 yield PanelUI.ensureReady();
michael@0 31 isnot(homeButton.parentNode.id, "BrowserToolbarPalette", "Home button should now be in panel");
michael@0 32 }
michael@0 33
michael@0 34 handlerCalledCount = 0;
michael@0 35 gCustomizeMode.addToToolbar(homeButton);
michael@0 36 is(handlerCalledCount, 2, "Should be called for both windows.");
michael@0 37
michael@0 38 gNavToolbox.removeEventListener("customizationchange", handler);
michael@0 39 otherToolbox.removeEventListener("customizationchange", handler);
michael@0 40
michael@0 41 yield promiseWindowClosed(newWindow);
michael@0 42 });
michael@0 43
michael@0 44 add_task(function asyncCleanup() {
michael@0 45 yield resetCustomization();
michael@0 46 });
michael@0 47

mercurial