Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
4 /**
5 * Makes sure Pie Charts have the right internal structure.
6 */
8 function test() {
9 initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => {
10 info("Starting test... ");
12 let { document, Chart } = aMonitor.panelWin;
13 let container = document.createElement("box");
15 let pie = Chart.Pie(document, {
16 width: 100,
17 height: 100,
18 data: [{
19 size: 1,
20 label: "foo"
21 }, {
22 size: 2,
23 label: "bar"
24 }, {
25 size: 3,
26 label: "baz"
27 }]
28 });
30 let node = pie.node;
31 let slices = node.querySelectorAll(".pie-chart-slice.chart-colored-blob");
32 let labels = node.querySelectorAll(".pie-chart-label");
34 ok(node.classList.contains("pie-chart-container") &&
35 node.classList.contains("generic-chart-container"),
36 "A pie chart container was created successfully.");
38 is(slices.length, 3,
39 "There should be 3 pie chart slices created.");
40 ok(slices[0].getAttribute("d").match(/\s*M 50,50 L 49\.\d+,97\.\d+ A 47\.5,47\.5 0 0 1 49\.\d+,2\.5\d* Z/),
41 "The first slice has the correct data.");
42 ok(slices[1].getAttribute("d").match(/\s*M 50,50 L 91\.\d+,26\.\d+ A 47\.5,47\.5 0 0 1 49\.\d+,97\.\d+ Z/),
43 "The second slice has the correct data.");
44 ok(slices[2].getAttribute("d").match(/\s*M 50,50 L 50\.\d+,2\.5\d* A 47\.5,47\.5 0 0 1 91\.\d+,26\.\d+ Z/),
45 "The third slice has the correct data.");
47 ok(slices[0].hasAttribute("largest"),
48 "The first slice should be the largest one.");
49 ok(slices[2].hasAttribute("smallest"),
50 "The third slice should be the smallest one.");
52 ok(slices[0].getAttribute("name"), "baz",
53 "The first slice's name is correct.");
54 ok(slices[1].getAttribute("name"), "bar",
55 "The first slice's name is correct.");
56 ok(slices[2].getAttribute("name"), "foo",
57 "The first slice's name is correct.");
59 is(labels.length, 3,
60 "There should be 3 pie chart labels created.");
61 is(labels[0].textContent, "baz",
62 "The first label's text is correct.");
63 is(labels[1].textContent, "bar",
64 "The first label's text is correct.");
65 is(labels[2].textContent, "foo",
66 "The first label's text is correct.");
68 teardown(aMonitor).then(finish);
69 });
70 }