blob: 5298bd93e6df4427dd5b09744f601e682f46ba7a [file] [log] [blame]
<html>
<head>
<script src="../../../resources/js-test-pre.js"></script>
</head>
<body>
<p>Test having a &lt;style scoped&gt; element as a direct child of a ShadowRoot.</p>
<div id="host">
</div>
<div id="ref">
</div>
<div id="console"></div>
<script>
if (!window.internals)
debug("windows.internals not found!");
else if (!window.internals.ensureShadowRoot)
debug("windows.internals.ensureShadowRoot not found!");
else if (!window.internals.numberOfScopedHTMLStyleChildren)
debug("windows.internals.numberOfScopedHTMLStyleChildren not found!");
else {
var ref = document.getElementById('ref');
var host = document.getElementById('host');
var sr = internals.ensureShadowRoot(host);
var style = document.createElement('style');
style.setAttribute('scoped', 'scoped');
debug("--- Initial ---");
shouldBe("internals.numberOfScopedHTMLStyleChildren(host)", "0");
shouldBe("internals.numberOfScopedHTMLStyleChildren(sr)", "0"); /* <style> out of document, scoped */
debug("--- Attaching &lt;style scoped&gt; ---");
sr.appendChild(style);
shouldBe("internals.numberOfScopedHTMLStyleChildren(host)", "0");
shouldBe("internals.numberOfScopedHTMLStyleChildren(sr)", "1"); /* <style> in shadow, scoped */
debug("--- Removing host ---");
host.parentNode.removeChild(host);
shouldBe("internals.numberOfScopedHTMLStyleChildren(host)", "0");
shouldBe("internals.numberOfScopedHTMLStyleChildren(sr)", "0"); /* <style> out of document, scoped */
debug("--- Inserting host ---");
ref.parentNode.insertBefore(host, ref);
shouldBe("internals.numberOfScopedHTMLStyleChildren(host)", "0");
shouldBe("internals.numberOfScopedHTMLStyleChildren(sr)", "1"); /* <style> in shadow, scoped */
debug("--- Unsetting @scoped ---");
style.scoped = false;
shouldBe("internals.numberOfScopedHTMLStyleChildren(host)", "0");
shouldBe("internals.numberOfScopedHTMLStyleChildren(sr)", "1"); /* <style> in shadow, not scoped */
debug("--- Setting @scoped ---");
style.scoped = true;
shouldBe("internals.numberOfScopedHTMLStyleChildren(host)", "0");
shouldBe("internals.numberOfScopedHTMLStyleChildren(sr)", "1"); /* <style> in shadow, scoped */
debug("--- Detaching &lt;style scoped&gt; ---");
sr.removeChild(style);
shouldBe("internals.numberOfScopedHTMLStyleChildren(host)", "0");
shouldBe("internals.numberOfScopedHTMLStyleChildren(sr)", "0"); /* <style> out of document, scoped */
debug("--- Attaching &lt;style scoped&gt; under host ---");
host.appendChild(style);
shouldBe("internals.numberOfScopedHTMLStyleChildren(host)", "1");
shouldBe("internals.numberOfScopedHTMLStyleChildren(sr)", "0"); /* <style> in tree, scoped */
debug("--- DONE ---");
}
var successfullyParsed = true;
</script>
<script src="../../../resources/js-test-post.js"></script>
</body>
</html>