Bug 1272133 - Fix runtime error thrown when no shortcut is found for the target platform. r=kmag draft
authorMatthew Wein <mwein@mozilla.com>
Mon, 25 Jul 2016 11:18:12 -0700
changeset 393068 aa062b32210b98a15981965ff4e9e9bd4108224c
parent 393065 951aa830b05185b7a7c98bf734dbab355b31a915
child 526483 a8bd760635748205b27ade4a088482ea6254b37d
push id24202
push usermwein@mozilla.com
push dateTue, 26 Jul 2016 23:38:13 +0000
reviewerskmag
bugs1272133
milestone50.0a1
Bug 1272133 - Fix runtime error thrown when no shortcut is found for the target platform. r=kmag MozReview-Commit-ID: CzR64GL5mxn
browser/components/extensions/ext-commands.js
--- a/browser/components/extensions/ext-commands.js
+++ b/browser/components/extensions/ext-commands.js
@@ -72,20 +72,22 @@ CommandList.prototype = {
   loadCommandsFromManifest(manifest) {
     let commands = new Map();
     // For Windows, chrome.runtime expects 'win' while chrome.commands
     // expects 'windows'.  We can special case this for now.
     let os = PlatformInfo.os == "win" ? "windows" : PlatformInfo.os;
     for (let name of Object.keys(manifest.commands)) {
       let command = manifest.commands[name];
       let shortcut = command.suggested_key[os] || command.suggested_key.default;
-      commands.set(name, {
-        description: command.description,
-        shortcut: shortcut.replace(/\s+/g, ""),
-      });
+      if (shortcut) {
+        commands.set(name, {
+          description: command.description,
+          shortcut: shortcut.replace(/\s+/g, ""),
+        });
+      }
     }
     return commands;
   },
 
   /**
    * Registers the commands to a document.
    * @param {ChromeWindow} window The XUL window to insert the Keyset.
    */