browser/devtools/netmonitor/test/browser_net_charts-02.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 have the right internal structure when
michael@0 6 * initialized with empty data.
michael@0 7 */
michael@0 8
michael@0 9 function test() {
michael@0 10 initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => {
michael@0 11 info("Starting test... ");
michael@0 12
michael@0 13 let { document, L10N, Chart } = aMonitor.panelWin;
michael@0 14 let container = document.createElement("box");
michael@0 15
michael@0 16 let pie = Chart.Pie(document, {
michael@0 17 data: null,
michael@0 18 width: 100,
michael@0 19 height: 100
michael@0 20 });
michael@0 21
michael@0 22 let node = pie.node;
michael@0 23 let slices = node.querySelectorAll(".pie-chart-slice.chart-colored-blob");
michael@0 24 let labels = node.querySelectorAll(".pie-chart-label");
michael@0 25
michael@0 26 ok(node.classList.contains("pie-chart-container") &&
michael@0 27 node.classList.contains("generic-chart-container"),
michael@0 28 "A pie chart container was created successfully.");
michael@0 29
michael@0 30 is(slices.length, 1,
michael@0 31 "There should be 1 pie chart slice created.");
michael@0 32 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 33 "The first slice has the correct data.");
michael@0 34
michael@0 35 ok(slices[0].hasAttribute("largest"),
michael@0 36 "The first slice should be the largest one.");
michael@0 37 ok(slices[0].hasAttribute("smallest"),
michael@0 38 "The first slice should also be the smallest one.");
michael@0 39 ok(slices[0].getAttribute("name"), L10N.getStr("pieChart.loading"),
michael@0 40 "The first slice's name is correct.");
michael@0 41
michael@0 42 is(labels.length, 1,
michael@0 43 "There should be 1 pie chart label created.");
michael@0 44 is(labels[0].textContent, "Loading",
michael@0 45 "The first label's text is correct.");
michael@0 46
michael@0 47 teardown(aMonitor).then(finish);
michael@0 48 });
michael@0 49 }

mercurial