summaryrefslogtreecommitdiffstats
path: root/devtools/client/inspector/grids/test/browser_grids_number-of-css-grids-telemetry.js
blob: 6ec6b32a63e827e14235f478b8b468bd26eaf6eb (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
/* Any copyright is dedicated to the Public Domain.
 http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

// Tests that the telemetry count for the number of CSS Grid Elements on a page navigation
// is correct when the toolbox is opened.

const TEST_URI1 = `
  <div></div>
`;

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

add_task(async function () {
  await addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI1));

  startTelemetry();

  const { inspector } = await openLayoutView();
  const { store } = inspector;

  info("Navigate to TEST_URI2");

  const onGridListUpdate = waitUntilState(
    store,
    state => state.grids.length == 1
  );
  await navigateTo(
    "data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI2)
  );
  await onGridListUpdate;

  checkResults();
});

function checkResults() {
  // Check for:
  //   - 1 CSS Grid Element
  checkTelemetry(
    "DEVTOOLS_NUMBER_OF_CSS_GRIDS_IN_A_PAGE",
    "",
    { 0: 0, 1: 1, 2: 0 },
    "array"
  );
}