5 testRunner.overridePreference("WebKitCSSGridLayoutEnabled", 1);
7 <link href="resources/grid.css" rel="stylesheet">
8 <script src="../../resources/check-layout.js"></script>
29 function testGridDefinitions(gridDefinitionRows, gridDefinitionColumns, firstGridItemData, secondGridItemData, thirdGridItemData)
31 var gridElement = document.getElementsByClassName("grid")[0];
32 gridElement.style.gridDefinitionRows = gridDefinitionRows;
33 gridElement.style.gridDefinitionColumns = gridDefinitionColumns;
35 var firstGridItem = document.getElementById("firstGridItem");
36 firstGridItem.setAttribute("data-expected-width", firstGridItemData.width);
37 firstGridItem.setAttribute("data-expected-height", firstGridItemData.height);
38 firstGridItem.setAttribute("data-offset-x", firstGridItemData.x);
39 firstGridItem.setAttribute("data-offset-y", firstGridItemData.y);
41 var secondGridItem = document.getElementById("secondGridItem");
42 secondGridItem.setAttribute("data-expected-width", secondGridItemData.width);
43 secondGridItem.setAttribute("data-expected-height", secondGridItemData.height);
44 secondGridItem.setAttribute("data-offset-x", secondGridItemData.x);
45 secondGridItem.setAttribute("data-offset-y", secondGridItemData.y);
47 var thirdGridItem = document.getElementById("thirdGridItem");
48 thirdGridItem.setAttribute("data-expected-width", thirdGridItemData.width);
49 thirdGridItem.setAttribute("data-expected-height", thirdGridItemData.height);
50 thirdGridItem.setAttribute("data-offset-x", thirdGridItemData.x);
51 thirdGridItem.setAttribute("data-offset-y", thirdGridItemData.y);
56 function testChangingGridDefinitions()
58 testGridDefinitions('10px 20px', '10px', { 'width': '10', 'height': '20', 'x': '0', 'y': '10' }, { 'width': '10', 'height': '10', 'x': '0', 'y': '0' }, { 'width': '10', 'height': '0', 'x': '0', 'y': '30' });
59 testGridDefinitions('50px', '30px 40px', { 'width': '30', 'height': '0', 'x': '0', 'y': '50' }, { 'width': '30', 'height': '50', 'x': '0', 'y': '0' }, { 'width': '40', 'height': '50', 'x': '30', 'y': '0' });
60 testGridDefinitions('50px', '60px', { 'width': '60', 'height': '0', 'x': '0', 'y': '50' }, { 'width': '60', 'height': '50', 'x': '0', 'y': '0' }, { 'width': '60', 'height': '0', 'x': '0', 'y': '50' });
61 testGridDefinitions('50px 100px 150px', '60px', { 'width': '60', 'height': '100', 'x': '0', 'y': '50' }, { 'width': '60', 'height': '50', 'x': '0', 'y': '0' }, { 'width': '60', 'height': '150', 'x': '0', 'y': '150' });
64 window.addEventListener("load", testChangingGridDefinitions, false);
67 <div>This test checks that grid-definition-{rows|columns} dynamic updates recomputes the positions of automatically placed grid items.</div>
69 <div style="position: relative">
71 <div class="sizedToGridArea" id="firstGridItem"></div>
72 <div class="sizedToGridArea" id="secondGridItem"></div>
73 <div class="sizedToGridArea" id="thirdGridItem"></div>