Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!DOCTYPE HTML>
<html>
<!--
-->
<head>
<title>Test for Bug 1524893</title>
<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>
<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>