Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Commit

Permalink
Bug 1357206 - fix the Windows key issues (#2820)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonLaster authored May 5, 2017
1 parent 25d9671 commit f9e048a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
15 changes: 15 additions & 0 deletions src/test/integration/utils/mochitest.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const { info } = require("./shared");
var ContentTask,
gBrowser,
isLinux,
isMac,
cmdOrCtrl,
keyMappings,
openNewTabAndToolbox,
Expand All @@ -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" },
Expand All @@ -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);
}
Expand Down
14 changes: 12 additions & 2 deletions src/test/mochitest/head.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand All @@ -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" },
Expand Down

0 comments on commit f9e048a

Please sign in to comment.