browser/base/content/test/general/browser_utilityOverlay.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 const gTests = [
     6   test_getTopWin,
     7   test_getBoolPref,
     8   test_openNewTabWith,
     9   test_openUILink
    10 ];
    12 function test () {
    13   waitForExplicitFinish();
    14   executeSoon(runNextTest);
    15 }
    17 function runNextTest() {
    18   if (gTests.length) {
    19     let testFun = gTests.shift();
    20     info("Running " + testFun.name);
    21     testFun()
    22   }
    23   else {
    24     finish();
    25   }
    26 }
    28 function test_getTopWin() {
    29   is(getTopWin(), window, "got top window");
    30   runNextTest();
    31 }
    34 function test_getBoolPref() {
    35   is(getBoolPref("browser.search.openintab", false), false, "getBoolPref");
    36   is(getBoolPref("this.pref.doesnt.exist", true), true, "getBoolPref fallback");
    37   is(getBoolPref("this.pref.doesnt.exist", false), false, "getBoolPref fallback #2");
    38   runNextTest();
    39 }
    41 function test_openNewTabWith() {
    42   openNewTabWith("http://example.com/");
    43   let tab = gBrowser.selectedTab = gBrowser.tabs[1];
    44   tab.linkedBrowser.addEventListener("load", function onLoad(event) {
    45     tab.linkedBrowser.removeEventListener("load", onLoad, true);
    46     is(tab.linkedBrowser.currentURI.spec, "http://example.com/", "example.com loaded");
    47     gBrowser.removeCurrentTab();
    48     runNextTest();
    49   }, true);
    50 }
    52 function test_openUILink() {
    53   let tab = gBrowser.selectedTab = gBrowser.addTab("about:blank");
    54   tab.linkedBrowser.addEventListener("load", function onLoad(event) {
    55     tab.linkedBrowser.removeEventListener("load", onLoad, true);
    56     is(tab.linkedBrowser.currentURI.spec, "http://example.org/", "example.org loaded");
    57     gBrowser.removeCurrentTab();
    58     runNextTest();
    59   }, true);
    61   openUILink("http://example.org/"); // defaults to "current"
    62 }

mercurial