diff --git a/browser/components/extensions/ext-commands.js b/browser/components/extensions/ext-commands.js deleted file mode 100644 index a00e49603c13..000000000000 --- a/browser/components/extensions/ext-commands.js +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */ -/* vim: set sts=2 sw=2 et tw=80: */ -"use strict"; - -Cu.import("resource://gre/modules/ExtensionUtils.jsm"); - -var { - PlatformInfo, -} = ExtensionUtils; - -// WeakMap[Extension -> Map[name => Command]] -var commandsMap = new WeakMap(); - -function Command(description, shortcut) { - this.description = description; - this.shortcut = shortcut; -} - -/* eslint-disable mozilla/balanced-listeners */ -extensions.on("manifest_commands", (type, directive, extension, manifest) => { - let commands = new Map(); - for (let name of Object.keys(manifest.commands)) { - let os = PlatformInfo.os == "win" ? "windows" : PlatformInfo.os; - let manifestCommand = manifest.commands[name]; - let description = manifestCommand.description; - let shortcut = manifestCommand.suggested_key[os] || manifestCommand.suggested_key.default; - let command = new Command(description, shortcut); - commands.set(name, command); - } - commandsMap.set(extension, commands); -}); - -extensions.on("shutdown", (type, extension) => { - commandsMap.delete(extension); -}); -/* eslint-enable mozilla/balanced-listeners */ - -extensions.registerSchemaAPI("commands", null, (extension, context) => { - return { - commands: { - getAll() { - let commands = Array.from(commandsMap.get(extension), ([name, command]) => { - return ({ - name, - description: command.description, - shortcut: command.shortcut, - }); - }); - return Promise.resolve(commands); - }, - }, - }; -}); diff --git a/browser/components/extensions/jar.mn b/browser/components/extensions/jar.mn index 58aa7f14521a..0d800edeee97 100644 --- a/browser/components/extensions/jar.mn +++ b/browser/components/extensions/jar.mn @@ -5,7 +5,6 @@ browser.jar: content/browser/extension.svg content/browser/ext-utils.js - content/browser/ext-commands.js content/browser/ext-contextMenus.js content/browser/ext-browserAction.js content/browser/ext-pageAction.js diff --git a/browser/components/extensions/test/browser/browser.ini b/browser/components/extensions/test/browser/browser.ini index 3e1cd97c0688..b6ee6d060e3f 100644 --- a/browser/components/extensions/test/browser/browser.ini +++ b/browser/components/extensions/test/browser/browser.ini @@ -9,7 +9,6 @@ support-files = file_popup_api_injection_b.html [browser_ext_simple.js] -[browser_ext_commands.js] [browser_ext_currentWindow.js] [browser_ext_browserAction_simple.js] [browser_ext_browserAction_pageAction_icon.js] diff --git a/browser/components/extensions/test/browser/browser_ext_commands.js b/browser/components/extensions/test/browser/browser_ext_commands.js deleted file mode 100644 index 098d81d13aaa..000000000000 --- a/browser/components/extensions/test/browser/browser_ext_commands.js +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */ -/* vim: set sts=2 sw=2 et tw=80: */ -"use strict"; - -var {AppConstants} = Cu.import("resource://gre/modules/AppConstants.jsm"); - -add_task(function* () { - let extension = ExtensionTestUtils.loadExtension({ - manifest: { - "name": "Commands Extension", - "commands": { - "with-desciption": { - "suggested_key": { - "default": "Ctrl+Shift+Y", - }, - "description": "should have a description", - }, - "without-description": { - "suggested_key": { - "default": "Ctrl+Shift+D", - }, - }, - "with-platform-info": { - "suggested_key": { - "mac": "Ctrl+Shift+M", - "linux": "Ctrl+Shift+L", - "windows": "Ctrl+Shift+W", - "android": "Ctrl+Shift+A", - }, - }, - }, - }, - - background: function() { - browser.test.onMessage.addListener((message, additionalScope) => { - browser.commands.getAll((commands) => { - browser.test.log(JSON.stringify(commands)); - browser.test.assertEq(commands.length, 3, "getAll should return an array of commands"); - - let command = commands.find(c => c.name == "with-desciption"); - browser.test.assertEq("should have a description", command.description, - "The description should match what is provided in the manifest"); - browser.test.assertEq("Ctrl+Shift+Y", command.shortcut, - "The shortcut should match the default shortcut provided in the manifest"); - - command = commands.find(c => c.name == "without-description"); - browser.test.assertEq(null, command.description, - "The description should be empty when it is not provided"); - browser.test.assertEq("Ctrl+Shift+D", command.shortcut, - "The shortcut should match the default shortcut provided in the manifest"); - - let platformKeys = { - macosx: "M", - linux: "L", - win: "W", - android: "A", - }; - - command = commands.find(c => c.name == "with-platform-info"); - let platformKey = platformKeys[additionalScope.platform]; - let shortcut = `Ctrl+Shift+${platformKey}`; - browser.test.assertEq(shortcut, command.shortcut, - `The shortcut should match the one provided in the manifest for OS='${additionalScope.platform}'`); - - browser.test.notifyPass("commands"); - }); - }); - browser.test.sendMessage("ready"); - }, - }); - - yield extension.startup(); - yield extension.awaitMessage("ready"); - extension.sendMessage("additional-scope", {platform: AppConstants.platform}); - yield extension.awaitFinish("commands"); - yield extension.unload(); -}); diff --git a/browser/components/nsBrowserGlue.js b/browser/components/nsBrowserGlue.js index dbce85e8fb6a..e6eb2509ced6 100644 --- a/browser/components/nsBrowserGlue.js +++ b/browser/components/nsBrowserGlue.js @@ -546,7 +546,6 @@ BrowserGlue.prototype = { ExtensionManagement.registerScript("chrome://browser/content/ext-utils.js"); ExtensionManagement.registerScript("chrome://browser/content/ext-browserAction.js"); ExtensionManagement.registerScript("chrome://browser/content/ext-pageAction.js"); - ExtensionManagement.registerScript("chrome://browser/content/ext-commands.js"); ExtensionManagement.registerScript("chrome://browser/content/ext-contextMenus.js"); ExtensionManagement.registerScript("chrome://browser/content/ext-desktop-runtime.js"); ExtensionManagement.registerScript("chrome://browser/content/ext-tabs.js");