browser/base/content/test/general/browser_zbug569342.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:494da35a2c43
1 /* Any copyright is dedicated to the Public Domain.
2 * http://creativecommons.org/publicdomain/zero/1.0/
3 */
4
5 var gTab = null;
6
7 function load(url, cb) {
8 gTab = gBrowser.addTab(url);
9 gBrowser.addEventListener("load", function (event) {
10 if (event.target.location != url)
11 return;
12
13 gBrowser.removeEventListener("load", arguments.callee, true);
14 // Trigger onLocationChange by switching tabs.
15 gBrowser.selectedTab = gTab;
16 cb();
17 }, true);
18 }
19
20 function test() {
21 waitForExplicitFinish();
22
23 ok(gFindBar.hidden, "Find bar should not be visible by default");
24
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");
28
29 nextTest();
30 }
31
32 let urls = [
33 "about:config",
34 "about:addons",
35 "about:permissions"
36 ];
37
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 }
51
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");
61
62 gBrowser.removeTab(gTab);
63 cb();
64 });
65 }
66
67 function testFindEnabled(url, cb) {
68 load(url, function() {
69 ok(!document.getElementById("cmd_find").getAttribute("disabled"),
70 "Find command should not be disabled");
71
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");
77
78 gBrowser.removeTab(gTab);
79 cb();
80 });
81 }

mercurial