2011-01-11 13:33:51 -08:00
|
|
|
/* Any copyright is dedicated to the Public Domain.
|
|
|
|
* http://creativecommons.org/publicdomain/zero/1.0/
|
|
|
|
*/
|
|
|
|
|
|
|
|
var gTab = null;
|
|
|
|
|
2011-01-21 09:18:21 -08:00
|
|
|
function load(url, cb) {
|
|
|
|
gTab = gBrowser.addTab(url);
|
|
|
|
gBrowser.addEventListener("load", function (event) {
|
2012-10-05 03:56:22 -07:00
|
|
|
if (event.target.location != url)
|
|
|
|
return;
|
|
|
|
|
2011-01-21 09:18:21 -08:00
|
|
|
gBrowser.removeEventListener("load", arguments.callee, true);
|
|
|
|
// Trigger onLocationChange by switching tabs.
|
|
|
|
gBrowser.selectedTab = gTab;
|
2011-01-11 13:33:51 -08:00
|
|
|
cb();
|
|
|
|
}, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
function test() {
|
|
|
|
waitForExplicitFinish();
|
|
|
|
|
2013-05-09 07:19:02 -07:00
|
|
|
ok(gFindBar.hidden, "Find bar should not be visible by default");
|
|
|
|
|
|
|
|
// Open the Find bar before we navigate to pages that shouldn't have it.
|
|
|
|
EventUtils.synthesizeKey("f", { accelKey: true });
|
|
|
|
ok(!gFindBar.hidden, "Find bar should be visible");
|
|
|
|
|
2011-06-06 08:15:21 -07:00
|
|
|
nextTest();
|
2011-01-11 13:33:51 -08:00
|
|
|
}
|
|
|
|
|
2011-06-06 08:15:21 -07:00
|
|
|
let urls = [
|
|
|
|
"about:config",
|
|
|
|
"about:addons",
|
|
|
|
"about:permissions"
|
|
|
|
];
|
|
|
|
|
|
|
|
function nextTest() {
|
|
|
|
let url = urls.shift();
|
|
|
|
if (url) {
|
|
|
|
testFindDisabled(url, nextTest);
|
|
|
|
} else {
|
|
|
|
// Make sure the find bar is re-enabled after disabled page is closed.
|
2013-09-13 07:41:23 -07:00
|
|
|
testFindEnabled("about:blank", function () {
|
|
|
|
EventUtils.synthesizeKey("VK_ESCAPE", { });
|
|
|
|
ok(gFindBar.hidden, "Find bar should now be hidden");
|
|
|
|
finish();
|
|
|
|
});
|
2011-06-06 08:15:21 -07:00
|
|
|
}
|
2011-01-11 13:33:51 -08:00
|
|
|
}
|
|
|
|
|
2011-06-06 08:15:21 -07:00
|
|
|
function testFindDisabled(url, cb) {
|
|
|
|
load(url, function() {
|
2011-01-11 13:33:51 -08:00
|
|
|
ok(gFindBar.hidden, "Find bar should not be visible");
|
|
|
|
EventUtils.synthesizeKey("/", {}, gTab.linkedBrowser.contentWindow);
|
|
|
|
ok(gFindBar.hidden, "Find bar should not be visible");
|
2011-01-21 09:18:21 -08:00
|
|
|
EventUtils.synthesizeKey("f", { accelKey: true });
|
|
|
|
ok(gFindBar.hidden, "Find bar should not be visible");
|
|
|
|
ok(document.getElementById("cmd_find").getAttribute("disabled"),
|
|
|
|
"Find command should be disabled");
|
2011-01-11 13:33:51 -08:00
|
|
|
|
2011-01-21 09:18:21 -08:00
|
|
|
gBrowser.removeTab(gTab);
|
2011-06-06 08:15:21 -07:00
|
|
|
cb();
|
2011-01-11 13:33:51 -08:00
|
|
|
});
|
|
|
|
}
|
2011-01-21 09:18:21 -08:00
|
|
|
|
2011-06-06 08:15:21 -07:00
|
|
|
function testFindEnabled(url, cb) {
|
|
|
|
load(url, function() {
|
2011-01-21 09:18:21 -08:00
|
|
|
ok(!document.getElementById("cmd_find").getAttribute("disabled"),
|
|
|
|
"Find command should not be disabled");
|
|
|
|
|
2013-07-05 17:56:36 -07:00
|
|
|
// Open Find bar and then close it.
|
2013-05-09 07:19:02 -07:00
|
|
|
EventUtils.synthesizeKey("f", { accelKey: true });
|
2013-07-05 17:56:36 -07:00
|
|
|
ok(!gFindBar.hidden, "Find bar should be visible again");
|
2013-05-09 07:19:02 -07:00
|
|
|
EventUtils.synthesizeKey("VK_ESCAPE", { });
|
|
|
|
ok(gFindBar.hidden, "Find bar should now be hidden");
|
|
|
|
|
2011-01-21 09:18:21 -08:00
|
|
|
gBrowser.removeTab(gTab);
|
2011-06-06 08:15:21 -07:00
|
|
|
cb();
|
2011-01-21 09:18:21 -08:00
|
|
|
});
|
2011-06-06 08:15:21 -07:00
|
|
|
}
|