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 have the right internal structure. 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, Chart } = aMonitor.panelWin; michael@0: let container = document.createElement("box"); michael@0: michael@0: let pie = Chart.Pie(document, { michael@0: width: 100, michael@0: height: 100, michael@0: data: [{ michael@0: size: 1, michael@0: label: "foo" michael@0: }, { michael@0: size: 2, michael@0: label: "bar" michael@0: }, { michael@0: size: 3, michael@0: label: "baz" michael@0: }] 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: ok(node.classList.contains("pie-chart-container") && michael@0: node.classList.contains("generic-chart-container"), michael@0: "A pie chart container was created successfully."); michael@0: michael@0: is(slices.length, 3, michael@0: "There should be 3 pie chart slices created."); michael@0: 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/), michael@0: "The first slice has the correct data."); michael@0: 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/), michael@0: "The second slice has the correct data."); michael@0: 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/), michael@0: "The third slice has the correct data."); michael@0: michael@0: ok(slices[0].hasAttribute("largest"), michael@0: "The first slice should be the largest one."); michael@0: ok(slices[2].hasAttribute("smallest"), michael@0: "The third slice should be the smallest one."); michael@0: michael@0: ok(slices[0].getAttribute("name"), "baz", michael@0: "The first slice's name is correct."); michael@0: ok(slices[1].getAttribute("name"), "bar", michael@0: "The first slice's name is correct."); michael@0: ok(slices[2].getAttribute("name"), "foo", michael@0: "The first slice's name is correct."); michael@0: michael@0: is(labels.length, 3, michael@0: "There should be 3 pie chart labels created."); michael@0: is(labels[0].textContent, "baz", michael@0: "The first label's text is correct."); michael@0: is(labels[1].textContent, "bar", michael@0: "The first label's text is correct."); michael@0: is(labels[2].textContent, "foo", michael@0: "The first label's text is correct."); michael@0: michael@0: teardown(aMonitor).then(finish); michael@0: }); michael@0: }