|
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 |
|
8 add_task(function* testOneWindow() { |
|
9 let windows = []; |
|
10 for (let win of CustomizableUI.windows) |
|
11 windows.push(win); |
|
12 is(windows.length, 1, "Should have one customizable window"); |
|
13 }); |
|
14 |
|
15 |
|
16 add_task(function* testOpenCloseWindow() { |
|
17 let newWindow = null; |
|
18 let openListener = { |
|
19 onWindowOpened: function(window) { |
|
20 newWindow = window; |
|
21 } |
|
22 } |
|
23 CustomizableUI.addListener(openListener); |
|
24 let win = yield openAndLoadWindow(null, true); |
|
25 isnot(newWindow, null, "Should have gotten onWindowOpen event"); |
|
26 is(newWindow, win, "onWindowOpen event should have received expected window"); |
|
27 CustomizableUI.removeListener(openListener); |
|
28 |
|
29 let windows = []; |
|
30 for (let win of CustomizableUI.windows) |
|
31 windows.push(win); |
|
32 is(windows.length, 2, "Should have two customizable windows"); |
|
33 isnot(windows.indexOf(window), -1, "Current window should be in window collection."); |
|
34 isnot(windows.indexOf(newWindow), -1, "New window should be in window collection."); |
|
35 |
|
36 let closedWindow = null; |
|
37 let closeListener = { |
|
38 onWindowClosed: function(window) { |
|
39 closedWindow = window; |
|
40 } |
|
41 } |
|
42 CustomizableUI.addListener(closeListener); |
|
43 yield promiseWindowClosed(newWindow); |
|
44 isnot(closedWindow, null, "Should have gotten onWindowClosed event") |
|
45 is(newWindow, closedWindow, "Closed window should match previously opened window"); |
|
46 CustomizableUI.removeListener(closeListener); |
|
47 |
|
48 let windows = []; |
|
49 for (let win of CustomizableUI.windows) |
|
50 windows.push(win); |
|
51 is(windows.length, 1, "Should have one customizable window"); |
|
52 isnot(windows.indexOf(window), -1, "Current window should be in window collection."); |
|
53 is(windows.indexOf(closedWindow), -1, "Closed window should not be in window collection."); |
|
54 }); |