8 #placeItemsCenterAuto {
9 place-items: center auto;
12 place-items: baseline;
14 #placeItemsFirstBaseline {
15 place-items: first baseline;
17 #placeItemsLastBaseline {
18 place-items: last baseline;
23 #placeItemsFlexStart {
24 place-items: flex-start;
29 #placeItemsSelfStart {
30 place-items: self-start;
36 place-items: start end;
38 #placeItemsStartSelfEnd {
39 place-items: start self-end;
41 #placeItemsStartBaseline {
42 place-items: start baseline;
45 <!-- Invalid CSS cases -->
58 #placeItemsStartSafe {
59 place-items: start safe;
61 #placeItemsStartEndLeft {
62 place-items: start end left;
65 <script src="../resources/testharness.js"></script>
66 <script src="../resources/testharnessreport.js"></script>
67 <script src="resources/alignment-parsing-utils-th.js"></script>
70 <p>Test to verify that the new place-items alignment shorthand is parsed as expected and correctly sets the longhand values.</p>
73 <div id="placeItemsNormal"></div>
74 <div id="placeItemsCenterAuto"></div>
75 <div id="placeItemsBaseline"></div>
76 <div id="placeItemsFirstBaseline"></div>
77 <div id="placeItemsLastBaseline"></div>
78 <div id="placeItemsStart"></div>
79 <div id="placeItemsFlexStart"></div>
80 <div id="placeItemsEnd"></div>
81 <div id="placeItemsSelfStart"></div>
82 <div id="placeItemsStretch"></div>
83 <div id="placeItemsStartEnd"></div>
84 <div id="placeItemsStartSelfEnd"></div>
85 <div id="placeItemsStartBaseline"></div>
87 <div id="placeItemsEmpty"></div>
88 <div id="placeItemsAuto"></div>
89 <div id="placeItemsNone"></div>
90 <div id="placeItemsSafe"></div>
91 <div id="placeItemsStartSafe"></div>
92 <div id="placeItemsBaselineSafe"></div>
93 <div id="placeItemsStartEndLeft"></div>
95 function checkPlaceItemsValues(element, value, alignValue, justifyValue) {
96 var res = value.split(" ");
99 checkValues(element, "alignItems", "align-items", res[0], alignValue);
100 checkValues(element, "justifyItems", "justify-items", res[1], justifyValue);
103 function checkPlaceItemsValuesJS(value, alignValue, justifyValue)
105 element = document.createElement("div");
106 document.body.appendChild(element);
107 element.style.placeItems = value;
108 checkValues(element, "placeItems", "place-items", value, alignValue + ' ' + justifyValue)
109 checkPlaceItemsValues(element, value, alignValue, justifyValue)
112 function checkPlaceItemsValuesBadJS(value)
114 element.style.placeItems = "";
115 element.style.placeItems = value;
116 checkPlaceItemsValues(element, "", "normal", "normal")
120 checkValues(placeItemsNormal, "placeItems", "place-items", "", "normal normal");
121 checkPlaceItemsValues(placeItemsNormal, "", "normal", "normal");
122 }, "Test getting the Computed Value of place-items's longhand properties when setting 'normal' value through CSS.");
125 checkValues(placeItemsCenterAuto, "placeItems", "place-items", "", "center normal");
126 checkPlaceItemsValues(placeItemsCenterAuto, "", "center", "normal");
127 }, "Test getting the Computed Value of place-items's longhand properties when setting 'center auto' value through CSS.");
130 checkValues(placeItemsBaseline, "placeItems", "place-items", "", "baseline baseline");
131 checkPlaceItemsValues(placeItemsBaseline, "", "baseline", "baseline");
132 }, "Test getting the Computed Value of place-items's longhand properties when setting 'baseline' value through CSS.");
135 checkValues(placeItemsFirstBaseline, "placeItems", "place-items", "", "baseline baseline");
136 checkPlaceItemsValues(placeItemsFirstBaseline, "", "baseline", "baseline");
137 }, "Test getting the Computed Value of place-items's longhand properties when setting 'first baseline' value through CSS.");
140 checkValues(placeItemsLastBaseline, "placeItems", "place-items", "", "last baseline last baseline");
141 checkPlaceItemsValues(placeItemsLastBaseline, "", "last baseline", "last baseline");
142 }, "Test getting the Computed Value of place-items's longhand properties when setting 'last baseline' value through CSS.");
145 checkValues(placeItemsStart, "placeItems", "place-items", "", "start start");
146 checkPlaceItemsValues(placeItemsStart, "", "start", "start");
147 }, "Test getting the Computed Value of place-items's longhand properties when setting 'start' value through CSS.");
150 checkValues(placeItemsFlexStart, "placeItems", "place-items", "", "flex-start flex-start");
151 checkPlaceItemsValues(placeItemsFlexStart, "", "flex-start", "flex-start");
152 }, "Test getting the Computed Value of place-items's longhand properties when setting 'flex-start' value through CSS.");
155 checkValues(placeItemsEnd, "placeItems", "place-items", "", "end end");
156 checkPlaceItemsValues(placeItemsEnd, "", "end", "end");
157 }, "Test getting the Computed Value of place-items's longhand properties when setting 'end' value through CSS.");
160 checkValues(placeItemsSelfStart, "placeItems", "place-items", "", "self-start self-start");
161 checkPlaceItemsValues(placeItemsSelfStart, "", "self-start", "self-start");
162 }, "Test getting the Computed Value of place-items's longhand properties when setting 'self-start' value through CSS.");
165 checkValues(placeItemsStretch, "placeItems", "place-items", "", "stretch stretch");
166 checkPlaceItemsValues(placeItemsStretch, "", "stretch", "stretch");
167 }, "Test getting the Computed Value of place-items's longhand properties when setting 'stretch' value through CSS.");
170 checkValues(placeItemsStartEnd, "placeItems", "place-items", "", "start end");
171 checkPlaceItemsValues(placeItemsStartEnd, "", "start", "end");
172 }, "Test getting the Computed Value of place-items's longhand properties when setting 'start end' value through CSS.");
175 checkValues(placeItemsStartSelfEnd, "placeItems", "place-items", "", "start self-end");
176 checkPlaceItemsValues(placeItemsStartSelfEnd, "", "start", "self-end");
177 }, "Test getting the Computed Value of place-items's longhand properties when setting 'start self-end' value through CSS.");
180 checkValues(placeItemsStartBaseline, "placeItems", "place-items", "", "start baseline");
181 checkPlaceItemsValues(placeItemsStartBaseline, "", "start", "baseline");
182 }, "Test getting the Computed Value of place-items's longhand properties when setting 'start baseline' value through CSS.");
185 checkValues(placeItemsAuto, "placeItems", "place-items", "", "normal normal");
186 checkPlaceItemsValues(placeItemsAuto, "", "normal", "normal");
187 }, "Test setting '' as incorrect value through CSS.");
190 checkValues(placeItemsAuto, "placeItems", "place-items", "", "normal normal");
191 checkPlaceItemsValues(placeItemsAuto, "", "normal", "normal");
192 }, "Test setting 'auto' as incorrect value through CSS.");
195 checkValues(placeItemsNone, "placeItems", "place-items", "", "normal normal");
196 checkPlaceItemsValues(placeItemsNone, "", "normal", "normal");
197 }, "Test setting 'none' as incorrect value through CSS.");
200 checkValues(placeItemsSafe, "placeItems", "place-items", "", "normal normal");
201 checkPlaceItemsValues(placeItemsSafe, "", "normal", "normal");
202 }, "Test setting 'safe' as incorrect value through CSS.");
205 checkValues(placeItemsStartSafe, "placeItems", "place-items", "", "normal normal");
206 checkPlaceItemsValues(placeItemsStartSafe, "", "normal", "normal");
207 }, "Test setting 'start safe' as incorrect value through CSS.");
210 checkValues(placeItemsStartSafe, "placeItems", "place-items", "", "normal normal");
211 checkPlaceItemsValues(placeItemsStartSafe, "", "normal", "normal");
212 }, "Test setting 'baseline safe' as incorrect value through CSS.");
215 checkValues(placeItemsStartEndLeft, "placeItems", "place-items", "", "normal normal");
216 checkPlaceItemsValues(placeItemsStartEndLeft, "", "normal", "normal");
217 }, "Test setting 'start end left' as incorrect value through CSS.");
220 checkPlaceItemsValuesJS("center", "center", "center");
221 checkPlaceItemsValuesJS("center start", "center", "start");
222 checkPlaceItemsValuesJS("self-start end", "self-start", "end");
223 checkPlaceItemsValuesJS("normal end", "normal", "end");
224 }, "Test setting values through JS.");
227 checkPlaceItemsValuesBadJS("auto normal", "normal", "normal");
228 checkPlaceItemsValuesBadJS("space-between", "normal", "normal");
229 checkPlaceItemsValuesBadJS("center safe", "normal", "normal");
230 checkPlaceItemsValuesBadJS("center self-start center", "normal", "normal");
231 checkPlaceItemsValuesBadJS("asrt", "normal", "normal");
232 checkPlaceItemsValuesBadJS("auto", "normal", "normal");
233 checkPlaceItemsValuesBadJS("10px", "normal", "normal");
234 checkPlaceItemsValuesBadJS("stretch safe", "normal", "normal");
235 checkPlaceItemsValuesBadJS("self-start start end", "normal", "normal");
236 checkPlaceItemsValuesBadJS("", "normal", "normal");
237 }, "Test setting incorrect values through JS.");
240 element = document.createElement("div");
241 document.body.appendChild(element);
242 checkValues(element, "placeItems", "place-items", "", "normal normal");
243 element.style.placeItems = "center";
244 checkPlaceItemsValues(element, "center", "center", "center");
245 element.style.placeItems = "initial";
246 checkValues(element, "placeItems", "place-items", "initial", "normal normal");
247 checkPlaceItemsValues(element, "initial", "normal", "normal");
248 }, "Test the 'initial' value of the place-items shorthand and its longhand properties' Computed value");
251 document.body.style.placeItems = "start";
252 var anotherElement = document.createElement("div");
253 document.body.appendChild(anotherElement);
254 checkPlaceItemsValues(anotherElement, "", "normal", "normal");
255 anotherElement.style.placeItems = "inherit";
256 checkPlaceItemsValues(anotherElement, "inherit", "start", "start");
257 }, "Test the 'inherit' value of the place-items shorthand and its longhand properties' Computed value");