Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
4 function test() {
5 waitForExplicitFinish();
7 nextTest();
8 }
10 let urls = [
11 "javascript:'foopy';",
12 "data:text/html,<body>hi"
13 ];
15 function urlEnter(url) {
16 gURLBar.value = url;
17 gURLBar.focus();
18 EventUtils.synthesizeKey("VK_RETURN", {});
19 }
21 function urlClick(url) {
22 gURLBar.value = url;
23 gURLBar.focus();
24 let goButton = document.getElementById("urlbar-go-button");
25 EventUtils.synthesizeMouseAtCenter(goButton, {});
26 }
28 function nextTest() {
29 let url = urls.shift();
30 if (url) {
31 testURL(url, urlEnter, function () {
32 testURL(url, urlClick, nextTest);
33 });
34 }
35 else
36 finish();
37 }
39 function testURL(url, loadFunc, endFunc) {
40 let tab = gBrowser.selectedTab = gBrowser.addTab();
41 registerCleanupFunction(function () {
42 gBrowser.removeTab(tab);
43 });
44 addPageShowListener(function () {
45 let pagePrincipal = gBrowser.contentPrincipal;
46 loadFunc(url);
48 addPageShowListener(function () {
49 let fm = Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager);
50 is(fm.focusedElement, null, "should be no focused element");
51 is(fm.focusedWindow, gBrowser.contentWindow, "content window should be focused");
53 ok(!gBrowser.contentPrincipal.equals(pagePrincipal),
54 "load of " + url + " by " + loadFunc.name + " should produce a page with a different principal");
55 endFunc();
56 });
57 });
58 }
60 function addPageShowListener(func) {
61 gBrowser.selectedBrowser.addEventListener("pageshow", function loadListener() {
62 gBrowser.selectedBrowser.removeEventListener("pageshow", loadListener, false);
63 func();
64 });
65 }