summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/uievents/order-of-events/mouse-events/click-on-div-manual.html
blob: 173e520a17eeb9ea6da189c217fe3af98df11a6b (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
<!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">
    <meta name="flags" content="interact">
    <script src="/resources/testharness.js"></script>
    <script src="/resources/testharnessreport.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. If a "PASS" result appears, the test passes; otherwise, it fails.</p>
    <div id="square">Click me</div>
    <script>
setup({explicit_timeout: true});
async_test(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);
}, "Clicking on a div element and having a click event listener on only document");
    </script>
  </body>
</html>