Skip to content

Commit

Permalink
Use getOSPreferredModifierKey() utility to off cross-platform support
Browse files Browse the repository at this point in the history
  • Loading branch information
stalgiag committed Sep 16, 2024
1 parent efaa27c commit 25084fd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
7 changes: 5 additions & 2 deletions test/tests/toolbar_toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const assertAttributeValues = require('../util/assertAttributeValues');
const assertRovingTabindex = require('../util/assertRovingTabindex');
const assertHasFocus = require('../util/assertHasFocus');
const assertAttributeCanBeToggled = require('../util/assertAttributeCanBeToggled');
const getOSPreferredModifierKey = require('../util/getOSPreferredModifierKey');

const exampleFile = 'content/patterns/toolbar/examples/toolbar.html';

Expand Down Expand Up @@ -1115,7 +1116,8 @@ ariaTest(
'toolbar-button-enter-or-space',
async (t) => {
let textarea = await t.context.session.findElement(By.css('textarea'));
await textarea.sendKeys(Key.chord(Key.META, 'a'));
let modifierKey = getOSPreferredModifierKey();
await textarea.sendKeys(Key.chord(modifierKey, 'a'));
let originalText = await textarea.getAttribute('value');

const buttons = await t.context.queryElements(
Expand Down Expand Up @@ -1206,7 +1208,8 @@ ariaTest(
'toolbar-button-enter-or-space',
async (t) => {
let textarea = await t.context.session.findElement(By.css('textarea'));
await textarea.sendKeys(Key.chord(Key.META, 'a'));
let modifierKey = getOSPreferredModifierKey();
await textarea.sendKeys(Key.chord(modifierKey, 'a'));
let originalText = await textarea.getAttribute('value');

const buttons = await t.context.queryElements(
Expand Down
6 changes: 6 additions & 0 deletions test/util/getOSPreferredModifierKey.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const { Key } = require('selenium-webdriver');
const isMacOS = require('./isMacOS');

module.exports = function getOSPreferredModifierKey() {
return isMacOS() ? Key.META : Key.CONTROL;
};
3 changes: 3 additions & 0 deletions test/util/isMacOS.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = function isMacOS() {
return process.platform === 'darwin';
};

0 comments on commit 25084fd

Please sign in to comment.