summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/css-grid-layout/grid-item-start-before-get-set.html
blob: 56d5176c9e22b03591243e7537723e8826e187dc (plain)
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
<!DOCTYPE html>
<html>
<head>
<link href="resources/grid.css" rel="stylesheet">
<style>
.grid {
    grid-template-areas: "firstArea secondArea"
                         "thirdArea thirdArea";
}

.gridItemWithPositiveInteger {
    grid-column-start: 10;
    grid-row-start: 15;
}
.gridItemWithNegativeInteger {
    grid-column-start: -10;
    grid-row-start: -15;
}
.gridItemWithBeforeSpan {
    grid-column-start: span 2;
    grid-row-start: span 8;
}
.gridItemWithAfterSpan {
    grid-column-start: 2 span;
    grid-row-start: 8 span;
}
.gridItemWithOnlySpan {
    grid-column-start: span;
    grid-row-start: span;
}
.gridItemWithAuto {
    grid-column-start: auto;
    grid-row-start: auto;
}
.gridItemWithString {
    grid-column-start: "first";
    grid-row-start: "last";
}
.gridItemWithSpanString {
    grid-column-start: "first" span;
    grid-row-start: span "last";
}
.gridItemWithSpanNumberString {
    grid-column-start: 2 "first" span;
    grid-row-start: "last" 3 span;
}
.gridItemWithArea {
    grid-column-start: firstArea;
    grid-row-start: thirdArea;
}
</style>
<script src="resources/grid-item-column-row-parsing-utils.js"></script>
<script src="../../resources/js-test.js"></script>
</head>
<body>
<div class="grid">
    <!-- The first has no properties set on it. -->
    <div id="gridElement"></div>
    <div class="gridItemWithPositiveInteger" id="gridItemWithPositiveInteger"></div>
    <div class="gridItemWithNegativeInteger" id="gridItemWithNegativeInteger"></div>
    <div class="gridItemWithBeforeSpan" id="gridItemWithBeforeSpan"></div>
    <div class="gridItemWithAfterSpan" id="gridItemWithAfterSpan"></div>
    <div class="gridItemWithOnlySpan" id="gridItemWithOnlySpan"></div>
    <div class="gridItemWithAuto" id="gridItemWithAutoElement"></div>
    <div class="gridItemWithString" id="gridItemWithStringElement"></div>
    <div class="gridItemWithSpanString" id="gridItemWithSpanStringElement"></div>
    <div class="gridItemWithSpanNumberString" id="gridItemWithSpanNumberStringElement"></div>
    <div class="gridItemWithArea" id="gridItemWithArea"></div>
</div>
<script>
    description('Test that setting and getting grid-column-start and grid-row-start works as expected');

    debug("Test getting grid-column-start and grid-row-start set through CSS");
    var gridElement = document.getElementById("gridElement");
    shouldBe("getComputedStyle(gridElement, '').getPropertyValue('grid-column-start')", "'auto'");
    shouldBe("getComputedStyle(gridElement, '').getPropertyValue('grid-column')", "'auto / auto'");
    shouldBe("getComputedStyle(gridElement, '').getPropertyValue('grid-row-start')", "'auto'");
    shouldBe("getComputedStyle(gridElement, '').getPropertyValue('grid-row')", "'auto / auto'");

    testColumnRowCSSParsing("gridItemWithPositiveInteger", "10 / auto", "15 / auto");
    testColumnRowCSSParsing("gridItemWithNegativeInteger", "-10 / auto", "-15 / auto");
    testColumnRowCSSParsing("gridItemWithBeforeSpan", "span 2 / auto", "span 8 / auto");
    testColumnRowCSSParsing("gridItemWithAfterSpan", "span 2 / auto", "span 8 / auto");
    testColumnRowCSSParsing("gridItemWithOnlySpan", "span 1 / auto", "span 1 / auto");
    testColumnRowCSSParsing("gridItemWithAutoElement", "auto / auto", "auto / auto");
    testColumnRowCSSParsing("gridItemWithStringElement", "1 first / auto", "1 last / auto");
    testColumnRowCSSParsing("gridItemWithSpanStringElement", "span 1 first / auto", "span 1 last / auto");
    testColumnRowCSSParsing("gridItemWithSpanNumberStringElement", "span 2 first / auto", "span 3 last / auto");
    testColumnRowCSSParsing("gridItemWithArea", "firstArea / auto", "thirdArea / auto");

    debug("");
    debug("Test the initial value");
    var element = document.createElement("div");
    document.body.appendChild(element);
    shouldBe("getComputedStyle(element, '').getPropertyValue('grid-column-start')", "'auto'");
    shouldBe("getComputedStyle(element, '').getPropertyValue('grid-column')", "'auto / auto'");
    shouldBe("getComputedStyle(element, '').getPropertyValue('grid-row-start')", "'auto'");
    shouldBe("getComputedStyle(element, '').getPropertyValue('grid-row')", "'auto / auto'");

    debug("");
    debug("Test getting and setting grid-column-start and grid-row-start through JS");
    testColumnStartRowStartJSParsing("18", "66");
    testColumnStartRowStartJSParsing("-55", "-40");
    testColumnStartRowStartJSParsing("'nav'", "'last'", "1 nav", "1 last");
    testColumnStartRowStartJSParsing("span 3", "span 20");
    testColumnStartRowStartJSParsing("span 'nav'", "span 'last'", "span 1 nav", "span 1 last");
    testColumnStartRowStartJSParsing("auto", "auto");
    testColumnStartRowStartJSParsing("thirdArea", "secondArea");
    testColumnStartRowStartJSParsing("nonExistentArea", "secondArea", "auto", "secondArea");
    testColumnStartRowStartJSParsing("secondArea", "nonExistentArea", "secondArea", "auto");

    debug("");
    debug("Test setting grid-column-start and grid-row-start to 'inherit' through JS");
    testColumnStartRowStartInheritJSParsing("inherit", "18");
    testColumnStartRowStartInheritJSParsing("2", "inherit");
    testColumnStartRowStartInheritJSParsing("inherit", "inherit");

    debug("");
    debug("Test setting grid-column-start and grid-row-start to 'initial' through JS");
    testColumnStartRowStartInitialJSParsing();

    debug("");
    debug("Test setting grid-column-start and grid-row-start back to 'auto' through JS");
    element.style.gridColumnStart = "18";
    element.style.gridRowStart = "66";
    shouldBe("getComputedStyle(element, '').getPropertyValue('grid-column-start')", "'18'");
    shouldBe("getComputedStyle(element, '').getPropertyValue('grid-column')", "'18 / auto'");
    shouldBe("getComputedStyle(element, '').getPropertyValue('grid-row-start')", "'66'");
    shouldBe("getComputedStyle(element, '').getPropertyValue('grid-row')", "'66 / auto'");
    element.style.gridColumnStart = "auto";
    element.style.gridRowStart = "auto";
    shouldBe("getComputedStyle(element, '').getPropertyValue('grid-column-start')", "'auto'");
    shouldBe("getComputedStyle(element, '').getPropertyValue('grid-column')", "'auto / auto'");
    shouldBe("getComputedStyle(element, '').getPropertyValue('grid-row-start')", "'auto'");
    shouldBe("getComputedStyle(element, '').getPropertyValue('grid-row')", "'auto / auto'");
</script>
</body>
</html>