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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial