summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/pointerevents/pointerup_after_pointerdown_target_removed.html
blob: 65c6ea314c8fd0b316290de9319c7750a676721a (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
<!DOCTYPE HTML>
<title>pointerup event fired after pointerdown target is removed</title>
<meta name="variant" content="?mouse">
<meta name="variant" content="?touch">
<meta name="variant" content="?pen">
<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>
<script src="pointerevent_support.js"></script>

<style>
  div.target {
      width: 100px;
      height: 50px;
  }
</style>
<div class="target" id="parent">
  <div class="target" id="child">child</div>
</div>
<div id="done">done</div>

<script>
  'use strict';
  const pointer_type = location.search.substring(1);

  const parent = document.getElementById("parent");
  const child = document.getElementById("child");
  const done = document.getElementById("done");

  let event_log = [];

  function logEvent(e) {
    event_log.push(`${e.type}(${e.eventPhase})`);
  }

  parent.addEventListener("pointerup", logEvent);
  parent.addEventListener("mouseup", logEvent);
  child.addEventListener("pointerdown", e => e.target.remove(), {once:true});

  promise_test(async () => {
    let done_click_promise = getEvent("click", done);

    let actions = new test_driver.Actions()
        .addPointer("TestPointer", pointer_type)
        .pointerMove(0, 0, {origin: parent})
        .pointerDown()
        .pointerUp()
        .pointerMove(0, 0, {origin: done})
        .pointerDown()
        .pointerUp();

    await actions.send();
    await done_click_promise;

    assert_equals(event_log.toString(),
        "pointerup(2),mouseup(2)",
        "received events");
  }, `pointerup event from ${pointer_type} fired after pointerdown target is removed`);
</script>