|
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/. */ |
|
4 |
|
5 const gTests = [ |
|
6 test_getTopWin, |
|
7 test_getBoolPref, |
|
8 test_openNewTabWith, |
|
9 test_openUILink |
|
10 ]; |
|
11 |
|
12 function test () { |
|
13 waitForExplicitFinish(); |
|
14 executeSoon(runNextTest); |
|
15 } |
|
16 |
|
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 } |
|
27 |
|
28 function test_getTopWin() { |
|
29 is(getTopWin(), window, "got top window"); |
|
30 runNextTest(); |
|
31 } |
|
32 |
|
33 |
|
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 } |
|
40 |
|
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 } |
|
51 |
|
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); |
|
60 |
|
61 openUILink("http://example.org/"); // defaults to "current" |
|
62 } |