Bug 1271777 - Fix the 'MacCtr' typo in the commands API. r=kmag
☠☠ backed out by dc4d7f68030e ☠ ☠
authorMatthew Wein <mwein@mozilla.com>
Wed, 25 May 2016 16:58:43 -0700
changeset 338535 ea4940dd52ccc58a914bfb3b464fa6cee0af628c
parent 338534 dd9e8143abd8b62b708cc886863781603dae1397
child 338536 b98fa78343cdb06f01379d4a50f580a7a25ac4d4
push id6249
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 13:59:36 +0000
treeherdermozilla-beta@bad9d4f5bf7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskmag
bugs1271777
milestone49.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1271777 - Fix the 'MacCtr' typo in the commands API. r=kmag MozReview-Commit-ID: 2pVcqpfSRKT
browser/components/extensions/schemas/commands.json
browser/components/extensions/test/browser/browser_ext_commands_onCommand.js
--- a/browser/components/extensions/schemas/commands.json
+++ b/browser/components/extensions/schemas/commands.json
@@ -6,17 +6,17 @@
   {
     "namespace": "manifest",
     "types": [
      {
         "id": "KeyName",
         "choices": [
           {
             "type": "string",
-            "pattern": "^\\s*(Alt|Ctrl|Command|MacCtr)\\s*\\+\\s*(Shift\\s*\\+\\s*)?([A-Z0-9]|Comma|Period|Home|End|PageUp|PageDown|Space|Insert|Delete|Up|Down|Left|Right)\\s*$"
+            "pattern": "^\\s*(Alt|Ctrl|Command|MacCtrl)\\s*\\+\\s*(Shift\\s*\\+\\s*)?([A-Z0-9]|Comma|Period|Home|End|PageUp|PageDown|Space|Insert|Delete|Up|Down|Left|Right)\\s*$"
           },
           {
             "type": "string",
             "pattern": "^(MediaNextTrack|MediaPlayPause|MediaPrevTrack|MediaStop)$"
           }
         ]
       },
       {
--- a/browser/components/extensions/test/browser/browser_ext_commands_onCommand.js
+++ b/browser/components/extensions/test/browser/browser_ext_commands_onCommand.js
@@ -1,38 +1,61 @@
 /* -*- 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/AppConstants.jsm");
+
 add_task(function* test_user_defined_commands() {
   // Create a window before the extension is loaded.
   let win1 = yield BrowserTestUtils.openNewBrowserWindow();
   yield BrowserTestUtils.loadURI(win1.gBrowser.selectedBrowser, "about:robots");
   yield BrowserTestUtils.browserLoaded(win1.gBrowser.selectedBrowser);
 
+  let commands = {
+    "toggle-feature-using-alt-shift-3": {
+      "suggested_key": {
+        "default": "Alt+Shift+3",
+      },
+    },
+    "toggle-feature-using-control-shift-4": {
+      "suggested_key": {
+        "default": "Ctrl+Shift+4",
+      },
+    },
+    "toggle-feature-using-control-page-up": {
+      "suggested_key": {
+        "default": "Ctrl+PageUp",
+      },
+    },
+    "toggle-feature-using-alt-shift-comma": {
+      "suggested_key": {
+        "default": "Alt+Shift+Comma",
+      },
+      "unrecognized_property": "with-a-random-value",
+    },
+    "toggle-feature-with-whitespace-in-suggested-key": {
+      "suggested_key": {
+        "default": "  Alt + Shift + 2  ",
+      },
+    },
+  };
+
+  // Register the Mac OS-X specific commands.
+  if (AppConstants.platform == "macosx") {
+    commands["toggle-feature-using-mac-control-5"] = {
+      "suggested_key": {
+        "default": "MacCtrl+5",
+      },
+    };
+  }
+
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
-      "commands": {
-        "toggle-feature-using-alt-shift-3": {
-          "suggested_key": {
-            "default": "Alt+Shift+3",
-          },
-        },
-        "toggle-feature-using-alt-shift-comma": {
-          "suggested_key": {
-            "default": "Alt+Shift+Comma",
-          },
-          "unrecognized_property": "with-a-random-value",
-        },
-        "toggle-feature-with-whitespace-in-suggested-key": {
-          "suggested_key": {
-            "default": "  Alt + Shift + 2  ",
-          },
-        },
-      },
+      "commands": commands,
     },
 
     background: function() {
       browser.commands.onCommand.addListener(commandName => {
         browser.test.sendMessage("oncommand", commandName);
       });
       browser.test.sendMessage("ready");
     },
@@ -53,28 +76,43 @@ add_task(function* test_user_defined_com
   let win2 = yield BrowserTestUtils.openNewBrowserWindow();
   yield BrowserTestUtils.loadURI(win2.gBrowser.selectedBrowser, "about:config");
   yield BrowserTestUtils.browserLoaded(win2.gBrowser.selectedBrowser);
 
   // Confirm the keysets have been added to both windows.
   let keysetID = `ext-keyset-id-${makeWidgetId(extension.id)}`;
   let keyset = win1.document.getElementById(keysetID);
   ok(keyset != null, "Expected keyset to exist");
-  is(keyset.childNodes.length, 3, "Expected keyset to have 3 children");
+  is(keyset.childNodes.length, Object.keys(commands).length, "Expected keyset to have the correct number of children");
 
   keyset = win2.document.getElementById(keysetID);
   ok(keyset != null, "Expected keyset to exist");
-  is(keyset.childNodes.length, 3, "Expected keyset to have 3 children");
+  is(keyset.childNodes.length, Object.keys(commands).length, "Expected keyset to have the correct number of children");
 
   // Confirm that the commands are registered to both windows.
   yield focusWindow(win1);
   EventUtils.synthesizeKey("3", {altKey: true, shiftKey: true});
   let message = yield extension.awaitMessage("oncommand");
   is(message, "toggle-feature-using-alt-shift-3", "Expected onCommand listener to fire with correct message");
 
+  EventUtils.synthesizeKey("4", {accelKey: true, shiftKey: true});
+  message = yield extension.awaitMessage("oncommand");
+  is(message, "toggle-feature-using-control-shift-4", "Expected onCommand listener to fire with correct message");
+
+  EventUtils.synthesizeKey("VK_PAGE_UP", {accelKey: true});
+  message = yield extension.awaitMessage("oncommand");
+  is(message, "toggle-feature-using-control-page-up", "Expected onCommand listener to fire with correct message");
+
+  // Test the Mac OS-X specific shortcut.
+  if (AppConstants.platform == "macosx") {
+    EventUtils.synthesizeKey("5", {ctrlKey: true});
+    message = yield extension.awaitMessage("oncommand");
+    is(message, "toggle-feature-using-mac-control-5", "Expected onCommand listener to fire with correct message");
+  }
+
   yield focusWindow(win2);
   EventUtils.synthesizeKey("VK_COMMA", {altKey: true, shiftKey: true});
   message = yield extension.awaitMessage("oncommand");
   is(message, "toggle-feature-using-alt-shift-comma", "Expected onCommand listener to fire with correct message");
 
   EventUtils.synthesizeKey("2", {altKey: true, shiftKey: true});
   message = yield extension.awaitMessage("oncommand");
   is(message, "toggle-feature-with-whitespace-in-suggested-key", "Expected onCommand listener to fire with correct message");