tor-browser

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

test_synthesized_touch.html (1247B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <title>Test synthesized touch input</title>
      4 <script src="/tests/SimpleTest/SimpleTest.js"></script>
      5 <script src="/tests/SimpleTest/EventUtils.js"></script>
      6 <link rel="stylesheet" href="/tests/SimpleTest/test.css" />
      7 
      8 <style>
      9  #container {
     10    width: 100px;
     11    height: 100px;
     12    background-color: green;
     13  }
     14 </style>
     15 
     16 <div id="container"></div>
     17 
     18 <script>
     19 function waitForEvent(aTarget, aEvent, aCheckFn) {
     20  return new Promise(aResolve => {
     21    aTarget.addEventListener(aEvent, function(e) {
     22      info(`${aEvent} received`);
     23      aCheckFn(e);
     24      aResolve();
     25    }, { once: true });
     26  });
     27 }
     28 
     29 add_task(async function test() {
     30  const tiltX = 10;
     31  const tiltY = -10;
     32  const twist = 5;
     33  const check = function(aEvent) {
     34    is(aEvent.tiltX, tiltX, "check tiltX");
     35    is(aEvent.tiltY, tiltY, "check tiltY");
     36    is(aEvent.twist, twist, "check twist");
     37  };
     38 
     39  const container = document.getElementById("container");
     40  const pointerDownPromise = waitForEvent(container, "pointerdown", check);
     41  const pointerUpPromise = waitForEvent(container, "pointerup", check);
     42 
     43  synthesizeTouchAtCenter(container, {tiltX, tiltY, twist});
     44 
     45  await Promise.all([pointerDownPromise, pointerUpPromise]);
     46 });
     47 </script>