Port bug 1475043 - Allow "" as shortcut in commands.update. rs=bustage-fix
authorGeoff Lankow <geoff@darktrojan.net>
Fri, 31 Jan 2020 12:51:06 +1300
changeset 37173 6c2764c30d1636e8e28af1670e80ae8fa3424ed5
parent 37172 676178d1f6725a869c084b30e1a7e822bb5ac0c8
child 37174 79c715e3ece3ab58035b2a1fb0643632d9b7810d
push id2552
push userclokep@gmail.com
push dateMon, 10 Feb 2020 21:24:16 +0000
treeherdercomm-beta@f95a6f4408a3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbustage-fix
bugs1475043
Port bug 1475043 - Allow "" as shortcut in commands.update. rs=bustage-fix
mail/components/extensions/test/browser/browser_ext_commands_getAll.js
mail/components/extensions/test/browser/browser_ext_commands_update.js
--- a/mail/components/extensions/test/browser/browser_ext_commands_getAll.js
+++ b/mail/components/extensions/test/browser/browser_ext_commands_getAll.js
@@ -101,33 +101,33 @@ add_task(async function() {
 
           browser.test.assertEq(
             "has no suggested_key",
             command.description,
             "The description should match what is provided in the manifest"
           );
 
           browser.test.assertEq(
-            null,
+            "",
             command.shortcut,
             "The shortcut should be empty if not provided"
           );
 
           command = commands.find(
             c => c.name == "without-suggested-key-nor-description"
           );
 
           browser.test.assertEq(
             null,
             command.description,
             "The description should be empty when it is not provided"
           );
 
           browser.test.assertEq(
-            null,
+            "",
             command.shortcut,
             "The shortcut should be empty if not provided"
           );
 
           browser.test.notifyPass("commands");
         });
       });
       browser.test.sendMessage("ready");
--- a/mail/components/extensions/test/browser/browser_ext_commands_update.js
+++ b/mail/components/extensions/test/browser/browser_ext_commands_update.js
@@ -143,16 +143,32 @@ add_task(async function test_update_defi
           "The description is updated"
         );
         browser.test.assertEq(
           "Ctrl+Shift+L",
           command.shortcut,
           "The shortcut is unchanged"
         );
 
+        // Clear the shortcut.
+        await browser.commands.update({
+          name: "foo",
+          shortcut: "",
+        });
+        commands = await browser.commands.getAll();
+        browser.test.assertEq(1, commands.length, "There is still 1 command");
+        command = commands[0];
+        browser.test.assertEq("foo", command.name, "The name is unchanged");
+        browser.test.assertEq(
+          "The only command",
+          command.description,
+          "The description is unchanged"
+        );
+        browser.test.assertEq("", command.shortcut, "The shortcut is empty");
+
         // Update the description and shortcut.
         await browser.commands.update({
           name: "foo",
           description: "The new command",
           shortcut: "   Alt+  Shift +9",
         });
 
         // Test the updated shortcut.
@@ -170,17 +186,17 @@ add_task(async function test_update_defi
           command.shortcut,
           "The shortcut is updated"
         );
 
         // Test a bad shortcut update.
         browser.test.assertThrows(
           () =>
             browser.commands.update({ name: "foo", shortcut: "Ctl+Shift+L" }),
-          /Type error for parameter detail/,
+          /Type error for parameter detail .+ primary modifier and a key/,
           "It rejects for a bad shortcut"
         );
 
         // Try to update a command that doesn't exist.
         await browser.test.assertRejects(
           browser.commands.update({ name: "bar", shortcut: "Ctrl+Shift+L" }),
           'Unknown command "bar"',
           "It rejects for an unknown command"