summaryrefslogtreecommitdiffstats
path: root/remote/test/puppeteer/test/assets/input/touchscreen.html
blob: 76e31c97f9380cf93af471700e9d8a4e4813b48a (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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<!doctype html>
<html>
  <head>
    <title>Touch test</title>
  </head>

  <body>
    <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 = [];
      globalThis.addEventListener(
        "touchstart",
        (event) => {
          allEvents.push({
            type: "touchstart",
            touches: [...event.changedTouches].map((touch) => [
              touch.clientX,
              touch.clientY,
              touch.radiusX,
              touch.radiusY,
            ]),
          });
        },
        true,
      );
      globalThis.addEventListener(
        "touchmove",
        (event) => {
          allEvents.push({
            type: "touchmove",
            touches: [...event.changedTouches].map((touch) => [
              touch.clientX,
              touch.clientY,
              touch.radiusX,
              touch.radiusY,
            ]),
          });
        },
        true,
      );
      globalThis.addEventListener(
        "touchend",
        (event) => {
          allEvents.push({
            type: "touchend",
            touches: [...event.changedTouches].map((touch) => [
              touch.clientX,
              touch.clientY,
              touch.radiusX,
              touch.radiusY,
            ])
          });
        },
        true,
      );
      globalThis.addEventListener(
        "pointerdown",
        (event) => {
          allEvents.push({
            type: "pointerdown",
            x: event.x,
            y: event.y,
            width: event.width,
            height: event.height,
          });
        },
        true,
      );
      globalThis.addEventListener(
        "pointermove",
        (event) => {
          allEvents.push({
            type: "pointermove",
            x: event.x,
            y: event.y,
            width: event.width,
            height: event.height,
          });
        },
        true,
      );
      globalThis.addEventListener(
        "pointerup",
        (event) => {
          allEvents.push({
            type: "pointerup",
            x: event.x,
            y: event.y,
            width: event.width,
            height: event.height,
          });
        },
        true,
      );
      globalThis.addEventListener(
        "click",
        (event) => {
          allEvents.push({
            type: "click",
            x: event.x,
            y: event.y,
            width: event.width,
            height: event.height,
          });
        },
        true,
      );
    </script>
  </body>
</html>