diff options
Diffstat (limited to 'browser/base/content/test/browser_bug565667.js')
-rw-r--r-- | browser/base/content/test/browser_bug565667.js | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/browser/base/content/test/browser_bug565667.js b/browser/base/content/test/browser_bug565667.js new file mode 100644 index 000000000..6fac026c8 --- /dev/null +++ b/browser/base/content/test/browser_bug565667.js @@ -0,0 +1,59 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +let fm = Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager); + +function test() { + waitForExplicitFinish(); + // Open the javascript console. It has the mac menu overlay, so browser.js is + // loaded in it. + let consoleWin = window.open("chrome://global/content/console.xul", "_blank", + "chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar"); + testWithOpenWindow(consoleWin); +} + +function testWithOpenWindow(consoleWin) { + // Add a tab so we don't open the url into the current tab + let newTab = gBrowser.addTab("http://example.com"); + gBrowser.selectedTab = newTab; + + let numTabs = gBrowser.tabs.length; + + waitForFocus(function() { + // Sanity check + is(fm.activeWindow, consoleWin, + "the console window is focused"); + + gBrowser.tabContainer.addEventListener("TabOpen", function(aEvent) { + gBrowser.tabContainer.removeEventListener("TabOpen", arguments.callee, true); + let browser = aEvent.originalTarget.linkedBrowser; + browser.addEventListener("pageshow", function(event) { + if (event.target.location.href != "about:addons") + return; + browser.removeEventListener("pageshow", arguments.callee, true); + + is(fm.activeWindow, window, + "the browser window was focused"); + is(browser.currentURI.spec, "about:addons", + "about:addons was loaded in the window"); + is(gBrowser.tabs.length, numTabs + 1, + "a new tab was added"); + + // Cleanup. + executeSoon(function() { + consoleWin.close(); + gBrowser.removeTab(gBrowser.selectedTab); + gBrowser.removeTab(newTab); + finish(); + }); + }, true); + }, true); + + // Open the addons manager, uses switchToTabHavingURI. + consoleWin.BrowserOpenAddonsMgr(); + }, consoleWin); +} + +// Ideally we'd also check that the case for no open windows works, but we can't +// due to limitations with the testing framework. |