summaryrefslogtreecommitdiffstats
path: root/devtools/server/tests/chrome/inactive-property-helper/float.mjs
blob: 4c502e3ccabade23e07d09c05745e7d6abe773aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

// InactivePropertyHelper `float` test cases.
export default [
  {
    info: "display: inline is inactive on a floated element",
    property: "display",
    tagName: "div",
    rules: ["div { display: inline; float: right; }"],
    isActive: false,
  },
  {
    info: "display: block is active on a floated element",
    property: "display",
    tagName: "div",
    rules: ["div { display: block; float: right;}"],
    isActive: true,
  },
  {
    info: "display: inline-grid is inactive on a floated element",
    property: "display",
    createTestElement: rootNode => {
      const container = document.createElement("div");
      container.classList.add("test");
      rootNode.append(container);
      return container;
    },
    rules: [
      "div { float: left; display:block; }",
      ".test { display: inline-grid ;}",
    ],
    isActive: false,
  },
  {
    info: "display: table-footer-group is inactive on a floated element",
    property: "display",
    createTestElement: rootNode => {
      const container = document.createElement("div");
      container.style.display = "table";
      const footer = document.createElement("div");
      footer.classList.add("table-footer");
      container.append(footer);
      rootNode.append(container);
      return footer;
    },
    rules: [".table-footer { display: table-footer-group; float: left;}"],
    isActive: false,
  },
  createGridPlacementOnFloatedItemTest("grid-row"),
  createGridPlacementOnFloatedItemTest("grid-column"),
  createGridPlacementOnFloatedItemTest("grid-area", "foo"),
];

function createGridPlacementOnFloatedItemTest(property, value = "2") {
  return {
    info: `grid placement property ${property} is active on a floated grid item`,
    property,
    createTestElement: rootNode => {
      const grid = document.createElement("div");
      grid.style.display = "grid";
      grid.style.gridTemplateRows = "repeat(5, 1fr)";
      grid.style.gridTemplateColumns = "repeat(5, 1fr)";
      grid.style.gridTemplateAreas = "'foo foo foo'";
      rootNode.appendChild(grid);

      const item = document.createElement("span");
      grid.appendChild(item);

      return item;
    },
    rules: [`span { ${property}: ${value}; float: left; }`],
    isActive: true,
  };
}