tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

invoker-utils.js (1107B)


      1 function waitForRender() {
      2  return new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)));
      3 }
      4 async function clickOn(element) {
      5  await waitForRender();
      6  let rect = element.getBoundingClientRect();
      7  let actions = new test_driver.Actions();
      8  // FIXME: Switch to pointerMove(0, 0, {origin: element}) once
      9  // https://github.com/web-platform-tests/wpt/issues/41257 is fixed.
     10  await actions
     11      .pointerMove(Math.round(rect.x + rect.width / 2), Math.round(rect.y + rect.height / 2), {})
     12      .pointerDown({button: actions.ButtonType.LEFT})
     13      .pointerUp({button: actions.ButtonType.LEFT})
     14      .send();
     15  await waitForRender();
     16 }
     17 async function hoverOver(element) {
     18  await waitForRender();
     19  let rect = element.getBoundingClientRect();
     20  let actions = new test_driver.Actions();
     21  // FIXME: Switch to pointerMove(0, 0, {origin: element}) once
     22  // https://github.com/web-platform-tests/wpt/issues/41257 is fixed.
     23  await actions
     24      .pointerMove(Math.round(rect.x + rect.width / 2), Math.round(rect.y + rect.height / 2), {})
     25      .send();
     26  await waitForRender();
     27 }