summaryrefslogtreecommitdiffstats
path: root/dom/html/test/forms/test_interactive_content_in_summary.html
blob: f8bac77d8947405fbd615c91e2c2102c7a6e05a5 (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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1524893
-->
<head>
  <title>Test for Bug 1524893</title>
  <script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <script 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=1524893">Mozilla Bug 1524893</a>

<details id="details">
  <summary>
    <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="no">
    <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>

    <!-- Tests related to shadow tree. -->
    <div id="root1"> <!-- content will be added by script below. --> </div>
    <button><div id="root2"> <!-- content will be added by script below. --> </div></button>

    <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>
  </summary>
  <div>This is details</div>
</details>
<script class="testbody" type="text/javascript">

/** Test for Bug 1524893 **/

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

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

var root1 = document.getElementById("root1");
root1.attachShadow({ mode: "open" }).innerHTML = "<button class=yes>button in shadow tree</button>";
var root2 = document.getElementById("root2");
root2.attachShadow({ mode: "open" }).innerHTML = "<div class=yes>text in shadow tree</div>";
var yes_nodes_in_shadow_tree =
  Array.from(root1.shadowRoot.querySelectorAll(".yes")).concat(
    Array.from(root2.shadowRoot.querySelectorAll(".yes")));

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

var node;
for (node of yes_nodes) {
  details.removeAttribute('open');
  node.click();
  ok(!details.hasAttribute('open'),
     "mouse click on interactive content " + node.nodeName + " shouldn't not open details");
}

for (node of yes_nodes_in_shadow_tree) {
  details.removeAttribute('open');
  node.click();
  ok(!details.hasAttribute('open'),
     "mouse click on content in shadow tree " + node.nodeName + " shouldn't open details");
}

for (node of no_nodes) {
  details.removeAttribute('open');
  node.click();
  ok(details.hasAttribute('open'),
     "mouse click on non interactive content " + node.nodeName + " should open details");
}

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