11cb0ef41Sopenharmony_ci/*
21cb0ef41Sopenharmony_ci * Function that sends an accesskey using the proper key combination depending on the browser and OS.
31cb0ef41Sopenharmony_ci *
41cb0ef41Sopenharmony_ci * This needs that the test imports the following scripts:
51cb0ef41Sopenharmony_ci *     <script src="/resources/testdriver.js"></script>
61cb0ef41Sopenharmony_ci *     <script src="/resources/testdriver-actions.js"></script>
71cb0ef41Sopenharmony_ci *     <script src="/resources/testdriver-vendor.js"></script>
81cb0ef41Sopenharmony_ci*/
91cb0ef41Sopenharmony_cifunction pressAccessKey(accessKey){
101cb0ef41Sopenharmony_ci  let controlKey = '\uE009'; // left Control key
111cb0ef41Sopenharmony_ci  let altKey = '\uE00A'; // left Alt key
121cb0ef41Sopenharmony_ci  let optionKey = altKey;  // left Option key
131cb0ef41Sopenharmony_ci  let shiftKey = '\uE008'; // left Shift key
141cb0ef41Sopenharmony_ci  // There are differences in using accesskey across browsers and OS's.
151cb0ef41Sopenharmony_ci  // See: // https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/accesskey
161cb0ef41Sopenharmony_ci  let isMacOSX = navigator.userAgent.indexOf("Mac") != -1;
171cb0ef41Sopenharmony_ci  let osAccessKey = isMacOSX ? [controlKey, optionKey] : [shiftKey, altKey];
181cb0ef41Sopenharmony_ci  let actions = new test_driver.Actions();
191cb0ef41Sopenharmony_ci  // Press keys.
201cb0ef41Sopenharmony_ci  for (let key of osAccessKey) {
211cb0ef41Sopenharmony_ci    actions = actions.keyDown(key);
221cb0ef41Sopenharmony_ci  }
231cb0ef41Sopenharmony_ci  actions = actions
241cb0ef41Sopenharmony_ci            .keyDown(accessKey)
251cb0ef41Sopenharmony_ci            .addTick()
261cb0ef41Sopenharmony_ci            .keyUp(accessKey);
271cb0ef41Sopenharmony_ci  osAccessKey.reverse();
281cb0ef41Sopenharmony_ci  for (let key of osAccessKey) {
291cb0ef41Sopenharmony_ci    actions = actions.keyUp(key);
301cb0ef41Sopenharmony_ci  }
311cb0ef41Sopenharmony_ci  return actions.send();
321cb0ef41Sopenharmony_ci}
331cb0ef41Sopenharmony_ci
341cb0ef41Sopenharmony_ci
35