summaryrefslogtreecommitdiffstats
path: root/devtools/client/inspector/grids/test/browser_grids_persist-color-palette.js
blob: 0a4e10dfa066279705d438acc12c7a50023f7527 (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
/* Any copyright is dedicated to the Public Domain.
 http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

// Tests that the when a custom color has been previously set, we initialize
// the grid with that color.

const TEST_URI = `
  <style type='text/css'>
    #grid {
      display: grid;
    }
  </style>
  <div id="grid">
    <div class="cell1">cell1</div>
    <div class="cell2">cell2</div>
  </div>
`;

add_task(async function () {
  await addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
  const { inspector, gridInspector, layoutView, toolbox } =
    await openLayoutView();
  const { document: doc } = gridInspector;
  const { store } = inspector;
  const cPicker = layoutView.swatchColorPickerTooltip;
  const swatch = doc.querySelector(
    "#layout-grid-container .layout-color-swatch"
  );

  info("Scrolling into view of the #grid color swatch.");
  swatch.scrollIntoView();

  info("Opening the color picker by clicking on the #grid color swatch.");
  const onColorPickerReady = cPicker.once("ready");
  swatch.click();
  await onColorPickerReady;

  await simulateColorPickerChange(cPicker, [51, 48, 0, 1]);

  info("Closing the toolbox.");
  await toolbox.destroy();
  info("Open the toolbox again.");
  await openLayoutView();

  info("Check that the previously set custom color is used.");
  is(
    swatch.style.backgroundColor,
    "rgb(51, 48, 0)",
    "The color swatch's background is correct."
  );
  is(
    store.getState().grids[0].color,
    "#333000",
    "The grid color state is correct."
  );
});