1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 // InactivePropertyHelper `float` test cases.
8 info: "display: inline is inactive on a floated element",
11 rules: ["div { display: inline; float: right; }"],
13 expectedMsgId: "inactive-css-not-display-block-on-floated-2",
16 info: "display: block is active on a floated element",
19 rules: ["div { display: block; float: right;}"],
23 info: "display: inline-grid is inactive on a floated element",
25 createTestElement: rootNode => {
26 const container = document.createElement("div");
27 container.classList.add("test");
28 rootNode.append(container);
32 "div { float: left; display:block; }",
33 ".test { display: inline-grid ;}",
36 expectedMsgId: "inactive-css-not-display-block-on-floated-2",
39 info: "display: table-footer-group is inactive on a floated element",
41 createTestElement: rootNode => {
42 const container = document.createElement("div");
43 container.style.display = "table";
44 const footer = document.createElement("div");
45 footer.classList.add("table-footer");
46 container.append(footer);
47 rootNode.append(container);
50 rules: [".table-footer { display: table-footer-group; float: left;}"],
52 expectedMsgId: "inactive-css-not-display-block-on-floated-2",
54 createGridPlacementOnFloatedItemTest("grid-row"),
55 createGridPlacementOnFloatedItemTest("grid-column"),
56 createGridPlacementOnFloatedItemTest("grid-area", "foo"),
58 info: "float is valid on block-level elements",
61 rules: ["div { float: right; }"],
65 info: "float is invalid on flex items",
67 createTestElement: createContainerWithItem("flex"),
68 rules: [".item { float: right; }"],
70 expectedMsgId: "inactive-css-only-non-grid-or-flex-item",
73 info: "float is invalid on grid items",
75 createTestElement: createContainerWithItem("grid"),
76 rules: [".item { float: right; }"],
78 expectedMsgId: "inactive-css-only-non-grid-or-flex-item",
81 info: "clear is valid on block-level elements",
84 rules: ["div { clear: right; }"],
88 info: "clear is valid on block-level grid containers",
91 rules: ["div { display: grid; clear: left; }"],
95 info: "clear is invalid on non-block-level elements",
98 rules: ["span { clear: right; }"],
100 expectedMsgId: "inactive-css-not-block",
103 info: "shape-image-threshold is valid on floating elements",
104 property: "shape-image-threshold",
106 rules: ["div { shape-image-threshold: 0.5; float: right; }"],
110 info: "shape-image-threshold is invalid on non-floating elements",
111 property: "shape-image-threshold",
113 rules: ["div { shape-image-threshold: 0.5; }"],
115 expectedMsgId: "inactive-css-not-floated",
118 info: "shape-outside is valid on floating elements",
119 property: "shape-outside",
121 rules: ["div { shape-outside: circle(); float: right; }"],
125 info: "shape-outside is invalid on non-floating elements",
126 property: "shape-outside",
128 rules: ["div { shape-outside: circle(); }"],
130 expectedMsgId: "inactive-css-not-floated",
133 info: "shape-margin is valid on floating elements",
134 property: "shape-margin",
136 rules: ["div { shape-margin: 10px; float: right; }"],
140 info: "shape-margin is invalid on non-floating elements",
141 property: "shape-margin",
143 rules: ["div { shape-margin: 10px; }"],
145 expectedMsgId: "inactive-css-not-floated",
149 function createGridPlacementOnFloatedItemTest(property, value = "2") {
151 info: `grid placement property ${property} is active on a floated grid item`,
153 createTestElement: rootNode => {
154 const grid = document.createElement("div");
155 grid.style.display = "grid";
156 grid.style.gridTemplateRows = "repeat(5, 1fr)";
157 grid.style.gridTemplateColumns = "repeat(5, 1fr)";
158 grid.style.gridTemplateAreas = "'foo foo foo'";
159 rootNode.appendChild(grid);
161 const item = document.createElement("span");
162 grid.appendChild(item);
166 rules: [`span { ${property}: ${value}; float: left; }`],
171 function createContainerWithItem(display) {
173 const container = document.createElement("div");
174 container.style.display = display;
175 const item = document.createElement("div");
176 item.classList.add("item");
177 container.append(item);
178 rootNode.append(container);