2011-05-12 10:52:25 -07:00
|
|
|
/* Any copyright is dedicated to the Public Domain.
|
|
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
|
|
|
|
function test() {
|
|
|
|
waitForExplicitFinish();
|
|
|
|
|
|
|
|
nextTest();
|
|
|
|
}
|
|
|
|
|
2011-05-13 10:40:22 -07:00
|
|
|
let urls = [
|
|
|
|
"javascript:'foopy';",
|
2011-05-19 16:44:01 -07:00
|
|
|
"data:text/html,<body>hi"
|
2011-05-12 10:52:25 -07:00
|
|
|
];
|
|
|
|
|
2011-05-19 16:44:01 -07:00
|
|
|
function urlEnter(url) {
|
|
|
|
gURLBar.value = url;
|
|
|
|
gURLBar.focus();
|
|
|
|
EventUtils.synthesizeKey("VK_RETURN", {});
|
|
|
|
}
|
|
|
|
|
|
|
|
function urlClick(url) {
|
|
|
|
gURLBar.value = url;
|
|
|
|
gURLBar.focus();
|
|
|
|
let goButton = document.getElementById("urlbar-go-button");
|
|
|
|
EventUtils.synthesizeMouseAtCenter(goButton, {});
|
|
|
|
}
|
|
|
|
|
2011-05-12 10:52:25 -07:00
|
|
|
function nextTest() {
|
2011-05-13 10:40:22 -07:00
|
|
|
let url = urls.shift();
|
2011-05-19 16:44:01 -07:00
|
|
|
if (url) {
|
|
|
|
testURL(url, urlEnter, function () {
|
|
|
|
testURL(url, urlClick, nextTest);
|
|
|
|
});
|
|
|
|
}
|
2011-05-12 10:52:25 -07:00
|
|
|
else
|
|
|
|
finish();
|
|
|
|
}
|
|
|
|
|
2011-05-19 16:44:01 -07:00
|
|
|
function testURL(url, loadFunc, endFunc) {
|
2011-05-12 10:52:25 -07:00
|
|
|
let tab = gBrowser.selectedTab = gBrowser.addTab();
|
|
|
|
registerCleanupFunction(function () {
|
|
|
|
gBrowser.removeTab(tab);
|
|
|
|
});
|
|
|
|
addPageShowListener(function () {
|
|
|
|
let pagePrincipal = gBrowser.contentPrincipal;
|
2011-05-19 16:44:01 -07:00
|
|
|
loadFunc(url);
|
2011-05-12 10:52:25 -07:00
|
|
|
|
|
|
|
addPageShowListener(function () {
|
2011-07-20 13:21:55 -07:00
|
|
|
let fm = Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager);
|
|
|
|
is(fm.focusedElement, null, "should be no focused element");
|
|
|
|
is(fm.focusedWindow, gBrowser.contentWindow, "content window should be focused");
|
|
|
|
|
2011-05-19 16:44:01 -07:00
|
|
|
ok(!gBrowser.contentPrincipal.equals(pagePrincipal),
|
|
|
|
"load of " + url + " by " + loadFunc.name + " should produce a page with a different principal");
|
|
|
|
endFunc();
|
2011-05-12 10:52:25 -07:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function addPageShowListener(func) {
|
|
|
|
gBrowser.selectedBrowser.addEventListener("pageshow", function loadListener() {
|
|
|
|
gBrowser.selectedBrowser.removeEventListener("pageshow", loadListener, false);
|
|
|
|
func();
|
|
|
|
});
|
|
|
|
}
|