4 <link href=
"resources/grid.css" rel=
"stylesheet">
7 grid-template-areas:
"firstArea secondArea"
11 .gridItemWithPositiveInteger {
15 .gridItemWithNegativeInteger {
19 .gridItemWithBeforeSpan {
20 grid-column-end: span
2;
23 .gridItemWithAfterSpan {
24 grid-column-end:
2 span;
27 .gridItemWithOnlySpan {
28 grid-column-end: span;
32 grid-column-end: auto;
35 .gridItemWithCustomIdent {
36 grid-column-end: first;
39 .gridItemWithNumberCustomIdent {
40 grid-column-end: first
2;
43 .gridItemWithSpanCustomIdent {
44 grid-column-end: first span;
45 grid-row-end: span last;
47 .gridItemWithSpanNumberCustomIdent {
48 grid-column-end:
2 first span;
49 grid-row-end: last
3 span;
52 grid-column-end: firstArea;
53 grid-row-end: thirdArea;
56 <script src=
"resources/grid-item-column-row-parsing-utils.js"></script>
57 <script src=
"../../resources/js-test.js"></script>
61 <!-- The first has no properties set on it. -->
62 <div id=
"gridElement"></div>
63 <div class=
"gridItemWithPositiveInteger" id=
"gridItemWithPositiveInteger"></div>
64 <div class=
"gridItemWithNegativeInteger" id=
"gridItemWithNegativeInteger"></div>
65 <div class=
"gridItemWithBeforeSpan" id=
"gridItemWithBeforeSpan"></div>
66 <div class=
"gridItemWithAfterSpan" id=
"gridItemWithAfterSpan"></div>
67 <div class=
"gridItemWithOnlySpan" id=
"gridItemWithOnlySpan"></div>
68 <div class=
"gridItemWithAuto" id=
"gridItemWithAutoElement"></div>
69 <div class=
"gridItemWithCustomIdent" id=
"gridItemWithCustomIdent"></div>
70 <div class=
"gridItemWithNumberCustomIdent" id=
"gridItemWithNumberCustomIdent"></div>
71 <div class=
"gridItemWithSpanCustomIdent" id=
"gridItemWithSpanCustomIdentElement"></div>
72 <div class=
"gridItemWithSpanNumberCustomIdent" id=
"gridItemWithSpanNumberCustomIdentElement"></div>
73 <div class=
"gridItemWithArea" id=
"gridItemWithArea"></div>
76 description('Test that setting and getting grid-column-end and grid-row-end works as expected');
78 debug("Test getting grid-column-end and grid-row-end set through CSS");
79 testColumnRowCSSParsing("gridElement", "auto / auto", "auto / auto");
80 testColumnRowCSSParsing("gridItemWithPositiveInteger", "auto / 10", "auto / 15");
81 testColumnRowCSSParsing("gridItemWithNegativeInteger", "auto / -10", "auto / -15");
82 testColumnRowCSSParsing("gridItemWithBeforeSpan", "auto / span 2", "auto / span 9");
83 testColumnRowCSSParsing("gridItemWithAfterSpan", "auto / span 2", "auto / span 9");
84 testColumnRowCSSParsing("gridItemWithOnlySpan", "auto / span 1", "auto / span 1");
85 testColumnRowCSSParsing("gridItemWithAutoElement", "auto / auto", "auto / auto");
86 testColumnRowCSSParsing("gridItemWithCustomIdent", "auto / first", "auto / last");
87 testColumnRowCSSParsing("gridItemWithNumberCustomIdent", "auto / 2 first", "auto / 3 last");
88 testColumnRowCSSParsing("gridItemWithSpanCustomIdentElement", "auto / span 1 first", "auto / span 1 last");
89 testColumnRowCSSParsing("gridItemWithSpanNumberCustomIdentElement", "auto / span 2 first", "auto / span 3 last");
90 testColumnRowCSSParsing("gridItemWithArea", "auto / firstArea", "auto / thirdArea");
93 debug("Test the initial value");
94 var element
= document
.createElement("div");
95 document
.body
.appendChild(element
);
96 shouldBe("getComputedStyle(element, '').getPropertyValue('grid-column-end')", "'auto'");
97 shouldBe("getComputedStyle(element, '').getPropertyValue('grid-column')", "'auto / auto'");
98 shouldBe("getComputedStyle(element, '').getPropertyValue('grid-row-end')", "'auto'");
99 shouldBe("getComputedStyle(element, '').getPropertyValue('grid-row')", "'auto / auto'");
102 debug("Test getting and setting grid-column-end and grid-row-end through JS");
103 testColumnEndRowEndJSParsing("18", "66");
104 testColumnEndRowEndJSParsing("-55", "-40");
105 testColumnEndRowEndJSParsing("first", "last", "first", "last");
106 testColumnEndRowEndJSParsing("span 7", "span 2");
107 testColumnEndRowEndJSParsing("span first", "span last", "span 1 first", "span 1 last");
108 testColumnEndRowEndJSParsing("auto", "auto");
109 testColumnEndRowEndJSParsing("thirdArea", "secondArea");
110 testColumnEndRowEndJSParsing("nonExistentArea", "secondArea");
111 testColumnEndRowEndJSParsing("secondArea", "nonExistentArea");
114 debug("Test setting grid-column-start and grid-row-start to 'inherit' through JS");
115 testColumnEndRowEndInheritJSParsing("inherit", "18");
116 testColumnEndRowEndInheritJSParsing("2", "inherit");
117 testColumnEndRowEndInheritJSParsing("inherit", "inherit");
120 debug("Test setting grid-column-start and grid-row-start to 'initial' through JS");
121 testEndAfterInitialJSParsing();
124 debug("Test setting grid-column-end and grid-row-end back to 'auto' through JS");
125 element
.style
.gridColumnEnd
= "18";
126 element
.style
.gridRowEnd
= "66";
127 shouldBe("getComputedStyle(element, '').getPropertyValue('grid-column-end')", "'18'");
128 shouldBe("getComputedStyle(element, '').getPropertyValue('grid-column')", "'auto / 18'");
129 shouldBe("getComputedStyle(element, '').getPropertyValue('grid-row-end')", "'66'");
130 shouldBe("getComputedStyle(element, '').getPropertyValue('grid-row')", "'auto / 66'");
131 element
.style
.gridColumnEnd
= "auto";
132 element
.style
.gridRowEnd
= "auto";
133 shouldBe("getComputedStyle(element, '').getPropertyValue('grid-column-end')", "'auto'");
134 shouldBe("getComputedStyle(element, '').getPropertyValue('grid-column')", "'auto / auto'");
135 shouldBe("getComputedStyle(element, '').getPropertyValue('grid-row-end')", "'auto'");
136 shouldBe("getComputedStyle(element, '').getPropertyValue('grid-row')", "'auto / auto'");