browser/base/content/test/general/browser_bug565667.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

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

mercurial