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/
3 */
5 var gTab = null;
7 function load(url, cb) {
8 gTab = gBrowser.addTab(url);
9 gBrowser.addEventListener("load", function (event) {
10 if (event.target.location != url)
11 return;
13 gBrowser.removeEventListener("load", arguments.callee, true);
14 // Trigger onLocationChange by switching tabs.
15 gBrowser.selectedTab = gTab;
16 cb();
17 }, true);
18 }
20 function test() {
21 waitForExplicitFinish();
23 ok(gFindBar.hidden, "Find bar should not be visible by default");
25 // Open the Find bar before we navigate to pages that shouldn't have it.
26 EventUtils.synthesizeKey("f", { accelKey: true });
27 ok(!gFindBar.hidden, "Find bar should be visible");
29 nextTest();
30 }
32 let urls = [
33 "about:config",
34 "about:addons",
35 "about:permissions"
36 ];
38 function nextTest() {
39 let url = urls.shift();
40 if (url) {
41 testFindDisabled(url, nextTest);
42 } else {
43 // Make sure the find bar is re-enabled after disabled page is closed.
44 testFindEnabled("about:blank", function () {
45 EventUtils.synthesizeKey("VK_ESCAPE", { });
46 ok(gFindBar.hidden, "Find bar should now be hidden");
47 finish();
48 });
49 }
50 }
52 function testFindDisabled(url, cb) {
53 load(url, function() {
54 ok(gFindBar.hidden, "Find bar should not be visible");
55 EventUtils.synthesizeKey("/", {}, gTab.linkedBrowser.contentWindow);
56 ok(gFindBar.hidden, "Find bar should not be visible");
57 EventUtils.synthesizeKey("f", { accelKey: true });
58 ok(gFindBar.hidden, "Find bar should not be visible");
59 ok(document.getElementById("cmd_find").getAttribute("disabled"),
60 "Find command should be disabled");
62 gBrowser.removeTab(gTab);
63 cb();
64 });
65 }
67 function testFindEnabled(url, cb) {
68 load(url, function() {
69 ok(!document.getElementById("cmd_find").getAttribute("disabled"),
70 "Find command should not be disabled");
72 // Open Find bar and then close it.
73 EventUtils.synthesizeKey("f", { accelKey: true });
74 ok(!gFindBar.hidden, "Find bar should be visible again");
75 EventUtils.synthesizeKey("VK_ESCAPE", { });
76 ok(gFindBar.hidden, "Find bar should now be hidden");
78 gBrowser.removeTab(gTab);
79 cb();
80 });
81 }