summaryrefslogtreecommitdiffstats
path: root/devtools/client/inspector/rules/test/browser_rules_inactive_css_flexbox.js
blob: 23f1b398458f8b184159b2fa98d0a10f7af784af (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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
/* Any copyright is dedicated to the Public Domain.
 http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

// Test inactive flex properties.

const TEST_URI = `
<head>
  <style>
    #container {
      width: 200px;
      height: 100px;
      border: 1px solid #000;
      align-content: space-between;
      order: 1;
    }

    .flex-item {
      flex-basis: auto;
      flex-grow: 1;
      flex-shrink: 1;
      flex-direction: row;
    }

    #self-aligned {
      align-self: stretch;
    }
  </style>
</head>
<body>
    <h1>browser_rules_inactive_css_flexbox.js</h1>
    <div id="container" style="display:flex">
      <div class="flex-item item-1" style="order:1">1</div>
      <div class="flex-item item-2" style="order:2">2</div>
      <div class="flex-item item-3" style="order:3">3</div>
    </div>
    <div id="self-aligned"></div>
</body>`;

const BEFORE = [
  {
    selector: "#self-aligned",
    inactiveDeclarations: [
      {
        declaration: {
          "align-self": "stretch",
        },
        ruleIndex: 1,
      },
    ],
  },
  {
    selector: ".item-2",
    activeDeclarations: [
      {
        declarations: {
          order: "2",
        },
        ruleIndex: 0,
      },
      {
        declarations: {
          "flex-basis": "auto",
          "flex-grow": "1",
          "flex-shrink": "1",
        },
        ruleIndex: 1,
      },
    ],
    inactiveDeclarations: [
      {
        declaration: {
          "flex-direction": "row",
        },
        ruleIndex: 1,
      },
    ],
  },
  {
    selector: "#container",
    activeDeclarations: [
      {
        declarations: {
          display: "flex",
        },
        ruleIndex: 0,
      },
      {
        declarations: {
          width: "200px",
          height: "100px",
          border: "1px solid #000",
          "align-content": "space-between",
        },
        ruleIndex: 1,
      },
    ],
    inactiveDeclarations: [
      {
        declaration: {
          order: "1",
        },
        ruleIndex: 1,
      },
    ],
  },
];

const AFTER = [
  {
    selector: ".item-2",
    inactiveDeclarations: [
      {
        declaration: {
          order: "2",
        },
        ruleIndex: 0,
      },
      {
        declaration: {
          "flex-basis": "auto",
        },
        ruleIndex: 1,
      },
      {
        declaration: {
          "flex-grow": "1",
        },
        ruleIndex: 1,
      },
      {
        declaration: {
          "flex-shrink": "1",
        },
        ruleIndex: 1,
      },
      {
        declaration: {
          "flex-direction": "row",
        },
        ruleIndex: 1,
      },
    ],
  },
];

add_task(async function () {
  await pushPref("devtools.inspector.inactive.css.enabled", true);

  await addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
  const { inspector, view } = await openRuleView();

  await runInactiveCSSTests(view, inspector, BEFORE);

  // Toggle `display:flex` to disabled.
  await toggleDeclaration(view, 0, {
    display: "flex",
  });
  await runInactiveCSSTests(view, inspector, AFTER);
});