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