Bug 1924993 - [devtools] Debugger tests wait before typing in conditional panel r...
[gecko.git] / devtools / client / netmonitor / test / browser_net_charts-02.js
blob106ec883804eac3d2384e27d511379bb8967a368
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
4 "use strict";
6 /**
7 * Makes sure Pie Charts have the right internal structure when
8 * initialized with empty data.
9 */
11 add_task(async function () {
12 const {
13 L10N,
14 } = require("resource://devtools/client/netmonitor/src/utils/l10n.js");
16 const { monitor } = await initNetMonitor(HTTPS_SIMPLE_URL, {
17 requestCount: 1,
18 });
19 info("Starting test... ");
21 const { document, windowRequire } = monitor.panelWin;
22 const { Chart } = windowRequire("devtools/client/shared/widgets/Chart");
24 const wait = waitForNetworkEvents(monitor, 1);
25 await navigateTo(HTTPS_SIMPLE_URL);
26 await wait;
28 const pie = Chart.Pie(document, {
29 data: null,
30 width: 100,
31 height: 100,
32 });
34 const { node } = pie;
35 const slices = node.querySelectorAll(".pie-chart-slice");
36 const labels = node.querySelectorAll(".pie-chart-label");
38 ok(
39 node.classList.contains("pie-chart-container") &&
40 node.classList.contains("generic-chart-container"),
41 "A pie chart container was created successfully."
44 is(slices.length, 1, "There should be 1 pie chart slice created.");
45 ok(
46 slices[0]
47 .getAttribute("d")
48 .match(
49 /\s*M 50,50 L 50\.\d+,2\.5\d* A 47\.5,47\.5 0 1 1 49\.\d+,2\.5\d* Z/
51 "The first slice has the correct data."
54 ok(
55 slices[0].hasAttribute("largest"),
56 "The first slice should be the largest one."
58 ok(
59 slices[0].hasAttribute("smallest"),
60 "The first slice should also be the smallest one."
62 is(
63 slices[0].getAttribute("data-statistic-name"),
64 L10N.getStr("pieChart.loading"),
65 "The first slice's name is correct."
68 is(labels.length, 1, "There should be 1 pie chart label created.");
69 is(labels[0].textContent, "Loading", "The first label's text is correct.");
71 await teardown(monitor);
72 });