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

Unified Diff: LayoutTests/fast/css/variables/cssom-computed-style.html

Issue 21006006: Add forEach() to CSSVariablesMap (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase and review changes Created 7 years, 3 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/variables/cssom-computed-style-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/fast/css/variables/cssom-computed-style.html
diff --git a/LayoutTests/fast/css/variables/cssom-computed-style.html b/LayoutTests/fast/css/variables/cssom-computed-style.html
index 5a58b0f6d9f8bacdd44e99441b894df5e53fb7ec..251caf573f89d685667b68ce39b2edae20a79932 100644
--- a/LayoutTests/fast/css/variables/cssom-computed-style.html
+++ b/LayoutTests/fast/css/variables/cssom-computed-style.html
@@ -1,70 +1,51 @@
-<script>
-if (window.testRunner)
- testRunner.dumpAsText();
-</script>
+<!doctype html>
+<head><script src="../../js/resources/js-test-pre.js"></script></head>
<style>
-pre {
+#test-target {
var-stylesheet: pass;
}
</style>
<body>
-
-<pre style="var-inherited: pass"><pre id="pre" style="var-inline: pass"></pre></pre>
-
+<div style="var-inherited: pass"><div id="test-target" style="var-inline: pass"></div></div>
</body>
<script>
-var pre = document.querySelector("#pre");
-var preStyle = getComputedStyle(pre);
-var bodyStyle = getComputedStyle(document.querySelector("body"));
-pre.innerText += "Computed variables declaration: " + preStyle.var + "\n";
-
-pre.innerText += "Create variable: ";
-try {
- preStyle.var.set("create", "test");
- pre.innerText += "No exception thrown.\n";
-}
-catch (exception) {
- pre.innerText += exception + "\n";
-}
-
-pre.innerText += "Count variables: " + preStyle.var.size + "\n";
-pre.innerText += "Count empty variables: " + bodyStyle.var.size + "\n";
-pre.innerText += "Read stylesheet variable: " + preStyle.var.get("stylesheet") + "\n";
-pre.innerText += "Read inherited variable: " + preStyle.var.get("inherited") + "\n";
-pre.innerText += "Read inline variable: " + preStyle.var.get("inline") + "\n";
-pre.innerText += "Read non-existent variable: " + (bodyStyle.var.get("test") ? "fail" : "pass") + "\n";
-
-pre.innerText += "Update variable: ";
-try {
- preStyle.var.set("inline", "test");
- pre.innerText += "No exception thrown (fail).\n";
-}
-catch (exception) {
- pre.innerText += exception + "\n";
-}
-
-pre.innerText += "Delete variable: " + (preStyle.var.delete("inline") ? "Deleted" : "Not deleted") + "\n";
-
-pre.innerText += "Clear variables: ";
-try {
- preStyle.var.clear();
- pre.innerText += "No exception thrown (fail).\n";
-}
-catch (exception) {
- pre.innerText += exception + "\n";
-}
-
-pre.innerText += "Set cssText: ";
-try {
- preStyle.cssText = "yay: !important;";
- pre.innerText += "No exception thrown (fail).\n";
-}
-catch (exception) {
- pre.innerText += exception + "\n";
-}
-
-pre.innerText += "Read deleted variable: " + preStyle.var.get("inline") + "\n";
+description('This tests Javascript access to CSS variables via getComputedStyle.');
+
+var computedStyle = getComputedStyle(document.querySelector("#test-target"));
+var computedBodyStyle = getComputedStyle(document.querySelector("body"));
+
+shouldBeEqualToString('computedStyle.var.toString()', '[object CSSVariablesMap]');
+shouldBe('computedStyle.var === computedStyle.var', 'true');
+shouldThrow('computedStyle.var.set("create", "test")', '"NoModificationAllowedError: Failed to set the \'create\' property on a computed \'CSSStyleDeclaration\': computed styles are read-only."');
+shouldBe('computedStyle.var.size', '3');
+shouldBe('computedBodyStyle.var.size', '0');
+shouldBeEqualToString('computedStyle.var.get("stylesheet")', 'pass');
+shouldBeEqualToString('computedStyle.var.get("inherited")', 'pass');
+shouldBeEqualToString('computedStyle.var.get("inline")', 'pass');
+shouldBeEqualToString('computedBodyStyle.var.get("non-existent")', '');
+
+var forEachIterations = [];
+computedStyle.var.forEach(function(value, name, map) {
+ forEachIterations.push([value, name, map.toString()]);
+});
+forEachIterations.sort();
+shouldBe('forEachIterations[0]', '["pass", "inherited", "[object CSSVariablesMap]"]');
+shouldBe('forEachIterations[1]', '["pass", "inline", "[object CSSVariablesMap]"]');
+shouldBe('forEachIterations[2]', '["pass", "stylesheet", "[object CSSVariablesMap]"]');
+shouldBe('forEachIterations.length', '3');
+
+var emptyVarForEachIterations = [];
+computedBodyStyle.var.forEach(function(value, name, map) {
+ emptyVarForEachIterations.push([value, name, map.toString()]);
+});
+shouldBe('emptyVarForEachIterations.length', '0');
+
+shouldThrow('computedStyle.var.set("inline", "fail")', '"NoModificationAllowedError: Failed to set the \'inline\' property on a computed \'CSSStyleDeclaration\': computed styles are read-only."');
+shouldThrow('computedStyle.var.clear()', '"NoModificationAllowedError: Failed to clear variables from a computed \'CSSStyleDeclaration\': computed styles are read-only."');
+shouldBe('computedStyle.var.delete("inline")', 'false');
+shouldBeEqualToString('computedStyle.var.get("inline")', 'pass');
</script>
+<script src="../../js/resources/js-test-post.js"></script>
« no previous file with comments | « no previous file | LayoutTests/fast/css/variables/cssom-computed-style-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698