michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ michael@0: */ michael@0: michael@0: var gTab = null; michael@0: michael@0: function load(url, cb) { michael@0: gTab = gBrowser.addTab(url); michael@0: gBrowser.addEventListener("load", function (event) { michael@0: if (event.target.location != url) michael@0: return; michael@0: michael@0: gBrowser.removeEventListener("load", arguments.callee, true); michael@0: // Trigger onLocationChange by switching tabs. michael@0: gBrowser.selectedTab = gTab; michael@0: cb(); michael@0: }, true); michael@0: } michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: michael@0: ok(gFindBar.hidden, "Find bar should not be visible by default"); michael@0: michael@0: // Open the Find bar before we navigate to pages that shouldn't have it. michael@0: EventUtils.synthesizeKey("f", { accelKey: true }); michael@0: ok(!gFindBar.hidden, "Find bar should be visible"); michael@0: michael@0: nextTest(); michael@0: } michael@0: michael@0: let urls = [ michael@0: "about:config", michael@0: "about:addons", michael@0: "about:permissions" michael@0: ]; michael@0: michael@0: function nextTest() { michael@0: let url = urls.shift(); michael@0: if (url) { michael@0: testFindDisabled(url, nextTest); michael@0: } else { michael@0: // Make sure the find bar is re-enabled after disabled page is closed. michael@0: testFindEnabled("about:blank", function () { michael@0: EventUtils.synthesizeKey("VK_ESCAPE", { }); michael@0: ok(gFindBar.hidden, "Find bar should now be hidden"); michael@0: finish(); michael@0: }); michael@0: } michael@0: } michael@0: michael@0: function testFindDisabled(url, cb) { michael@0: load(url, function() { michael@0: ok(gFindBar.hidden, "Find bar should not be visible"); michael@0: EventUtils.synthesizeKey("/", {}, gTab.linkedBrowser.contentWindow); michael@0: ok(gFindBar.hidden, "Find bar should not be visible"); michael@0: EventUtils.synthesizeKey("f", { accelKey: true }); michael@0: ok(gFindBar.hidden, "Find bar should not be visible"); michael@0: ok(document.getElementById("cmd_find").getAttribute("disabled"), michael@0: "Find command should be disabled"); michael@0: michael@0: gBrowser.removeTab(gTab); michael@0: cb(); michael@0: }); michael@0: } michael@0: michael@0: function testFindEnabled(url, cb) { michael@0: load(url, function() { michael@0: ok(!document.getElementById("cmd_find").getAttribute("disabled"), michael@0: "Find command should not be disabled"); michael@0: michael@0: // Open Find bar and then close it. michael@0: EventUtils.synthesizeKey("f", { accelKey: true }); michael@0: ok(!gFindBar.hidden, "Find bar should be visible again"); michael@0: EventUtils.synthesizeKey("VK_ESCAPE", { }); michael@0: ok(gFindBar.hidden, "Find bar should now be hidden"); michael@0: michael@0: gBrowser.removeTab(gTab); michael@0: cb(); michael@0: }); michael@0: }