summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/uievents/order-of-events/mouse-events/click-on-div.html
blob: bf06d8251cf6c956b2a1c351d2f6a45cd449bea3 (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
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Clicking on a div element that has no click event handler fires a click event</title>
    <link rel="author" title="Chris Rebert" href="http://chrisrebert.com">
    <link rel="help" href="https://w3c.github.io/uievents/#event-type-click">
    <link rel="help" href="https://dom.spec.whatwg.org/#concept-event-dispatch">
    <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>
#square {
  width: 100px;
  height: 100px;
  background-color: blue;
  color: white;
  /* Center the "Click me" text */
  line-height: 100px;
  text-align: center;
}
    </style>
  </head>
  <body>
    <p>Click on the blue square below.</p>
    <div id="square">Click me</div>
    <script>
setup({explicit_timeout: true});
promise_test(async function(t) {
  document.addEventListener('click', function (event) {
    var square = document.getElementById('square');
    t.step(function () {
      assert_equals(event.target, square, 'target of click event must be the test square');
      assert_equals(event.eventPhase, Event.BUBBLING_PHASE, 'click event must propagate to the document object during the Bubbling Phase');
      square.textContent = 'PASS';
      square.style.backgroundColor = 'green';
      t.done();
    });
  }, false);

  await test_driver.click(square);
}, "Clicking on a div element and having a click event listener on only document");
    </script>
  </body>
</html>