Bug 563912: Allow the tab key to only move to the items relevant to the selected extension. r=Unfocused, a=blocks-final

This commit is contained in:
Dave Townsend 2011-02-09 10:23:47 -08:00
parent e5507515ee
commit 8e78a72832
2 changed files with 64 additions and 1 deletions

View File

@ -170,3 +170,8 @@ xhtml|link {
#discover-view:not([selectedIndex="0"]) .loading {
display: none;
}
/* Elements in unselected richlistitems cannot be focused */
richlistitem:not([selected]) * {
-moz-user-focus: ignore;
}

View File

@ -2,7 +2,7 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// Tests the recent updates pane
// Tests the list view
var gProvider;
var gManagerWindow;
@ -571,3 +571,61 @@ add_test(function() {
run_next_test();
});
// Check that focus changes correctly move around the selected list item
add_test(function() {
function is_node_in_list(aNode) {
var list = gManagerWindow.document.getElementById("addon-list");
while (aNode && aNode != list)
aNode = aNode.parentNode;
if (aNode)
return true;
return false;
}
// Ignore the OSX full keyboard access setting
Services.prefs.setBoolPref("accessibility.tabfocus_applies_to_xul", false);
let items = get_test_items();
var fm = Cc["@mozilla.org/focus-manager;1"].
getService(Ci.nsIFocusManager);
let addon = items["Test add-on 6"];
EventUtils.synthesizeMouseAtCenter(addon, { }, gManagerWindow);
is(fm.focusedElement, addon.parentNode, "Focus should have moved to the list");
EventUtils.synthesizeKey("VK_TAB", { }, gManagerWindow);
is(fm.focusedElement, get_node(addon, "details-btn"), "Focus should have moved to the more button");
EventUtils.synthesizeKey("VK_TAB", { }, gManagerWindow);
is(fm.focusedElement, get_node(addon, "disable-btn"), "Focus should have moved to the disable button");
EventUtils.synthesizeKey("VK_TAB", { }, gManagerWindow);
is(fm.focusedElement, get_node(addon, "remove-btn"), "Focus should have moved to the remove button");
EventUtils.synthesizeKey("VK_TAB", { }, gManagerWindow);
ok(!is_node_in_list(fm.focusedElement), "Focus should be outside the list");
EventUtils.synthesizeKey("VK_TAB", { shiftKey: true }, gManagerWindow);
is(fm.focusedElement, get_node(addon, "remove-btn"), "Focus should have moved to the remove button");
EventUtils.synthesizeKey("VK_TAB", { shiftKey: true }, gManagerWindow);
EventUtils.synthesizeKey("VK_TAB", { shiftKey: true }, gManagerWindow);
is(fm.focusedElement, get_node(addon, "details-btn"), "Focus should have moved to the more button");
EventUtils.synthesizeKey("VK_TAB", { shiftKey: true }, gManagerWindow);
is(fm.focusedElement, addon.parentNode, "Focus should have moved to the list");
EventUtils.synthesizeKey("VK_TAB", { shiftKey: true }, gManagerWindow);
ok(!is_node_in_list(fm.focusedElement), "Focus should be outside the list");
try {
Services.prefs.clearUserPref("accessibility.tabfocus_applies_to_xul");
}
catch (e) { }
run_next_test();
});