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