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

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: Refactor and add test 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..9ecc67a5d354c470d1e0c788f81a01ee4d3e16fe
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/typedcssom/inlinestyle/tokenStreamValue.html
@@ -0,0 +1,50 @@
+<!DOCTYPE html>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+
+<div id="testElement1"></div>
meade_UTC10 2016/08/22 07:55:47 You can use the same element for each test, and ju
anthonyhkf 2016/08/25 03:48:31 Done.
+<div id="testElement2"></div>
+
+<script>
+
+function compareTokenStreamValueWithArray(tokenStreamValue, expectedTokenStreamValue) {
meade_UTC10 2016/08/22 07:55:47 This function is much too complicated to be in a t
+ if (tokenStreamValue == null) {
+ return expectedTokenStreamValue == null;
+ }
+ assert_true(tokenStreamValue instanceof CSSTokenStreamValue);
+ var iterator = tokenStreamValue.values();
+ var correct = true, i;
+ for (i = iterator.next(), j = 0; j < expectedTokenStreamValue.length; i = iterator.next(), ++j) {
+ if (i.done) return false;
+ if (typeof(i.value) == 'string') {
+ if (i.value != expectedTokenStreamValue[j]) {
+ return false;
+ }
+ } else if (i.value instanceof CSSVariableReferenceValue) {
+ if (i.value.variable != expectedTokenStreamValue[j].variable) {
+ return false;
+ }
+ correct = correct && compareTokenStreamValueWithArray(i.value.fallback, expectedTokenStreamValue[j].fallback);
+ } else return false;
+ }
+ return correct && i.done;
+}
+
+test(function() {
+ testElement1.style.width = "calc(42px + var(--foo, 15em) + var(--bar, var(--far) + 15px))";
+ var expectedTokenStreamValue =
+ ["calc(42px + "
+ , { variable: "--foo", fallback: [" 15em"] }
+ , " + "
+ , { variable: "--bar", fallback: [" ", { variable: "--far", fallback: undefined }, " + 15px"] }
+ , ")"];
+ assert_true(compareTokenStreamValueWithArray(testElement1.styleMap.get("width"), expectedTokenStreamValue));
+}, "Can get CSSTokenStreamValue from StyleMap with correct normalization");
+
+test(function() {
+ testElement2.style.width = "var(--a, 10px)";
+ var expectedTokenStreamValue = [{ variable: "--a", fallback: [" 10px"]}];
+ assert_true(compareTokenStreamValueWithArray(testElement2.styleMap.get("width"), expectedTokenStreamValue));
+}, "No empty strings in fragments");
+
+</script>

Powered by Google App Engine
This is Rietveld 408576698