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 positioned elements test cases.
7 // These are the properties we care about, those that are inactive when the element isn't
10 { property: "z-index", value: "2" },
11 { property: "top", value: "20px" },
12 { property: "right", value: "20px" },
13 { property: "bottom", value: "20px" },
14 { property: "left", value: "20px" },
17 // These are all of the different position values and whether the above properties are
18 // active or not for each.
20 { position: "unset", isActive: false },
21 { position: "initial", isActive: false },
22 { position: "inherit", isActive: false },
23 { position: "static", isActive: false },
24 { position: "absolute", isActive: true },
25 { position: "relative", isActive: true },
26 { position: "fixed", isActive: true },
27 { position: "sticky", isActive: true },
30 function makeTestCase(property, value, position, isActive) {
32 info: `${property} is ${
34 }active when position is ${position}`,
37 rules: [`div { ${property}: ${value}; position: ${position}; }`],
42 // Make the test cases for all the combinations of PROPERTIES and POSITIONS
45 for (const { property, value } of PROPERTIES) {
46 for (const { position, isActive } of POSITIONS) {
47 mainTests.push(makeTestCase(property, value, position, isActive));
51 // Add a few test cases to check that z-index actually works inside grids and flexboxes.
53 info: "z-index is active even on unpositioned elements if they are grid items",
55 createTestElement: rootNode => {
56 const container = document.createElement("div");
57 const element = document.createElement("span");
58 container.append(element);
59 rootNode.append(container);
62 rules: ["div { display: grid; }", "span { z-index: 3; }"],
68 info: "z-index is active even on unpositioned elements if they are flex items",
70 createTestElement: rootNode => {
71 const container = document.createElement("div");
72 const element = document.createElement("span");
73 container.append(element);
74 rootNode.append(container);
77 rules: ["div { display: flex; }", "span { z-index: 3; }"],
82 export default mainTests;