зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1521826 - Part 1: Sort commands by a shortcut being set r=Gijs
Commands that have a shortcut will be listed first in the extension shortcut UI. Differential Revision: https://phabricator.services.mozilla.com/D17877 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
5c8682b0c0
Коммит
cf52c09668
|
@ -273,6 +273,14 @@ async function renderAddons(addons) {
|
|||
|
||||
if (extension.shortcuts) {
|
||||
let commands = await extension.shortcuts.allCommands();
|
||||
commands.sort((a, b) => {
|
||||
// Boolean compare the shortcuts to see if they're both set or unset.
|
||||
if (!a.shortcut == !b.shortcut)
|
||||
return 0;
|
||||
if (a.shortcut)
|
||||
return -1;
|
||||
return 1;
|
||||
});
|
||||
|
||||
for (let command of commands) {
|
||||
let row = document.importNode(templates.row.content, true);
|
||||
|
|
|
@ -8,6 +8,7 @@ PromiseTestUtils.whitelistRejectionsGlobally(/Message manager disconnected/);
|
|||
|
||||
add_task(async function testUpdatingCommands() {
|
||||
let commands = {
|
||||
commandZero: {},
|
||||
commandOne: {
|
||||
suggested_key: {default: "Shift+Alt+4"},
|
||||
},
|
||||
|
@ -64,6 +65,12 @@ add_task(async function testUpdatingCommands() {
|
|||
let inputs = card.querySelectorAll(".shortcut-input");
|
||||
is(inputs.length, Object.keys(commands).length, "There is an input for each command");
|
||||
|
||||
let nameOrder = Array.from(inputs).map(input => input.getAttribute("name"));
|
||||
Assert.deepEqual(
|
||||
nameOrder,
|
||||
["commandOne", "commandTwo", "_execute_browser_action", "commandZero"],
|
||||
"commandZero should be last since it is unset");
|
||||
|
||||
for (let input of inputs) {
|
||||
// Change the shortcut.
|
||||
input.focus();
|
||||
|
|
Загрузка…
Ссылка в новой задаче