2012-11-27 08:06:17 -08:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
const gTests = [
|
|
|
|
test_getTopWin,
|
|
|
|
test_getBoolPref,
|
|
|
|
test_openNewTabWith,
|
|
|
|
test_openUILink
|
|
|
|
];
|
|
|
|
|
|
|
|
function test () {
|
2012-11-27 09:34:42 -08:00
|
|
|
waitForExplicitFinish();
|
2012-11-27 08:06:17 -08:00
|
|
|
executeSoon(runNextTest);
|
|
|
|
}
|
|
|
|
|
|
|
|
function runNextTest() {
|
|
|
|
if (gTests.length) {
|
|
|
|
let testFun = gTests.shift();
|
|
|
|
info("Running " + testFun.name);
|
|
|
|
testFun()
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
finish();
|
|
|
|
}
|
|
|
|
}
|
2010-01-28 10:31:45 -08:00
|
|
|
|
2012-11-27 08:06:17 -08:00
|
|
|
function test_getTopWin() {
|
2010-01-28 10:31:45 -08:00
|
|
|
is(getTopWin(), window, "got top window");
|
2012-11-27 08:06:17 -08:00
|
|
|
runNextTest();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function test_getBoolPref() {
|
2010-11-16 19:38:00 -08:00
|
|
|
is(getBoolPref("browser.search.openintab", false), false, "getBoolPref");
|
2010-01-28 10:31:45 -08:00
|
|
|
is(getBoolPref("this.pref.doesnt.exist", true), true, "getBoolPref fallback");
|
|
|
|
is(getBoolPref("this.pref.doesnt.exist", false), false, "getBoolPref fallback #2");
|
2012-11-27 08:06:17 -08:00
|
|
|
runNextTest();
|
|
|
|
}
|
2010-01-28 10:31:45 -08:00
|
|
|
|
2012-11-27 08:06:17 -08:00
|
|
|
function test_openNewTabWith() {
|
|
|
|
openNewTabWith("http://example.com/");
|
|
|
|
let tab = gBrowser.selectedTab = gBrowser.tabs[1];
|
|
|
|
tab.linkedBrowser.addEventListener("load", function onLoad(event) {
|
|
|
|
tab.linkedBrowser.removeEventListener("load", onLoad, true);
|
|
|
|
is(tab.linkedBrowser.currentURI.spec, "http://example.com/", "example.com loaded");
|
|
|
|
gBrowser.removeCurrentTab();
|
|
|
|
runNextTest();
|
2010-01-28 10:31:45 -08:00
|
|
|
}, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
function test_openUILink() {
|
2012-11-27 08:06:17 -08:00
|
|
|
let tab = gBrowser.selectedTab = gBrowser.addTab("about:blank");
|
|
|
|
tab.linkedBrowser.addEventListener("load", function onLoad(event) {
|
|
|
|
tab.linkedBrowser.removeEventListener("load", onLoad, true);
|
|
|
|
is(tab.linkedBrowser.currentURI.spec, "http://example.org/", "example.org loaded");
|
|
|
|
gBrowser.removeCurrentTab();
|
|
|
|
runNextTest();
|
2010-01-28 10:31:45 -08:00
|
|
|
}, true);
|
|
|
|
|
2012-11-27 08:06:17 -08:00
|
|
|
openUILink("http://example.org/"); // defaults to "current"
|
2010-01-28 10:31:45 -08:00
|
|
|
}
|