Bug 1272133 - Fix runtime error thrown when no shortcut is found for the target platform. r=kmag
MozReview-Commit-ID: CzR64GL5mxn
--- 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.
*/