From f9e048aa38258549e3b0e9977c157a3667f5cc4b Mon Sep 17 00:00:00 2001 From: Jason Laster Date: Fri, 5 May 2017 16:44:34 +0300 Subject: [PATCH] Bug 1357206 - fix the Windows key issues (#2820) --- src/test/integration/utils/mochitest.js | 15 +++++++++++++++ src/test/mochitest/head.js | 14 ++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/test/integration/utils/mochitest.js b/src/test/integration/utils/mochitest.js index 238fcfe94b..b53d892051 100644 --- a/src/test/integration/utils/mochitest.js +++ b/src/test/integration/utils/mochitest.js @@ -3,6 +3,7 @@ const { info } = require("./shared"); var ContentTask, gBrowser, isLinux, + isMac, cmdOrCtrl, keyMappings, openNewTabAndToolbox, @@ -11,12 +12,25 @@ var ContentTask, EventUtils; function setKeyboardMapping(isLinux, cmdOrCtrl) { + // On Mac, going to beginning/end only works with meta+left/right. On + // Windows, it only works with home/end. On Linux, apparently, either + // ctrl+left/right or home/end work. + const endKey = isMac + ? { code: "VK_RIGHT", modifiers: cmdOrCtrl } + : { code: "VK_END" }; + const startKey = isMac + ? { code: "VK_LEFT", modifiers: cmdOrCtrl } + : { code: "VK_HOME" }; return { sourceSearch: { code: "p", modifiers: cmdOrCtrl }, fileSearch: { code: "f", modifiers: cmdOrCtrl }, Enter: { code: "VK_RETURN" }, Up: { code: "VK_UP" }, Down: { code: "VK_DOWN" }, + Right: { code: "VK_RIGHT" }, + Left: { code: "VK_LEFT" }, + End: endKey, + Start: startKey, Tab: { code: "VK_TAB" }, Escape: { code: "VK_ESCAPE" }, pauseKey: { code: "VK_F8" }, @@ -38,6 +52,7 @@ function setupTestRunner(context) { EXAMPLE_URL = context.EXAMPLE_URL; EventUtils = context.EventUtils; isLinux = Services.appinfo.OS === "Linux"; + isMac = Services.appinfo.OS === "Darwin"; cmdOrCtrl = isLinux ? { ctrlKey: true } : { metaKey: true }; keyMappings = setKeyboardMapping(isLinux, cmdOrCtrl); } diff --git a/src/test/mochitest/head.js b/src/test/mochitest/head.js index a8a37504bc..b13cc8d825 100644 --- a/src/test/mochitest/head.js +++ b/src/test/mochitest/head.js @@ -554,7 +554,17 @@ function invokeInTab(fnc) { } const isLinux = Services.appinfo.OS === "Linux"; +const isMac = Services.appinfo.OS === "Darwin"; const cmdOrCtrl = isLinux ? { ctrlKey: true } : { metaKey: true }; +// On Mac, going to beginning/end only works with meta+left/right. On +// Windows, it only works with home/end. On Linux, apparently, either +// ctrl+left/right or home/end work. +const endKey = isMac + ? { code: "VK_RIGHT", modifiers: cmdOrCtrl } + : { code: "VK_END" }; +const startKey = isMac + ? { code: "VK_LEFT", modifiers: cmdOrCtrl } + : { code: "VK_HOME" }; const keyMappings = { sourceSearch: { code: "p", modifiers: cmdOrCtrl }, fileSearch: { code: "f", modifiers: cmdOrCtrl }, @@ -563,8 +573,8 @@ const keyMappings = { Down: { code: "VK_DOWN" }, Right: { code: "VK_RIGHT" }, Left: { code: "VK_LEFT" }, - End: { code: "VK_RIGHT", modifiers: cmdOrCtrl }, - Start: { code: "VK_LEFT", modifiers: cmdOrCtrl }, + End: endKey, + Start: startKey, Tab: { code: "VK_TAB" }, Escape: { code: "VK_ESCAPE" }, pauseKey: { code: "VK_F8" },