Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
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 }