Bug 569342 - Find bar should not be enabled in about:addons [r=dtownsend,gavin a=blocking]

This commit is contained in:
Margaret Leibovic 2011-01-21 09:18:21 -08:00
parent 027d784cc5
commit 79e73cef20
2 changed files with 44 additions and 14 deletions

View File

@ -4319,6 +4319,21 @@ var XULBrowserWindow = {
document.documentElement.setAttribute("disablechrome", "true");
else
document.documentElement.removeAttribute("disablechrome");
// Disable find commands in documents that ask for them to be disabled.
let docElt = content.document.documentElement;
let disableFind = aLocationURI &&
(docElt && docElt.getAttribute("disablefastfind") == "true") &&
(aLocationURI.schemeIs("about") || aLocationURI.schemeIs("chrome"));
let findCommands = [document.getElementById("cmd_find"),
document.getElementById("cmd_findAgain"),
document.getElementById("cmd_findPrevious")];
findCommands.forEach(function (elt) {
if (disableFind)
elt.setAttribute("disabled", "true");
else
elt.removeAttribute("disabled");
});
}
UpdateBackForwardCommands(gBrowser.webNavigation);

View File

@ -4,45 +4,60 @@
var gTab = null;
function cleanUp() {
gBrowser.removeTab(gTab);
finish();
}
// function borrowed from browser_bug386835.js
function load(tab, url, cb) {
tab.linkedBrowser.addEventListener("load", function (event) {
event.currentTarget.removeEventListener("load", arguments.callee, true);
function load(url, cb) {
gTab = gBrowser.addTab(url);
gBrowser.addEventListener("load", function (event) {
gBrowser.removeEventListener("load", arguments.callee, true);
// Trigger onLocationChange by switching tabs.
gBrowser.selectedTab = gTab;
cb();
}, true);
tab.linkedBrowser.loadURI(url);
}
function test() {
waitForExplicitFinish();
gTab = gBrowser.selectedTab = gBrowser.addTab();
ok(gFindBar.hidden, "Find bar should not be visible");
run_test_1();
}
function run_test_1() {
load(gTab, "about:config", function() {
load("about:config", function() {
ok(gFindBar.hidden, "Find bar should not be visible");
EventUtils.synthesizeKey("/", {}, gTab.linkedBrowser.contentWindow);
ok(gFindBar.hidden, "Find bar should not be visible");
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");
gBrowser.removeTab(gTab);
run_test_2();
});
}
function run_test_2() {
load(gTab, "about:addons", function() {
load("about:addons", function() {
ok(gFindBar.hidden, "Find bar should not be visible");
EventUtils.synthesizeKey("/", {}, gTab.linkedBrowser.contentWindow);
ok(gFindBar.hidden, "Find bar should not be visible");
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");
cleanUp();
gBrowser.removeTab(gTab);
run_test_3();
});
}
function run_test_3() {
load("about:blank", function() {
ok(!document.getElementById("cmd_find").getAttribute("disabled"),
"Find command should not be disabled");
gBrowser.removeTab(gTab);
finish();
});
}