tor-browser

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

touching.js (911B)


      1 function waitForCompositorCommit() {
      2  return new Promise((resolve) => {
      3    // rAF twice.
      4    window.requestAnimationFrame(() => {
      5      window.requestAnimationFrame(resolve);
      6    });
      7  });
      8 }
      9 
     10 function injectInput(touchDiv) {
     11  return new test_driver.Actions()
     12    .addPointer("touch_pointer", "touch")
     13    .pointerMove(0, 0, {origin: touchDiv})
     14    .pointerDown()
     15    .pointerMove(30, 30)
     16    .pointerUp()
     17    .send();
     18 }
     19 
     20 function runTest({target, eventName, passive, expectCancelable}) {
     21  let touchDiv = document.getElementById("touchDiv");
     22  let cancelable = null;
     23  let arrived = false;
     24  target.addEventListener(eventName, function (event) {
     25    cancelable = event.cancelable;
     26    arrived = true;
     27  }, {passive});
     28  promise_test(async () => {
     29    await waitForCompositorCommit();
     30    await injectInput(touchDiv);
     31    await waitFor(() => arrived);
     32    assert_equals(cancelable, expectCancelable);
     33  });
     34 }