Bug 617872 - Focus manager allows F6 to focus elements inside non-focusable iframes/browsers. r=smaug, a=blocking

This commit is contained in:
Neil Deakin 2010-12-09 13:20:00 -08:00
parent 073efd8c8b
commit 54df769994
2 changed files with 26 additions and 3 deletions

View File

@ -123,6 +123,22 @@ function test() {
browser1.contentWindow, null, true,
"focusedWindow after tab switch from no focus to no focus");
gURLBar.focus();
_browser_tabfocus_test_events = "";
_browser_tabfocus_test_lastfocus = gURLBar;
_browser_tabfocus_test_lastfocuswindow = window;
expectFocusShift(function () EventUtils.synthesizeKey("VK_F6", { }),
browser1.contentWindow, browser1.contentDocument.documentElement,
true, "switch document forward with f6");
EventUtils.synthesizeKey("VK_F6", { });
is(fm.focusedWindow, window, "switch document forward again with f6");
browser1.style.MozUserFocus = "ignore";
browser1.clientWidth;
EventUtils.synthesizeKey("VK_F6", { });
is(fm.focusedWindow, window, "switch document forward again with f6 when browser non-focusable");
window.addEventListener("focus", _browser_tabfocus_test_eventOccured, true);
window.addEventListener("blur", _browser_tabfocus_test_eventOccured, true);
@ -207,7 +223,7 @@ function expectFocusShift(callback, expectedWindow, expectedElement, focusChange
"focus: " + windowid + "-window";
}
if (expectedElement) {
if (expectedElement && expectedElement != expectedElement.ownerDocument.documentElement) {
if (expectedEvents)
expectedEvents += " ";
expectedEvents += "focus: " + getId(expectedElement);

View File

@ -2878,8 +2878,15 @@ nsFocusManager::GetRootForFocus(nsPIDOMWindow* aWindow,
if (aIsForDocNavigation) {
nsCOMPtr<nsIContent> docContent =
do_QueryInterface(aWindow->GetFrameElementInternal());
if (docContent && docContent->Tag() == nsGkAtoms::iframe)
return nsnull;
// document navigation skips iframes and frames that are specifically non-focusable
if (docContent) {
if (docContent->Tag() == nsGkAtoms::iframe)
return nsnull;
nsIFrame* frame = docContent->GetPrimaryFrame();
if (!frame || !frame->IsFocusable(nsnull, 0))
return nsnull;
}
}
else {
PRInt32 itemType;