Bug 1272133 - Fix runtime error thrown when no shortcut is found for the target platform. r=kmag, a=gchang
authorMatthew Wein <mwein@mozilla.com>
Mon, 25 Jul 2016 11:18:12 -0700
changeset 342428 878f4c530d611318aec18c207c846dc1bca20778
parent 342427 16dac3dd9af01a52c34756b5769e5291ab9ea75e
child 342429 2b53363331a6162efc75d9488f17b33101649b64
push id1183
push userraliiev@mozilla.com
push dateMon, 05 Sep 2016 20:01:49 +0000
treeherdermozilla-release@3148731bed45 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskmag, gchang
bugs1272133
milestone49.0
Bug 1272133 - Fix runtime error thrown when no shortcut is found for the target platform. r=kmag, a=gchang MozReview-Commit-ID: CzR64GL5mxn
browser/components/extensions/ext-commands.js
--- a/browser/components/extensions/ext-commands.js
+++ b/browser/components/extensions/ext-commands.js
@@ -70,20 +70,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.
    */