1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
4 <link href="resources/grid.css" rel="stylesheet">
8 grid-auto-columns: 50px;
12 grid-auto-rows: minmax(10%, 15px);
13 grid-auto-columns: minmax(30%, 100px);
16 .gridAutoMinMaxContent {
17 grid-auto-rows: min-content;
18 grid-auto-columns: max-content;
21 .gridAutoFixedFixedWithFixedFixed {
23 grid-auto-columns: 40px;
24 grid-template-rows: 15px;
25 grid-template-columns: 20px;
29 <script src="../../resources/js-test.js"></script>
30 <script src="resources/grid-definitions-parsing-utils.js"></script>
33 <div class="grid gridAutoFixedFixed" id="gridAutoFixedFixed"></div>
34 <div class="grid gridAutoMinMax" id="gridAutoMinMax"></div>
35 <div class="grid gridAutoMinMaxContent" id="gridAutoMinMaxContent"></div>
36 <div class="grid gridAutoFixedFixed" id="gridAutoFixedFixedWithChildren">
37 <div class="sizedToGridArea firstRowFirstColumn"></div>
39 <div class="grid gridAutoFixedFixedWithFixedFixed" id="gridAutoFixedFixedWithFixedFixedWithChildren">
40 <div class="sizedToGridArea thirdRowAutoColumn"></div>
41 <div class="sizedToGridArea autoRowThirdColumn"></div>
44 description('Test that setting and getting grid-auto-columns and grid-auto-rows works as expected');
46 debug("Test getting grid-auto-columns and grid-auto-rows set through CSS");
47 testGridAutoDefinitionsValues(document.getElementById("gridAutoFixedFixed"), "30px", "50px");
48 testGridAutoDefinitionsValues(document.getElementById("gridAutoMinMax"), "minmax(10%, 15px)", "minmax(30%, 100px)");
49 testGridAutoDefinitionsValues(document.getElementById("gridAutoMinMaxContent"), "min-content", "max-content");
52 debug("Test that getting grid-template-columns and grid-template-rows set through CSS lists every track listed whether implicitly or explicitly created");
53 testGridAutoDefinitionsValues(document.getElementById("gridAutoFixedFixedWithChildren"), "30px", "50px");
54 testGridDefinitionsValues(document.getElementById("gridAutoFixedFixedWithChildren"), "50px", "30px");
55 testGridAutoDefinitionsValues(document.getElementById("gridAutoFixedFixedWithFixedFixedWithChildren"), "30px", "40px");
56 testGridDefinitionsValues(document.getElementById("gridAutoFixedFixedWithFixedFixedWithChildren"), "20px", "15px", "20px 40px 40px", "15px 30px 30px");
59 debug("Test that grid-template-* definitions are not affected by grid-auto-* definitions");
60 testGridDefinitionsValues(document.getElementById("gridAutoFixedFixed"), "none", "none");
61 testGridDefinitionsValues(document.getElementById("gridAutoMinMax"), "none", "none");
62 testGridDefinitionsValues(document.getElementById("gridAutoMinMaxContent"), "none", "none");
65 debug("Test the initial value");
66 var element = document.createElement("div");
67 document.body.appendChild(element);
68 shouldBe("getComputedStyle(element, '').getPropertyValue('grid-auto-columns')", "'auto'");
69 shouldBe("getComputedStyle(element, '').getPropertyValue('grid-auto-rows')", "'auto'");
72 debug("Test getting and setting grid-auto-columns and grid-auto-rows through JS");
73 element.style.font = "10px Ahem";
74 element.style.gridAutoColumns = "18em";
75 element.style.gridAutoRows = "66em";
76 shouldBe("getComputedStyle(element, '').getPropertyValue('grid-auto-columns')", "'180px'");
77 shouldBe("getComputedStyle(element, '').getPropertyValue('grid-auto-rows')", "'660px'");
79 element = document.createElement("div");
80 document.body.appendChild(element);
81 element.style.gridAutoColumns = "minmax(min-content, 8vh)";
82 element.style.gridAutoRows = "minmax(10vw, min-content)";
83 shouldBe("getComputedStyle(element, '').getPropertyValue('grid-auto-columns')", "'minmax(min-content, 48px)'");
84 shouldBe("getComputedStyle(element, '').getPropertyValue('grid-auto-rows')", "'minmax(80px, min-content)'");
86 element = document.createElement("div");
87 document.body.appendChild(element);
88 element.style.gridAutoColumns = "minmax(min-content, max-content)";
89 element.style.gridAutoRows = "minmax(max-content, min-content)";
90 shouldBe("getComputedStyle(element, '').getPropertyValue('grid-auto-columns')", "'minmax(min-content, max-content)'");
91 shouldBe("getComputedStyle(element, '').getPropertyValue('grid-auto-rows')", "'minmax(max-content, min-content)'");
94 debug("Test setting grid-auto-columns and grid-auto-rows to bad minmax value through JS");
95 element = document.createElement("div");
96 document.body.appendChild(element);
98 element.style.gridAutoColumns = "minmax(10px 20px)";
99 // Only 1 argument provided.
100 element.style.gridAutoRows = "minmax(10px)";
101 shouldBe("getComputedStyle(element, '').getPropertyValue('grid-auto-columns')", "'auto'");
102 shouldBe("getComputedStyle(element, '').getPropertyValue('grid-auto-rows')", "'auto'");
104 element = document.createElement("div");
105 document.body.appendChild(element);
107 element.style.gridAutoColumns = "minmax(minmax(10px, 20px), 20px)";
108 // Only 2 arguments are allowed.
109 element.style.gridAutoRows = "minmax(10px, 20px, 30px)";
110 shouldBe("getComputedStyle(element, '').getPropertyValue('grid-auto-columns')", "'auto'");
111 shouldBe("getComputedStyle(element, '').getPropertyValue('grid-auto-rows')", "'auto'");
113 element = document.createElement("div");
114 document.body.appendChild(element);
116 element.style.gridAutoColumns = "minmax()";
118 element.style.gridAutoRows = "minmax(30px 30% 30em)";
119 shouldBe("getComputedStyle(element, '').getPropertyValue('grid-auto-columns')", "'auto'");
120 shouldBe("getComputedStyle(element, '').getPropertyValue('grid-auto-rows')", "'auto'");
122 element = document.createElement("div");
123 document.body.appendChild(element);
124 // Auto is not allowed inside minmax.
125 element.style.gridAutoColumns = "minmax(auto, 8vh)";
126 element.style.gridAutoRows = "minmax(10vw, auto)";
127 shouldBe("getComputedStyle(element, '').getPropertyValue('grid-auto-columns')", "'auto'");
128 shouldBe("getComputedStyle(element, '').getPropertyValue('grid-auto-rows')", "'auto'");
130 element = document.createElement("div");
131 document.body.appendChild(element);
132 // None is not allowed for grid-auto-{rows|columns}.
133 element.style.gridAutoColumns = "none";
134 element.style.gridAutoRows = "none";
135 shouldBe("getComputedStyle(element, '').getPropertyValue('grid-auto-columns')", "'auto'");
136 shouldBe("getComputedStyle(element, '').getPropertyValue('grid-auto-rows')", "'auto'");
138 function testInherit()
140 var parentElement = document.createElement("div");
141 document.body.appendChild(parentElement);
142 parentElement.style.gridAutoColumns = "50px";
143 parentElement.style.gridAutoRows = "101%";
145 element = document.createElement("div");
146 parentElement.appendChild(element);
147 element.style.gridAutoColumns = "inherit";
148 element.style.gridAutoRows = "inherit";
149 shouldBe("getComputedStyle(element, '').getPropertyValue('grid-auto-columns')", "'50px'");
150 shouldBe("getComputedStyle(element, '').getPropertyValue('grid-auto-rows')", "'101%'");
152 document.body.removeChild(parentElement);
155 debug("Test setting grid-auto-columns and grid-auto-rows to 'inherit' through JS");
158 function testInitial()
160 element = document.createElement("div");
161 document.body.appendChild(element);
162 element.style.gridAutoColumns = "150%";
163 element.style.gridAutoRows = "1fr";
164 shouldBe("getComputedStyle(element, '').getPropertyValue('grid-auto-columns')", "'150%'");
165 shouldBe("getComputedStyle(element, '').getPropertyValue('grid-auto-rows')", "'1fr'");
167 element.style.gridAutoColumns = "initial";
168 element.style.gridAutoRows = "initial";
169 shouldBe("getComputedStyle(element, '').getPropertyValue('grid-auto-columns')", "'auto'");
170 shouldBe("getComputedStyle(element, '').getPropertyValue('grid-auto-rows')", "'auto'");
172 document.body.removeChild(element);
175 debug("Test setting grid-auto-columns and grid-auto-rows to 'initial' through JS");