michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: /** michael@0: * Makes sure Pie Charts correctly handle empty source data. michael@0: */ michael@0: michael@0: function test() { michael@0: initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => { michael@0: info("Starting test... "); michael@0: michael@0: let { document, L10N, Chart } = aMonitor.panelWin; michael@0: let container = document.createElement("box"); michael@0: michael@0: let pie = Chart.Pie(document, { michael@0: data: [], michael@0: width: 100, michael@0: height: 100 michael@0: }); michael@0: michael@0: let node = pie.node; michael@0: let slices = node.querySelectorAll(".pie-chart-slice.chart-colored-blob"); michael@0: let labels = node.querySelectorAll(".pie-chart-label"); michael@0: michael@0: is(slices.length, 1, michael@0: "There should be 1 pie chart slice created."); michael@0: 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: "The slice has the correct data."); michael@0: michael@0: ok(slices[0].hasAttribute("largest"), michael@0: "The slice should be the largest one."); michael@0: ok(slices[0].hasAttribute("smallest"), michael@0: "The slice should also be the smallest one."); michael@0: ok(slices[0].getAttribute("name"), L10N.getStr("pieChart.unavailable"), michael@0: "The slice's name is correct."); michael@0: michael@0: is(labels.length, 1, michael@0: "There should be 1 pie chart label created."); michael@0: is(labels[0].textContent, "Empty", michael@0: "The label's text is correct."); michael@0: michael@0: teardown(aMonitor).then(finish); michael@0: }); michael@0: }