summaryrefslogtreecommitdiffstats
path: root/dom/html/test/forms/test_interactive_content_in_label.html
blob: 3df64eae24dd96b5ff5a8c0f557c4eb89ff55954 (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
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=229925
-->
<head>
  <title>Test for Bug 229925</title>
  <script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=229925">Mozilla Bug 229925</a>
<p id="display"></p>
<form action="#">
  <label>
    <span id="text">label</span>
    <input type="button" id="target" value="target">

    <a class="yes" href="#">a</a>
    <audio class="yes" controls></audio>
    <button class="yes">button</button>
    <details class="yes">details</details>
    <embed class="yes">embed</embed>
    <iframe class="yes" src="data:text/plain," style="width: 16px; height: 16px;"></iframe>
    <img class="yes" src="data:image/png," usemap="#map">
    <input class="yes" type="text" size="4">
    <keygen class="yes">
    <label class="yes">label</label>
    <object class="yes" usemap="#map">object</object>
    <select class="yes"><option>select</option></select>
    <textarea class="yes" cols="1" rows="1"></textarea>
    <video class="yes" controls></video>

    <a class="no">a</a>
    <audio class="no"></audio>
    <img class="no" src="data:image/png,">
    <input class="no" type="hidden">
    <object class="no">object</object>
    <video class="no"></video>

    <span class="no" tabindex="1">tabindex</span>
    <audio class="no" tabindex="1"></audio>
    <img class="no" src="data:image/png," tabindex="1">
    <input class="no" type="hidden" tabindex="1">
    <object class="no" tabindex="1">object</object>
    <video class="no" tabindex="1"></video>
  </label>
</form>
<script class="testbody" type="text/javascript">

/** Test for Bug 229925 **/

var target = document.getElementById("target");

var yes_nodes = Array.from(document.getElementsByClassName("yes"));

var no_nodes = Array.from(document.getElementsByClassName("no"));

var target_clicked = false;
target.addEventListener("click", function() {
  target_clicked = true;
});

var node;
for (node of yes_nodes) {
  target_clicked = false;
  node.click();
  is(target_clicked, false, "mouse click on interactive content " + node.nodeName + " shouldn't dispatch event to label target");
}

for (node of no_nodes) {
  target_clicked = false;
  node.click();
  is(target_clicked, true, "mouse click on non interactive content " + node.nodeName + " should dispatch event to label target");
}

</script>
</pre>
</body>
</html>