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

Unified Diff: LayoutTests/fast/css-grid-layout/resources/grid-template-shorthand-parsing-utils.js

Issue 149373004: [CSS Grid Layout] Implementation of the grid-template shorthand. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@grid-template-working
Patch Set: Adding checks and layout tests to verify misplaced 'none' arguments. Created 6 years, 10 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: LayoutTests/fast/css-grid-layout/resources/grid-template-shorthand-parsing-utils.js
diff --git a/LayoutTests/fast/css-grid-layout/resources/grid-template-shorthand-parsing-utils.js b/LayoutTests/fast/css-grid-layout/resources/grid-template-shorthand-parsing-utils.js
new file mode 100644
index 0000000000000000000000000000000000000000..c76e47df21d552b5fa95f664eab812ba375c2e4d
--- /dev/null
+++ b/LayoutTests/fast/css-grid-layout/resources/grid-template-shorthand-parsing-utils.js
@@ -0,0 +1,48 @@
+function testGridDefinitionsValues(element, columnsValue, rowsValue, areasValue, computedColumnsValue, computedRowsValue)
+{
+ window.element = element;
+ var elementID = element.id || "element";
+ shouldBeEqualToString("window.getComputedStyle(" + elementID + ", '').getPropertyValue('grid-template-columns')", computedColumnsValue || columnsValue);
+ shouldBeEqualToString("window.getComputedStyle(" + elementID + ", '').getPropertyValue('grid-template-rows')", computedRowsValue || rowsValue);
+ shouldBeEqualToString("window.getComputedStyle(" + elementID + ", '').getPropertyValue('grid-template-areas')", areasValue);
+}
+
+function testGridDefinitionsSetJSValues(shorthandValue, computedColumnsValue, computedRowsValue, computedAreasValue, jsColumnsValue, jsRowsValue, jsAreasValue)
+{
+ checkGridDefinitionsSetJSValues(true, shorthandValue, computedColumnsValue, computedRowsValue, computedAreasValue, jsColumnsValue, jsRowsValue, jsAreasValue);
+}
+
+function testNonGridDefinitionsSetJSValues(shorthandValue, computedColumnsValue, computedRowsValue, computedAreasValue, jsColumnsValue, jsRowsValue, jsAreasValue)
+{
+ checkGridDefinitionsSetJSValues(false, shorthandValue, computedColumnsValue, computedRowsValue, computedAreasValue, jsColumnsValue, jsRowsValue, jsAreasValue);
+}
+
+function checkGridDefinitionsSetJSValues(useGrid, shorthandValue, computedColumnsValue, computedRowsValue, computedAreasValue, jsColumnsValue, jsRowsValue, jsAreasValue)
+{
+ window.element = document.createElement("div");
+ document.body.appendChild(element);
+ if (useGrid) {
+ element.style.display = "grid";
+ element.style.width = "800px";
+ element.style.height = "600px";
+ }
+ element.style.font = "10px Ahem"; // Used to resolve em font consistently.
+ element.style.gridTemplate = shorthandValue;
+ shouldBeEqualToString("getComputedStyle(element, '').getPropertyValue('grid-template-columns')", computedColumnsValue);
+ shouldBeEqualToString("element.style.gridTemplateColumns", jsColumnsValue || computedColumnsValue);
+ shouldBeEqualToString("getComputedStyle(element, '').getPropertyValue('grid-template-rows')", computedRowsValue);
+ shouldBeEqualToString("element.style.gridTemplateRows", jsRowsValue || computedRowsValue);
+ shouldBeEqualToString("getComputedStyle(element, '').getPropertyValue('grid-template-areas')", computedAreasValue);
+ shouldBeEqualToString("element.style.gridTemplateAreas", jsAreasValue || computedAreasValue);
+ document.body.removeChild(element);
+}
+
+function testGridDefinitionsSetBadJSValues(shorthandValue)
+{
+ window.element = document.createElement("div");
+ document.body.appendChild(element);
+ element.style.gridTemplate = shorthandValue;
+ // We can't use testSetJSValues as element.style.gridTemplateRows returns "".
+ testGridDefinitionsValues(element, "none", "none", "none");
+ document.body.removeChild(element);
+}

Powered by Google App Engine
This is Rietveld 408576698