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.

     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);
     7 function test() {
     8   waitForExplicitFinish();
     9   // Open the javascript console. It has the mac menu overlay, so browser.js is
    10   // loaded in it.
    11   let consoleWin = window.open("chrome://global/content/console.xul", "_blank",
    12                                "chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar");
    13   testWithOpenWindow(consoleWin);
    14 }
    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() {
    24     // Sanity check
    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")
    33           return;
    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");
    43         // Cleanup.
    44         executeSoon(function() {
    45           consoleWin.close();
    46           gBrowser.removeTab(gBrowser.selectedTab);
    47           gBrowser.removeTab(newTab);
    48           finish();
    49         });
    50       }, true);
    51     }, true);
    53     // Open the addons manager, uses switchToTabHavingURI.
    54     consoleWin.BrowserOpenAddonsMgr();
    55   }, consoleWin);
    56 }
    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.

mercurial