Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Unified Diff: LayoutTests/fast/css/style-scoped/registering-shadowroot.html

Issue 317143002: Revert of Remove scoped styles. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: LayoutTests/fast/css/style-scoped/registering-shadowroot.html
diff --git a/LayoutTests/fast/css/style-scoped/registering-shadowroot.html b/LayoutTests/fast/css/style-scoped/registering-shadowroot.html
new file mode 100644
index 0000000000000000000000000000000000000000..b1c54a79fb977f1e74b3d0daec79be18f1df94e1
--- /dev/null
+++ b/LayoutTests/fast/css/style-scoped/registering-shadowroot.html
@@ -0,0 +1,70 @@
+<html>
+<head>
+ <script src="../../../resources/js-test.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.numberOfScopedHTMLStyleChildren)
+ debug("windows.internals.numberOfScopedHTMLStyleChildren not found!");
+ else {
+ var ref = document.getElementById('ref');
+ var host = document.getElementById('host');
+ var sr = host.createShadowRoot();
+ 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>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698