tor-browser

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

get-persistendeviceid-from-pointer-event.tentative.html (1377B)


      1 <!DOCTYPE html>
      2 <!--
      3   Tentative; contingent on merge of:
      4   https://github.com/w3c/pointerevents/pull/495
      5 -->
      6 <script src="/resources/testharness.js"></script>
      7 <script src="/resources/testharnessreport.js"></script>
      8 <script src="/resources/testdriver.js"></script>
      9 <script src="/resources/testdriver-actions.js"></script>
     10 <script src="/resources/testdriver-vendor.js"></script>
     11 
     12 <style>
     13  div {
     14    user-select: none; // Prevents text selection on drag.
     15  }
     16 </style>
     17 <div id="logger" draggable="false"></div>
     18 <div id="console"></div>
     19 <!-- This test verifies that pointerEvent.persistentDeviceId is 0
     20     by default for a pointer with an invalid hardware id - in this case
     21     a testdriver generated event, which does not support hardware id. -->
     22 <script>
     23    function CheckDeviceId(event) {
     24        eventFired++;
     25        assert_equals(event.persistentDeviceId, 0, "deviceId is 0");
     26    }
     27 
     28    window.addEventListener("pointerdown", CheckDeviceId, false);
     29    window.addEventListener("pointermove", CheckDeviceId, false);
     30 
     31    promise_test(async () => {
     32        eventFired = 0;
     33        let actions = new test_driver.Actions()
     34          .addPointer("TestPointer", "pen")
     35          .pointerDown()
     36          .pointerMove(100, 100)
     37          .pointerUp();
     38 
     39        await actions.send();
     40 
     41        assert_true(eventFired == 2);
     42    }, 'PointerEvent.persistentDeviceId');
     43 </script>