1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/netmonitor/test/browser_net_charts-04.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,70 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +/** 1.8 + * Makes sure Pie Charts have the right internal structure when 1.9 + * initialized with empty data. 1.10 + */ 1.11 + 1.12 +function test() { 1.13 + initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => { 1.14 + info("Starting test... "); 1.15 + 1.16 + let { document, L10N, Chart } = aMonitor.panelWin; 1.17 + let container = document.createElement("box"); 1.18 + 1.19 + let table = Chart.Table(document, { 1.20 + title: "Table title", 1.21 + data: null, 1.22 + totals: { 1.23 + label1: value => "Hello " + L10N.numberWithDecimals(value, 2), 1.24 + label2: value => "World " + L10N.numberWithDecimals(value, 2) 1.25 + } 1.26 + }); 1.27 + 1.28 + let node = table.node; 1.29 + let title = node.querySelector(".table-chart-title"); 1.30 + let grid = node.querySelector(".table-chart-grid"); 1.31 + let totals = node.querySelector(".table-chart-totals"); 1.32 + let rows = grid.querySelectorAll(".table-chart-row"); 1.33 + let sums = node.querySelectorAll(".table-chart-summary-label"); 1.34 + 1.35 + ok(node.classList.contains("table-chart-container") && 1.36 + node.classList.contains("generic-chart-container"), 1.37 + "A table chart container was created successfully."); 1.38 + 1.39 + ok(title, 1.40 + "A title node was created successfully."); 1.41 + is(title.getAttribute("value"), "Table title", 1.42 + "The title node displays the correct text."); 1.43 + 1.44 + is(rows.length, 1, 1.45 + "There should be 1 table chart row created."); 1.46 + 1.47 + ok(rows[0].querySelector(".table-chart-row-box.chart-colored-blob"), 1.48 + "A colored blob exists for the firt row."); 1.49 + is(rows[0].querySelectorAll("label")[0].getAttribute("name"), "size", 1.50 + "The first column of the first row exists."); 1.51 + is(rows[0].querySelectorAll("label")[1].getAttribute("name"), "label", 1.52 + "The second column of the first row exists."); 1.53 + is(rows[0].querySelectorAll("label")[0].getAttribute("value"), "", 1.54 + "The first column of the first row displays the correct text."); 1.55 + is(rows[0].querySelectorAll("label")[1].getAttribute("value"), L10N.getStr("tableChart.loading"), 1.56 + "The second column of the first row displays the correct text."); 1.57 + 1.58 + is(sums.length, 2, 1.59 + "There should be 2 total summaries created."); 1.60 + 1.61 + is(totals.querySelectorAll(".table-chart-summary-label")[0].getAttribute("name"), "label1", 1.62 + "The first sum's type is correct."); 1.63 + is(totals.querySelectorAll(".table-chart-summary-label")[0].getAttribute("value"), "Hello 0", 1.64 + "The first sum's value is correct."); 1.65 + 1.66 + is(totals.querySelectorAll(".table-chart-summary-label")[1].getAttribute("name"), "label2", 1.67 + "The second sum's type is correct."); 1.68 + is(totals.querySelectorAll(".table-chart-summary-label")[1].getAttribute("value"), "World 0", 1.69 + "The second sum's value is correct."); 1.70 + 1.71 + teardown(aMonitor).then(finish); 1.72 + }); 1.73 +}