summaryrefslogtreecommitdiffstats
path: root/devtools/client/inspector/test/browser_inspector_highlighter-cssgrid_02.js
blob: 2fabf9b34bfceaaa126ff5112f0efdd81dc66a64 (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
/* 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/. */

"use strict";

// Test that grid layouts without items don't cause grid highlighter errors.

const TEST_URL = `
  <style type='text/css'>
    .grid {
      display: grid;
      grid-template-columns: 20px 20px;
      grid-gap: 15px;
    }
  </style>
  <div class="grid"></div>
`;

const HIGHLIGHTER_TYPE = "CssGridHighlighter";

add_task(async function () {
  const { inspector, highlighterTestFront } = await openInspectorForURL(
    "data:text/html;charset=utf-8," + encodeURIComponent(TEST_URL)
  );
  const front = inspector.inspectorFront;
  const highlighter = await front.getHighlighterByType(HIGHLIGHTER_TYPE);

  info("Try to show the highlighter on the grid container");
  const node = await getNodeFront(".grid", inspector);
  await highlighter.show(node);

  let hidden = await highlighterTestFront.getHighlighterNodeAttribute(
    "css-grid-canvas",
    "hidden",
    highlighter
  );
  ok(!hidden, "The highlighter is visible");

  info("Hiding the highlighter");
  await highlighter.hide();

  hidden = await highlighterTestFront.getHighlighterNodeAttribute(
    "css-grid-canvas",
    "hidden",
    highlighter
  );
  ok(hidden, "The highlighter is hidden");

  await highlighter.finalize();
});