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

Unified Diff: third_party/WebKit/LayoutTests/typedcssom/inlinestyle/tokenStreamValue.html

Issue 2251663002: [Typed-OM] Get CSSTokenStreamValue from StyleMap (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unused header Created 4 years, 4 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: third_party/WebKit/LayoutTests/typedcssom/inlinestyle/tokenStreamValue.html
diff --git a/third_party/WebKit/LayoutTests/typedcssom/inlinestyle/tokenStreamValue.html b/third_party/WebKit/LayoutTests/typedcssom/inlinestyle/tokenStreamValue.html
new file mode 100644
index 0000000000000000000000000000000000000000..213aa869ebe330b554677530d0666e10446fe95b
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/typedcssom/inlinestyle/tokenStreamValue.html
@@ -0,0 +1,72 @@
+<!DOCTYPE html>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+
+<div id="testElement"></div>
+
+<script>
+
+test(function() {
+ testElement.style.width = "calc(42px + var(--foo, 15em) + var(--bar, var(--test) + 15px))";
+ var result = [...testElement.styleMap.get('width')];
+ assert_equals(result.length, 5);
+ assert_equals(result[0], "calc(42px + ");
+ assert_equals(result[1].variable, "--foo");
+ assert_equals([...result[1].fallback].length, 1);
+ assert_equals([...result[1].fallback][0], " 15em");
+ assert_equals(result[2], " + ");
+ assert_equals(result[3].variable, "--bar");
+ var barFallback = [...result[3].fallback];
+ assert_equals(barFallback.length, 3);
+ assert_equals(barFallback[0], " ");
+ assert_equals(barFallback[1].variable, "--test");
+ assert_equals(barFallback[1].fallback, null);
+ assert_equals(barFallback[2], " + 15px");
+ assert_equals(result[4], ")");
+}, "Construction of CSSTokenStreamValue is normalized using example from the spec");
+
+test(function() {
+ testElement.style.width = "var(--a, 10px, 20px, 30em)";
+ var result = [...testElement.styleMap.get('width')];
+ assert_equals(result.length, 1);
+ assert_equals(result[0].variable, "--a");
+ assert_equals([...result[0].fallback].length, 1);
+ assert_equals([...result[0].fallback][0], " 10px, 20px, 30em");
+}, "Has several values");
+
+test(function() {
+ testElement.style.width = " var( --a , 5px ) ";
+ var result = [...testElement.styleMap.get('width')];
+ assert_equals(result.length, 2);
+ assert_equals(result[0].variable, "--a");
+ assert_equals([...result[0].fallback].length, 1);
+ assert_equals([...result[0].fallback][0], " 5px ");
+ assert_equals(result[1], " ");
+
+ testElement.style.width = " calc( var( --test, 30px ) + 15px )";
+ result = [...testElement.styleMap.get('width')];
+ assert_equals(result.length, 3);
+ assert_equals(result[0], "calc( ");
+ assert_equals(result[1].variable, "--test");
+ assert_equals([...result[1].fallback].length, 1);
+ assert_equals([...result[1].fallback][0], " 30px ");
+ assert_equals(result[2], " + 15px )");
+}, "Can handle extra spaces with fallback");
+
+test(function() {
+ testElement.style.width = " var( --a ) ";
+ var result = [...testElement.styleMap.get('width')];
+ assert_equals(result.length, 2);
+ assert_equals(result[0].variable, "--a");
+ assert_equals(result[0].fallback, null);
+ assert_equals(result[1], " ");
+
+ testElement.style.width = " calc( var( --test ) + 15px ) ";
+ result = [...testElement.styleMap.get('width')];
+ assert_equals(result.length, 3);
+ assert_equals(result[0], "calc( ");
+ assert_equals(result[1].variable, "--test");
+ assert_equals(result[1].fallback, null);
+ assert_equals(result[2], " + 15px ) ");
+}, "Can handle extra spaces without fallback");
+</script>

Powered by Google App Engine
This is Rietveld 408576698