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

Unified Diff: third_party/WebKit/LayoutTests/external/csswg-test/css-align-3/resources/alignment-parsing-utils.js

Issue 2762043004: [css-align] Import the CSS Box Alignment tests from the CSSWG Test Suite (Closed)
Patch Set: Upload suggested changes. Created 3 years, 9 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/external/csswg-test/css-align-3/resources/alignment-parsing-utils.js
diff --git a/third_party/WebKit/LayoutTests/external/csswg-test/css-align-3/resources/alignment-parsing-utils.js b/third_party/WebKit/LayoutTests/external/csswg-test/css-align-3/resources/alignment-parsing-utils.js
new file mode 100644
index 0000000000000000000000000000000000000000..9084624e994fc89282fff96bf48c152b0edf7e03
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/external/csswg-test/css-align-3/resources/alignment-parsing-utils.js
@@ -0,0 +1,54 @@
+var selfPositionValues = [ "start", "end", "self-start", "self-end", "left", "right", "center", "flex-start", "flex-end"];
+var contentPositionValues = [ "start", "end", "left", "right", "center", "flex-start", "flex-end"];
+var distributionValues = [ "stretch", "space-around", "space-between", "space-evenly"];
+var baselineValues = [ "baseline", "first baseline", "last baseline"];
+
+function checkPlaceShorhand(shorthand, alignValue, justifyValue)
+{
+ var div = document.createElement("div");
+ var specifiedValue = (alignValue + " " + justifyValue).trim();
+ div.style[shorthand] = specifiedValue;
+ document.body.appendChild(div);
+
+ if (alignValue === justifyValue)
+ specifiedValue = alignValue;
+
+ var resolvedValue = getComputedStyle(div).getPropertyValue(shorthand);
+ if (alignValue === "first baseline")
+ alignValue = "baseline";
+ if (justifyValue === "first baseline")
+ justifyValue = "baseline";
+ if (justifyValue === "")
+ justifyValue = alignValue;
+ var expectedResolvedValue = (alignValue + " " + justifyValue).trim()
+
+ assert_equals(div.style[shorthand], specifiedValue, shorthand + " specified value");
+ // FIXME: We need https://github.com/w3c/csswg-drafts/issues/1041 to clarify which
+ // value is expected for the shorthand's 'resolved value".
+ assert_in_array(resolvedValue, ["", expectedResolvedValue], shorthand + " resolved value");
+}
+
+function checkPlaceShorhandLonghands(shorthand, alignLonghand, justifyLonghand, alignValue, justifyValue = "")
+{
+ var div = document.createElement("div");
+ div.setAttribute("style", shorthand + ": " + alignValue + " " + justifyValue);
+ document.body.appendChild(div);
+ if (justifyValue === "")
+ justifyValue = alignValue;
+ assert_equals(div.style[alignLonghand],
+ alignValue, alignLonghand + " expanded value");
+ assert_equals(div.style[justifyLonghand],
+ justifyValue, justifyLonghand + " expanded value");
+}
+
+function checkPlaceShorthandInvalidValues(shorthand, alignLonghand, justifyLonghand, value)
+{
+ var div = document.createElement("div");
+ var css = alignLonghand + ": start; " + justifyLonghand + ": end;" + shorthand + ": " + value;
+ div.setAttribute("style", css);
+ document.body.appendChild(div);
+ assert_equals(div.style[alignLonghand],
+ "start", alignLonghand + " expanded value");
+ assert_equals(div.style[justifyLonghand],
+ "end", justifyLonghand + " expanded value");
+}

Powered by Google App Engine
This is Rietveld 408576698