/
grid-auto-flow-update.html
48 lines (46 loc) · 1.86 KB
/
grid-auto-flow-update.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<!DOCTYPE html>
<html>
<script>
if (window.testRunner)
testRunner.overridePreference("WebKitCSSGridLayoutEnabled", 1);
</script>
<link href="resources/grid.css" rel="stylesheet">
<script src="../../resources/check-layout.js"></script>
<style>
.grid {
-webkit-grid-template-columns: 50px 100px;
-webkit-grid-template-rows: 50px 100px;
}
</style>
<script>
function testGrid(flow, positionAndSize)
{
var gridElement = document.getElementsByClassName("grid")[0];
gridElement.style.webkitGridAutoFlow = flow;
var gridItem = document.getElementById("autoItem");
gridItem.setAttribute("data-offset-x", positionAndSize.offsetX);
gridItem.setAttribute("data-offset-y", positionAndSize.offsetY);
gridItem.setAttribute("data-expected-width", positionAndSize.width);
gridItem.setAttribute("data-expected-height", positionAndSize.height);
checkLayout(".grid");
}
function updateAutoFlow()
{
checkLayout(".grid");
testGrid("row", { 'offsetX': '50', 'offsetY': '0', 'width': '100', 'height': '50' });
testGrid("column", { 'offsetX': '0', 'offsetY': '50', 'width': '50', 'height': '100' });
testGrid("invalid", { 'offsetX': '0', 'offsetY': '50', 'width': '50', 'height': '100' });
testGrid("none", { 'offsetX': '0', 'offsetY': '0', 'width': '50', 'height': '50' });
}
window.addEventListener("load", updateAutoFlow, false);
</script>
<body>
<div>This test checks that updating the grid's element's grid-auto-flow property recomputes the grid.</div>
<div style="position: relative">
<div class="grid">
<div class="sizedToGridArea autoRowAutoColumn" id="autoItem" data-offset-x="0" data-offset-y="0" data-expected-width="50" data-expected-height="50"></div>
<div class="sizedToGridArea firstRowFirstColumn" data-offset-x="0" data-offset-y="0" data-expected-width="50" data-expected-height="50"></div>
</div>
</div>
</body>
</html>