diff --git a/toolkit/mozapps/extensions/content/extensions.css b/toolkit/mozapps/extensions/content/extensions.css index 8c5a7667b07..6a146824112 100644 --- a/toolkit/mozapps/extensions/content/extensions.css +++ b/toolkit/mozapps/extensions/content/extensions.css @@ -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; +} diff --git a/toolkit/mozapps/extensions/test/browser/browser_list.js b/toolkit/mozapps/extensions/test/browser/browser_list.js index 859c4bd8904..b5f19162e15 100644 --- a/toolkit/mozapps/extensions/test/browser/browser_list.js +++ b/toolkit/mozapps/extensions/test/browser/browser_list.js @@ -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(); +});