summaryrefslogtreecommitdiffstats
path: root/remote/test/puppeteer/test/assets/input/touchscreen.html
blob: b3a51e7f91cf003833513e841693709168d919b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<!DOCTYPE html>
<html>
  <head>
    <title>Touch test</title>
  </head>

  <body style="touch-action: none">
    <style>
      button {
        box-sizing: border-box;
        position: absolute;
        left: 0;
        top: 0;
        width: 10px;
        height: 10px;
        padding: 0;
        margin: 0;
      }
    </style>
    <button>Click target</button>
    <script>
      var allEvents = [];
      for (const name of ["touchstart", "touchmove", "touchend"]) {
        globalThis.addEventListener(
          name,
          (event) => {
            allEvents.push({
              type: name,
              changedTouches: [...event.changedTouches].map((touch) => ({
                clientX: touch.clientX,
                clientY: touch.clientY,
                radiusX: touch.radiusX,
                radiusY: touch.radiusY,
                force: touch.force,
              })),
              activeTouches: [...event.touches].map((touch) => ({
                clientX: touch.clientX,
                clientY: touch.clientY,
                radiusX: touch.radiusX,
                radiusY: touch.radiusY,
                force: touch.force,
              })),
            });
          },
          true,
        );
      }
      for (const name of ['pointerdown', 'pointermove', 'pointerup', 'click']) {
        globalThis.addEventListener(
          name,
          (event) => {
            allEvents.push({
              type: name,
              x: event.x,
              y: event.y,
              width: event.width,
              height: event.height,
              altitudeAngle: event.altitudeAngle,
              azimuthAngle: event.azimuthAngle,
              pressure: event.pressure,
              pointerType: event.pointerType,
              twist: event.twist,
              tiltX: event.tiltX,
              tiltY: event.tiltY,
            });
          },
          true,
        );
      }
    </script>
  </body>
</html>