browser/devtools/netmonitor/test/browser_net_charts-06.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:97946ad46c0f
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
3
4 /**
5 * Makes sure Pie Charts correctly handle empty source data.
6 */
7
8 function test() {
9 initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => {
10 info("Starting test... ");
11
12 let { document, L10N, Chart } = aMonitor.panelWin;
13 let container = document.createElement("box");
14
15 let pie = Chart.Pie(document, {
16 data: [],
17 width: 100,
18 height: 100
19 });
20
21 let node = pie.node;
22 let slices = node.querySelectorAll(".pie-chart-slice.chart-colored-blob");
23 let labels = node.querySelectorAll(".pie-chart-label");
24
25 is(slices.length, 1,
26 "There should be 1 pie chart slice created.");
27 ok(slices[0].getAttribute("d").match(/\s*M 50,50 L 50\.\d+,2\.5\d* A 47\.5,47\.5 0 1 1 49\.\d+,2\.5\d* Z/),
28 "The slice has the correct data.");
29
30 ok(slices[0].hasAttribute("largest"),
31 "The slice should be the largest one.");
32 ok(slices[0].hasAttribute("smallest"),
33 "The slice should also be the smallest one.");
34 ok(slices[0].getAttribute("name"), L10N.getStr("pieChart.unavailable"),
35 "The slice's name is correct.");
36
37 is(labels.length, 1,
38 "There should be 1 pie chart label created.");
39 is(labels[0].textContent, "Empty",
40 "The label's text is correct.");
41
42 teardown(aMonitor).then(finish);
43 });
44 }

mercurial