-
Notifications
You must be signed in to change notification settings - Fork 360
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix disclosure_navigation_hybrid test, support platform specific key …
…conversion to key chord
- Loading branch information
Showing
5 changed files
with
48 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
/** | ||
* Returns true if the current platform is macOS | ||
* | ||
* @returns {boolean} | ||
*/ | ||
module.exports = function isMacOS() { | ||
return process.platform === 'darwin'; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const { Key } = require('selenium-webdriver'); | ||
const isMacOS = require('./isMacOS'); | ||
|
||
const MAC_KEY_MAPPINGS = { | ||
[Key.CONTROL]: Key.META, | ||
}; | ||
|
||
/** | ||
* Translates a key or key combination for the current OS | ||
* | ||
* @param {string|string[]} keys - The key(s) to translate | ||
* @returns {string[]} - The translated key(s) as a flat array ready for spreading | ||
*/ | ||
function translatePlatformKey(keys) { | ||
const keyArray = Array.isArray(keys) ? keys : [keys]; | ||
if (!isMacOS()) { | ||
return keyArray; | ||
} | ||
|
||
return keyArray.reduce((acc, key) => { | ||
const mappedKey = MAC_KEY_MAPPINGS[key] || key; | ||
return acc.concat(mappedKey); | ||
}, []); | ||
} | ||
|
||
module.exports = translatePlatformKey; |