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

Unified Diff: LayoutTests/fast/css/style-scoped/basic-attribute.html

Issue 315173002: 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
« no previous file with comments | « no previous file | LayoutTests/fast/css/style-scoped/basic-attribute-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/fast/css/style-scoped/basic-attribute.html
diff --git a/LayoutTests/fast/css/style-scoped/basic-attribute.html b/LayoutTests/fast/css/style-scoped/basic-attribute.html
new file mode 100644
index 0000000000000000000000000000000000000000..b2fd3696c722023b88cd0c587460cb8d1c41498f
--- /dev/null
+++ b/LayoutTests/fast/css/style-scoped/basic-attribute.html
@@ -0,0 +1,122 @@
+<html>
+<head>
+ <script src="../../../resources/js-test.js"></script>
+</head>
+<body>
+ <p>Basic test for the &lt;style scoped&gt; attribute.</p>
+ <div id="scope">
+ <style id="global1"></style>
+ <style scoped='scoped' id="scoped1"></style>
+ </div>
+
+ <div id="console"></div>
+
+ <script>
+ function testBooleanAttribute(elem, attr)
+ {
+ var val = elem.getAttribute(attr);
+ if (val === null)
+ return false
+ if (val === '' || val === attr)
+ return true;
+ throw "Illegal value for boolean attribute!";
+ }
+
+ var scope = document.getElementById('scope');
+
+ var global1 = document.getElementById('global1');
+ var scoped1 = document.getElementById('scoped1');
+
+ var global2 = document.createElement('style');
+ var scoped2 = document.createElement('style');
+ scoped2.setAttribute('scoped', 'scoped');
+ var scoped3 = document.createElement('style');
+ scoped3.scoped = true;
+
+ debug("--- Initial ---");
+ shouldBeNull("global1.getAttribute('scoped')");
+ shouldBeFalse("global1.scoped");
+ shouldBeNull("global2.getAttribute('scoped')");
+ shouldBeFalse("global2.scoped");
+ shouldBeTrue("testBooleanAttribute(scoped1, 'scoped')");
+ shouldBeTrue("scoped1.scoped");
+ shouldBeTrue("testBooleanAttribute(scoped2, 'scoped')");
+ shouldBeTrue("scoped2.scoped");
+ shouldBeTrue("testBooleanAttribute(scoped3, 'scoped')");
+ shouldBeTrue("scoped3.scoped");
+
+ debug("--- After insertion into tree ---")
+ scope.appendChild(global2);
+ scope.appendChild(scoped2);
+ scope.appendChild(scoped3);
+
+ shouldBeNull("global1.getAttribute('scoped')");
+ shouldBeFalse("global1.scoped");
+ shouldBeNull("global2.getAttribute('scoped')");
+ shouldBeFalse("global2.scoped");
+ shouldBeTrue("testBooleanAttribute(scoped1, 'scoped')");
+ shouldBeTrue("scoped1.scoped");
+ shouldBeTrue("testBooleanAttribute(scoped2, 'scoped')");
+ shouldBeTrue("scoped2.scoped");
+ shouldBeTrue("testBooleanAttribute(scoped3, 'scoped')");
+ shouldBeTrue("scoped3.scoped");
+
+ debug("--- Inverting 'scoped' attribute while in tree ---");
+ scoped1.scoped = null;
+ scoped2.scoped = false;
+ scoped3.removeAttribute('scoped');
+ global1.scoped = true;
+ global2.setAttribute('scoped', 'scoped');
+
+ shouldBeTrue("testBooleanAttribute(global1, 'scoped')");
+ shouldBeTrue("global1.scoped");
+ shouldBeTrue("testBooleanAttribute(global2, 'scoped')");
+ shouldBeTrue("global2.scoped");
+ shouldBeNull("scoped1.getAttribute('scoped')");
+ shouldBeFalse("scoped1.scoped");
+ shouldBeNull("scoped2.getAttribute('scoped')");
+ shouldBeFalse("scoped2.scoped");
+ shouldBeNull("scoped3.getAttribute('scoped')");
+ shouldBeFalse("scoped3.scoped");
+
+ debug("--- After removal from tree (attribute is still inverted) ---");
+ scope.removeChild(global1);
+ scope.removeChild(global2);
+ scope.removeChild(scoped1);
+ scope.removeChild(scoped2);
+ scope.removeChild(scoped3);
+
+ shouldBeTrue("testBooleanAttribute(global1, 'scoped')");
+ shouldBeTrue("global1.scoped");
+ shouldBeTrue("testBooleanAttribute(global2, 'scoped')");
+ shouldBeTrue("global2.scoped");
+ shouldBeNull("scoped1.getAttribute('scoped')");
+ shouldBeFalse("scoped1.scoped");
+ shouldBeNull("scoped2.getAttribute('scoped')");
+ shouldBeFalse("scoped2.scoped");
+ shouldBeNull("scoped3.getAttribute('scoped')");
+ shouldBeFalse("scoped3.scoped");
+
+ debug("--- Inverting 'scoped' attribute again, while outside tree ---");
+ scoped1.scoped = true;
+ scoped2.scoped = true;
+ scoped3.setAttribute('scoped', 'scoped');
+ global1.scoped = false;
+ global2.removeAttribute('scoped');
+
+ shouldBeNull("global1.getAttribute('scoped')");
+ shouldBeFalse("global1.scoped");
+ shouldBeNull("global2.getAttribute('scoped')");
+ shouldBeFalse("global2.scoped");
+ shouldBeTrue("testBooleanAttribute(scoped1, 'scoped')");
+ shouldBeTrue("scoped1.scoped");
+ shouldBeTrue("testBooleanAttribute(scoped2, 'scoped')");
+ shouldBeTrue("scoped2.scoped");
+ shouldBeTrue("testBooleanAttribute(scoped3, 'scoped')");
+ shouldBeTrue("scoped3.scoped");
+
+ debug("--- DONE ---");
+ var successfullyParsed = true;
+ </script>
+</body>
+</html>
« no previous file with comments | « no previous file | LayoutTests/fast/css/style-scoped/basic-attribute-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698