1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
7 * Makes sure Pie Charts have the right internal structure when
8 * initialized with empty data.
11 add_task(async
function () {
14 } = require("resource://devtools/client/netmonitor/src/utils/l10n.js");
16 const { monitor
} = await
initNetMonitor(HTTPS_SIMPLE_URL
, {
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
);
28 const pie
= Chart
.Pie(document
, {
35 const slices
= node
.querySelectorAll(".pie-chart-slice");
36 const labels
= node
.querySelectorAll(".pie-chart-label");
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.");
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."
55 slices
[0].hasAttribute("largest"),
56 "The first slice should be the largest one."
59 slices
[0].hasAttribute("smallest"),
60 "The first slice should also be the smallest one."
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
);