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 when michael@0: * initialized with empty 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 table = Chart.Table(document, { michael@0: title: "Table title", michael@0: data: null, michael@0: totals: { michael@0: label1: value => "Hello " + L10N.numberWithDecimals(value, 2), michael@0: label2: value => "World " + L10N.numberWithDecimals(value, 2) michael@0: } michael@0: }); michael@0: michael@0: let node = table.node; michael@0: let title = node.querySelector(".table-chart-title"); michael@0: let grid = node.querySelector(".table-chart-grid"); michael@0: let totals = node.querySelector(".table-chart-totals"); michael@0: let rows = grid.querySelectorAll(".table-chart-row"); michael@0: let sums = node.querySelectorAll(".table-chart-summary-label"); michael@0: michael@0: ok(node.classList.contains("table-chart-container") && michael@0: node.classList.contains("generic-chart-container"), michael@0: "A table chart container was created successfully."); michael@0: michael@0: ok(title, michael@0: "A title node was created successfully."); michael@0: is(title.getAttribute("value"), "Table title", michael@0: "The title node displays the correct text."); michael@0: michael@0: is(rows.length, 1, michael@0: "There should be 1 table chart row created."); michael@0: michael@0: ok(rows[0].querySelector(".table-chart-row-box.chart-colored-blob"), michael@0: "A colored blob exists for the firt row."); michael@0: is(rows[0].querySelectorAll("label")[0].getAttribute("name"), "size", michael@0: "The first column of the first row exists."); michael@0: is(rows[0].querySelectorAll("label")[1].getAttribute("name"), "label", michael@0: "The second column of the first row exists."); michael@0: is(rows[0].querySelectorAll("label")[0].getAttribute("value"), "", michael@0: "The first column of the first row displays the correct text."); michael@0: is(rows[0].querySelectorAll("label")[1].getAttribute("value"), L10N.getStr("tableChart.loading"), michael@0: "The second column of the first row displays the correct text."); michael@0: michael@0: is(sums.length, 2, michael@0: "There should be 2 total summaries created."); michael@0: michael@0: is(totals.querySelectorAll(".table-chart-summary-label")[0].getAttribute("name"), "label1", michael@0: "The first sum's type is correct."); michael@0: is(totals.querySelectorAll(".table-chart-summary-label")[0].getAttribute("value"), "Hello 0", michael@0: "The first sum's value is correct."); michael@0: michael@0: is(totals.querySelectorAll(".table-chart-summary-label")[1].getAttribute("name"), "label2", michael@0: "The second sum's type is correct."); michael@0: is(totals.querySelectorAll(".table-chart-summary-label")[1].getAttribute("value"), "World 0", michael@0: "The second sum's value is correct."); michael@0: michael@0: teardown(aMonitor).then(finish); michael@0: }); michael@0: }