1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/components/customizableui/test/browser_987492_window_api.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,54 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +"use strict"; 1.9 + 1.10 + 1.11 +add_task(function* testOneWindow() { 1.12 + let windows = []; 1.13 + for (let win of CustomizableUI.windows) 1.14 + windows.push(win); 1.15 + is(windows.length, 1, "Should have one customizable window"); 1.16 +}); 1.17 + 1.18 + 1.19 +add_task(function* testOpenCloseWindow() { 1.20 + let newWindow = null; 1.21 + let openListener = { 1.22 + onWindowOpened: function(window) { 1.23 + newWindow = window; 1.24 + } 1.25 + } 1.26 + CustomizableUI.addListener(openListener); 1.27 + let win = yield openAndLoadWindow(null, true); 1.28 + isnot(newWindow, null, "Should have gotten onWindowOpen event"); 1.29 + is(newWindow, win, "onWindowOpen event should have received expected window"); 1.30 + CustomizableUI.removeListener(openListener); 1.31 + 1.32 + let windows = []; 1.33 + for (let win of CustomizableUI.windows) 1.34 + windows.push(win); 1.35 + is(windows.length, 2, "Should have two customizable windows"); 1.36 + isnot(windows.indexOf(window), -1, "Current window should be in window collection."); 1.37 + isnot(windows.indexOf(newWindow), -1, "New window should be in window collection."); 1.38 + 1.39 + let closedWindow = null; 1.40 + let closeListener = { 1.41 + onWindowClosed: function(window) { 1.42 + closedWindow = window; 1.43 + } 1.44 + } 1.45 + CustomizableUI.addListener(closeListener); 1.46 + yield promiseWindowClosed(newWindow); 1.47 + isnot(closedWindow, null, "Should have gotten onWindowClosed event") 1.48 + is(newWindow, closedWindow, "Closed window should match previously opened window"); 1.49 + CustomizableUI.removeListener(closeListener); 1.50 + 1.51 + let windows = []; 1.52 + for (let win of CustomizableUI.windows) 1.53 + windows.push(win); 1.54 + is(windows.length, 1, "Should have one customizable window"); 1.55 + isnot(windows.indexOf(window), -1, "Current window should be in window collection."); 1.56 + is(windows.indexOf(closedWindow), -1, "Closed window should not be in window collection."); 1.57 +});