5 <title>Test parsing of grid item shorthands (grid-column, grid-row, grid-area)
</title>
6 <link rel=
"author" title=
"Simon Sapin" href=
"mailto:simon.sapin@exyr.org">
7 <script src=
"/resources/testharness.js"></script>
8 <script src=
"/resources/testharnessreport.js"></script>
9 <link rel='stylesheet' href='/resources/testharness.css'
>
15 // For various specified values of the grid-column and grid-row shorthands,
16 // test the computed values of the corresponding longhands.
17 var grid_column_row_test_cases
= [
24 specified
: "foo / span bar",
25 expected_start
: "foo",
26 expected_end
: "span bar",
28 // http://dev.w3.org/csswg/css-grid/#placement-shorthands
29 // "When the second value is omitted,
30 // if the first value is a <custom-ident>,
31 // the grid-row-end/grid-column-end longhand
32 // is also set to that <custom-ident>;
33 // otherwise, it is set to auto."
36 expected_start
: "foo",
46 expected_start
: "7 foo",
50 specified
: "span foo",
51 expected_start
: "span foo",
55 specified
: "foo 7 span",
56 expected_start
: "span 7 foo",
61 expected_start
: "span 7",
66 // For various specified values of the grid-area shorthand,
67 // test the computed values of the corresponding longhands.
68 var grid_area_test_cases
= [
70 specified
: "10 / 20 / 30 / 40",
72 gridColumnStart
: "20",
77 specified
: "foo / bar / baz",
79 gridColumnStart
: "bar",
84 specified
: "foo / span bar / baz",
86 gridColumnStart
: "span bar",
88 gridColumnEnd
: "auto",
91 specified
: "foo / bar",
93 gridColumnStart
: "bar",
100 gridColumnStart
: "4",
102 gridColumnEnd
: "auto",
107 gridColumnStart
: "foo",
109 gridColumnEnd
: "foo",
114 gridColumnStart
: "auto",
116 gridColumnEnd
: "auto",
120 grid_column_row_test_cases
.forEach(function(test_case
) {
121 ["Column", "Row"].forEach(function(axis
) {
122 var shorthand
= "grid" + axis
;
123 var start_longhand
= "grid" + axis
+ "Start";
124 var end_longhand
= "grid" + axis
+ "End";
126 var element
= document
.createElement('div');
127 document
.body
.appendChild(element
);
128 element
.style
[shorthand
] = test_case
.specified
;
129 var computed
= window
.getComputedStyle(element
);
130 assert_equals(computed
[start_longhand
], test_case
.expected_start
);
131 assert_equals(computed
[end_longhand
], test_case
.expected_end
);
132 }, "test parsing of '" + shorthand
+ ": " + test_case
.specified
+ "'");
136 grid_area_test_cases
.forEach(function(test_case
) {
138 var element
= document
.createElement('div');
139 document
.body
.appendChild(element
);
140 element
.style
.gridArea
= test_case
.specified
;
141 var computed
= window
.getComputedStyle(element
);
143 "gridRowStart", "gridColumnStart", "gridRowEnd", "gridColumnEnd"
144 ].forEach(function(longhand
) {
145 assert_equals(computed
[longhand
], test_case
[longhand
], longhand
);
147 }, "test parsing of 'grid-area: " + test_case
.specified
+ "'");