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/. */
5 let fm = Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager);
8 waitForExplicitFinish();
9 // Open the javascript console. It has the mac menu overlay, so browser.js is
11 let consoleWin = window.open("chrome://global/content/console.xul", "_blank",
12 "chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar");
13 testWithOpenWindow(consoleWin);
16 function testWithOpenWindow(consoleWin) {
17 // Add a tab so we don't open the url into the current tab
18 let newTab = gBrowser.addTab("http://example.com");
19 gBrowser.selectedTab = newTab;
21 let numTabs = gBrowser.tabs.length;
23 waitForFocus(function() {
25 is(fm.activeWindow, consoleWin,
26 "the console window is focused");
28 gBrowser.tabContainer.addEventListener("TabOpen", function(aEvent) {
29 gBrowser.tabContainer.removeEventListener("TabOpen", arguments.callee, true);
30 let browser = aEvent.originalTarget.linkedBrowser;
31 browser.addEventListener("pageshow", function(event) {
32 if (event.target.location.href != "about:addons")
34 browser.removeEventListener("pageshow", arguments.callee, true);
36 is(fm.activeWindow, window,
37 "the browser window was focused");
38 is(browser.currentURI.spec, "about:addons",
39 "about:addons was loaded in the window");
40 is(gBrowser.tabs.length, numTabs + 1,
41 "a new tab was added");
44 executeSoon(function() {
46 gBrowser.removeTab(gBrowser.selectedTab);
47 gBrowser.removeTab(newTab);
53 // Open the addons manager, uses switchToTabHavingURI.
54 consoleWin.BrowserOpenAddonsMgr();
58 // Ideally we'd also check that the case for no open windows works, but we can't
59 // due to limitations with the testing framework.