tor-browser

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

test_contextmenu_pointerId_of_long_tap.html (1409B)


      1 <!doctype html>
      2 <head>
      3 <meta charset="utf-8">
      4 <title>`contextmenu` event for a long tap should have proper `pointerId`</title>
      5 <script src="/tests/SimpleTest/SimpleTest.js"></script>
      6 <script src="/tests/SimpleTest/EventUtils.js"></script>
      7 <script src="/tests/SimpleTest/paint_listener.js"></script>
      8 <script src="apz_test_utils.js"></script>
      9 <link rel="stylesheet" href="/tests/SimpleTest/test.css" />
     10 <script>
     11 "use strict";
     12 
     13 SimpleTest.waitForExplicitFinish();
     14 waitUntilApzStable().then(async () => {
     15  await SpecialPowers.pushPrefEnv({set: [
     16    ["test.events.async.enabled", true],
     17    ["ui.click_hold_context_menus.delay", 0],
     18  ]});
     19  const target = document.getElementById("target");
     20  const waitForContextMen = new Promise(resolve => {
     21    addEventListener("contextmenu", event => {
     22      is(
     23        event.pointerId,
     24        5,
     25        "pointerId of `contextmenu` should be the specified ID of the touch"
     26      );
     27      event.preventDefault();
     28      resolve();
     29    }, {once: true});
     30  });
     31  const waitForTouchEnd = new Promise(resolve => {
     32    addEventListener("touchend", resolve, {once: true});
     33  });
     34  synthesizeTouchAtCenter(target, {type: "touchstart", id: 5});
     35  synthesizeTouchAtCenter(target, {type: "touchend", id: 5});
     36  await Promise.all([waitForContextMen, waitForTouchEnd]);
     37  SimpleTest.finish();
     38 });
     39 </script>
     40 </head>
     41 <body>
     42  <a href="#" id="target">link to nowhere</a>
     43 </body>
     44 </html>