summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/infrastructure/testdriver/actions/mouseClickCount.html
blob: 4f02088c5a7c4f17945b0e1028ace6186e8ee0c9 (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
<!DOCTYPE html>
<meta charset="utf-8">
<title>TestDriver actions: test the mouse click counts at different cases</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="/resources/testdriver-vendor.js"></script>

<style>
div#test {
  position: fixed;
  touch-action: none;
  top: 5px;
  left: 5px;
  width: 100px;
  height: 100px;
  background-color: blue;
}
</style>

<div id="test">
</div>

<script>
let clickCountList = [];

async_test(t => {
  let test = document.getElementById("test");
  test.addEventListener("click", e => {
    clickCountList.push(e.detail);
  });

  let div = document.getElementById("test");
  var actions = new test_driver.Actions();
  actions.pointerMove(0, 0, {origin: test})
    .pointerDown()
    .pointerUp()
    .pointerDown()
    .pointerUp()
    .pointerMove(15, 15, {origin: test})
    .pointerDown()
    .pointerUp()
    .pointerDown()
    .pointerUp()
    .pointerDown()
    .pointerUp()
    .send()
    .then(t.step_func_done(() => {
      let expectedClickCountList = [1, 2, 1, 2, 3];
      assert_array_equals(clickCountList, expectedClickCountList);
  })).catch(e => t.step_func(() => assert_unreached("Actions sequence failed " + e)));
});
</script>