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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script>
if (window.testRunner)
testRunner.overridePreference("WebKitCSSGridLayoutEnabled", 1);
</script>
<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;
}
</style>
<script src="../js/resources/js-test-pre.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>
<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");
var gridAutoFixedFixed = document.getElementById("gridAutoFixedFixed");
shouldBe("getComputedStyle(gridAutoFixedFixed, '').getPropertyValue('grid-auto-rows')", "'30px'");
shouldBe("getComputedStyle(gridAutoFixedFixed, '').getPropertyValue('grid-auto-columns')", "'50px'");
var gridAutoMinMax = document.getElementById("gridAutoMinMax");
shouldBe("getComputedStyle(gridAutoMinMax, '').getPropertyValue('grid-auto-rows')", "'minmax(10%, 15px)'");
shouldBe("getComputedStyle(gridAutoMinMax, '').getPropertyValue('grid-auto-columns')", "'minmax(30%, 100px)'");
var gridAutoMinMaxContent = document.getElementById("gridAutoMinMaxContent");
shouldBe("getComputedStyle(gridAutoMinMaxContent, '').getPropertyValue('grid-auto-rows')", "'min-content'");
shouldBe("getComputedStyle(gridAutoMinMaxContent, '').getPropertyValue('grid-auto-columns')", "'max-content'");
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);
// Auto is not allowed inside minmax.
element.style.gridAutoColumns = "minmax(auto, 8vh)";
element.style.gridAutoRows = "minmax(10vw, auto)";
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>
<script src="../js/resources/js-test-post.js"></script>
</body>
</html>
|