| <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
| <html> |
| <head> |
| <link href="resources/grid.css" rel="stylesheet"> |
| <style> |
| .gridAutoFixedFixed { |
| grid-auto-rows: 30px; |
| grid-auto-columns: 50px; |
| } |
| |
| .gridAutoMinMax { |
| grid-auto-rows: minmax(10%, 15px); |
| grid-auto-columns: minmax(30%, 100px); |
| } |
| |
| .gridAutoMinMaxContent { |
| grid-auto-rows: min-content; |
| grid-auto-columns: max-content; |
| } |
| |
| .gridAutoFixedFixedWithFixedFixed { |
| grid-auto-rows: 30px; |
| grid-auto-columns: 40px; |
| grid-template-rows: 15px; |
| grid-template-columns: 20px; |
| } |
| |
| .gridAutoAutoInMinMax { |
| grid-auto-rows: minmax(auto, 8vh); |
| grid-auto-columns: minmax(10vw, auto); |
| } |
| |
| </style> |
| <script src="../../resources/js-test.js"></script> |
| <script src="resources/grid-definitions-parsing-utils.js"></script> |
| </head> |
| <body> |
| <div class="grid gridAutoFixedFixed" id="gridAutoFixedFixed"></div> |
| <div class="grid gridAutoMinMax" id="gridAutoMinMax"></div> |
| <div class="grid gridAutoMinMaxContent" id="gridAutoMinMaxContent"></div> |
| <div class="grid gridAutoAutoInMinMax" id="gridAutoAutoInMinMax"></div> |
| <div class="grid gridAutoFixedFixed" id="gridAutoFixedFixedWithChildren"> |
| <div class="sizedToGridArea firstRowFirstColumn"></div> |
| </div> |
| <div class="grid gridAutoFixedFixedWithFixedFixed" id="gridAutoFixedFixedWithFixedFixedWithChildren"> |
| <div class="sizedToGridArea thirdRowAutoColumn"></div> |
| <div class="sizedToGridArea autoRowThirdColumn"></div> |
| </div> |
| <script> |
| description('Test that setting and getting grid-auto-columns and grid-auto-rows works as expected'); |
| |
| debug("Test getting grid-auto-columns and grid-auto-rows set through CSS"); |
| testGridAutoDefinitionsValues(document.getElementById("gridAutoFixedFixed"), "30px", "50px"); |
| testGridAutoDefinitionsValues(document.getElementById("gridAutoMinMax"), "minmax(10%, 15px)", "minmax(30%, 100px)"); |
| testGridAutoDefinitionsValues(document.getElementById("gridAutoMinMaxContent"), "min-content", "max-content"); |
| testGridAutoDefinitionsValues(document.getElementById("gridAutoAutoInMinMax"), "minmax(auto, 48px)", "minmax(80px, auto)"); |
| |
| debug(""); |
| debug("Test that getting grid-template-columns and grid-template-rows set through CSS lists every track listed whether implicitly or explicitly created"); |
| testGridAutoDefinitionsValues(document.getElementById("gridAutoFixedFixedWithChildren"), "30px", "50px"); |
| testGridDefinitionsValues(document.getElementById("gridAutoFixedFixedWithChildren"), "50px", "30px"); |
| testGridAutoDefinitionsValues(document.getElementById("gridAutoFixedFixedWithFixedFixedWithChildren"), "30px", "40px"); |
| testGridDefinitionsValues(document.getElementById("gridAutoFixedFixedWithFixedFixedWithChildren"), "20px 40px 40px", "15px 30px 30px"); |
| |
| debug(""); |
| debug("Test that grid-template-* definitions are not affected by grid-auto-* definitions"); |
| testGridDefinitionsValues(document.getElementById("gridAutoFixedFixed"), "none", "none"); |
| testGridDefinitionsValues(document.getElementById("gridAutoMinMax"), "none", "none"); |
| testGridDefinitionsValues(document.getElementById("gridAutoMinMaxContent"), "none", "none"); |
| |
| debug(""); |
| debug("Test the initial value"); |
| var element = document.createElement("div"); |
| document.body.appendChild(element); |
| shouldBe("getComputedStyle(element, '').getPropertyValue('grid-auto-columns')", "'auto'"); |
| shouldBe("getComputedStyle(element, '').getPropertyValue('grid-auto-rows')", "'auto'"); |
| |
| debug(""); |
| debug("Test getting and setting grid-auto-columns and grid-auto-rows through JS"); |
| element.style.font = "10px Ahem"; |
| element.style.gridAutoColumns = "18em"; |
| element.style.gridAutoRows = "66em"; |
| shouldBe("getComputedStyle(element, '').getPropertyValue('grid-auto-columns')", "'180px'"); |
| shouldBe("getComputedStyle(element, '').getPropertyValue('grid-auto-rows')", "'660px'"); |
| |
| element = document.createElement("div"); |
| document.body.appendChild(element); |
| element.style.gridAutoColumns = "minmax(min-content, 8vh)"; |
| element.style.gridAutoRows = "minmax(10vw, min-content)"; |
| shouldBe("getComputedStyle(element, '').getPropertyValue('grid-auto-columns')", "'minmax(min-content, 48px)'"); |
| shouldBe("getComputedStyle(element, '').getPropertyValue('grid-auto-rows')", "'minmax(80px, min-content)'"); |
| |
| element = document.createElement("div"); |
| document.body.appendChild(element); |
| element.style.gridAutoColumns = "minmax(min-content, max-content)"; |
| element.style.gridAutoRows = "minmax(max-content, min-content)"; |
| shouldBe("getComputedStyle(element, '').getPropertyValue('grid-auto-columns')", "'minmax(min-content, max-content)'"); |
| shouldBe("getComputedStyle(element, '').getPropertyValue('grid-auto-rows')", "'minmax(max-content, min-content)'"); |
| |
| debug(""); |
| debug("Test setting grid-auto-columns and grid-auto-rows to bad minmax value through JS"); |
| element = document.createElement("div"); |
| document.body.appendChild(element); |
| // No comma. |
| element.style.gridAutoColumns = "minmax(10px 20px)"; |
| // Only 1 argument provided. |
| element.style.gridAutoRows = "minmax(10px)"; |
| shouldBe("getComputedStyle(element, '').getPropertyValue('grid-auto-columns')", "'auto'"); |
| shouldBe("getComputedStyle(element, '').getPropertyValue('grid-auto-rows')", "'auto'"); |
| |
| element = document.createElement("div"); |
| document.body.appendChild(element); |
| // Nested minmax. |
| element.style.gridAutoColumns = "minmax(minmax(10px, 20px), 20px)"; |
| // Only 2 arguments are allowed. |
| element.style.gridAutoRows = "minmax(10px, 20px, 30px)"; |
| shouldBe("getComputedStyle(element, '').getPropertyValue('grid-auto-columns')", "'auto'"); |
| shouldBe("getComputedStyle(element, '').getPropertyValue('grid-auto-rows')", "'auto'"); |
| |
| element = document.createElement("div"); |
| document.body.appendChild(element); |
| // No breadth value. |
| element.style.gridAutoColumns = "minmax()"; |
| // No comma. |
| element.style.gridAutoRows = "minmax(30px 30% 30em)"; |
| shouldBe("getComputedStyle(element, '').getPropertyValue('grid-auto-columns')", "'auto'"); |
| shouldBe("getComputedStyle(element, '').getPropertyValue('grid-auto-rows')", "'auto'"); |
| |
| element = document.createElement("div"); |
| document.body.appendChild(element); |
| // None is not allowed for grid-auto-{rows|columns}. |
| element.style.gridAutoColumns = "none"; |
| element.style.gridAutoRows = "none"; |
| shouldBe("getComputedStyle(element, '').getPropertyValue('grid-auto-columns')", "'auto'"); |
| shouldBe("getComputedStyle(element, '').getPropertyValue('grid-auto-rows')", "'auto'"); |
| |
| function testInherit() |
| { |
| var parentElement = document.createElement("div"); |
| document.body.appendChild(parentElement); |
| parentElement.style.gridAutoColumns = "50px"; |
| parentElement.style.gridAutoRows = "101%"; |
| |
| element = document.createElement("div"); |
| parentElement.appendChild(element); |
| element.style.gridAutoColumns = "inherit"; |
| element.style.gridAutoRows = "inherit"; |
| shouldBe("getComputedStyle(element, '').getPropertyValue('grid-auto-columns')", "'50px'"); |
| shouldBe("getComputedStyle(element, '').getPropertyValue('grid-auto-rows')", "'101%'"); |
| |
| document.body.removeChild(parentElement); |
| } |
| debug(""); |
| debug("Test setting grid-auto-columns and grid-auto-rows to 'inherit' through JS"); |
| testInherit(); |
| |
| function testInitial() |
| { |
| element = document.createElement("div"); |
| document.body.appendChild(element); |
| element.style.gridAutoColumns = "150%"; |
| element.style.gridAutoRows = "1fr"; |
| shouldBe("getComputedStyle(element, '').getPropertyValue('grid-auto-columns')", "'150%'"); |
| shouldBe("getComputedStyle(element, '').getPropertyValue('grid-auto-rows')", "'1fr'"); |
| |
| element.style.gridAutoColumns = "initial"; |
| element.style.gridAutoRows = "initial"; |
| shouldBe("getComputedStyle(element, '').getPropertyValue('grid-auto-columns')", "'auto'"); |
| shouldBe("getComputedStyle(element, '').getPropertyValue('grid-auto-rows')", "'auto'"); |
| |
| document.body.removeChild(element); |
| } |
| debug(""); |
| debug("Test setting grid-auto-columns and grid-auto-rows to 'initial' through JS"); |
| testInitial(); |
| </script> |
| </body> |
| </html> |