michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: "use strict"; michael@0: michael@0: michael@0: add_task(function* testOneWindow() { michael@0: let windows = []; michael@0: for (let win of CustomizableUI.windows) michael@0: windows.push(win); michael@0: is(windows.length, 1, "Should have one customizable window"); michael@0: }); michael@0: michael@0: michael@0: add_task(function* testOpenCloseWindow() { michael@0: let newWindow = null; michael@0: let openListener = { michael@0: onWindowOpened: function(window) { michael@0: newWindow = window; michael@0: } michael@0: } michael@0: CustomizableUI.addListener(openListener); michael@0: let win = yield openAndLoadWindow(null, true); michael@0: isnot(newWindow, null, "Should have gotten onWindowOpen event"); michael@0: is(newWindow, win, "onWindowOpen event should have received expected window"); michael@0: CustomizableUI.removeListener(openListener); michael@0: michael@0: let windows = []; michael@0: for (let win of CustomizableUI.windows) michael@0: windows.push(win); michael@0: is(windows.length, 2, "Should have two customizable windows"); michael@0: isnot(windows.indexOf(window), -1, "Current window should be in window collection."); michael@0: isnot(windows.indexOf(newWindow), -1, "New window should be in window collection."); michael@0: michael@0: let closedWindow = null; michael@0: let closeListener = { michael@0: onWindowClosed: function(window) { michael@0: closedWindow = window; michael@0: } michael@0: } michael@0: CustomizableUI.addListener(closeListener); michael@0: yield promiseWindowClosed(newWindow); michael@0: isnot(closedWindow, null, "Should have gotten onWindowClosed event") michael@0: is(newWindow, closedWindow, "Closed window should match previously opened window"); michael@0: CustomizableUI.removeListener(closeListener); michael@0: michael@0: let windows = []; michael@0: for (let win of CustomizableUI.windows) michael@0: windows.push(win); michael@0: is(windows.length, 1, "Should have one customizable window"); michael@0: isnot(windows.indexOf(window), -1, "Current window should be in window collection."); michael@0: is(windows.indexOf(closedWindow), -1, "Closed window should not be in window collection."); michael@0: });