1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/base/content/test/general/browser_utilityOverlay.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,62 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +const gTests = [ 1.9 + test_getTopWin, 1.10 + test_getBoolPref, 1.11 + test_openNewTabWith, 1.12 + test_openUILink 1.13 +]; 1.14 + 1.15 +function test () { 1.16 + waitForExplicitFinish(); 1.17 + executeSoon(runNextTest); 1.18 +} 1.19 + 1.20 +function runNextTest() { 1.21 + if (gTests.length) { 1.22 + let testFun = gTests.shift(); 1.23 + info("Running " + testFun.name); 1.24 + testFun() 1.25 + } 1.26 + else { 1.27 + finish(); 1.28 + } 1.29 +} 1.30 + 1.31 +function test_getTopWin() { 1.32 + is(getTopWin(), window, "got top window"); 1.33 + runNextTest(); 1.34 +} 1.35 + 1.36 + 1.37 +function test_getBoolPref() { 1.38 + is(getBoolPref("browser.search.openintab", false), false, "getBoolPref"); 1.39 + is(getBoolPref("this.pref.doesnt.exist", true), true, "getBoolPref fallback"); 1.40 + is(getBoolPref("this.pref.doesnt.exist", false), false, "getBoolPref fallback #2"); 1.41 + runNextTest(); 1.42 +} 1.43 + 1.44 +function test_openNewTabWith() { 1.45 + openNewTabWith("http://example.com/"); 1.46 + let tab = gBrowser.selectedTab = gBrowser.tabs[1]; 1.47 + tab.linkedBrowser.addEventListener("load", function onLoad(event) { 1.48 + tab.linkedBrowser.removeEventListener("load", onLoad, true); 1.49 + is(tab.linkedBrowser.currentURI.spec, "http://example.com/", "example.com loaded"); 1.50 + gBrowser.removeCurrentTab(); 1.51 + runNextTest(); 1.52 + }, true); 1.53 +} 1.54 + 1.55 +function test_openUILink() { 1.56 + let tab = gBrowser.selectedTab = gBrowser.addTab("about:blank"); 1.57 + tab.linkedBrowser.addEventListener("load", function onLoad(event) { 1.58 + tab.linkedBrowser.removeEventListener("load", onLoad, true); 1.59 + is(tab.linkedBrowser.currentURI.spec, "http://example.org/", "example.org loaded"); 1.60 + gBrowser.removeCurrentTab(); 1.61 + runNextTest(); 1.62 + }, true); 1.63 + 1.64 + openUILink("http://example.org/"); // defaults to "current" 1.65 +}