1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/netmonitor/test/browser_net_charts-07.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,58 @@ 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 Table Charts correctly handle empty source data. 1.9 + */ 1.10 + 1.11 +function test() { 1.12 + initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => { 1.13 + info("Starting test... "); 1.14 + 1.15 + let { document, L10N, Chart } = aMonitor.panelWin; 1.16 + let container = document.createElement("box"); 1.17 + 1.18 + let table = Chart.Table(document, { 1.19 + data: [], 1.20 + totals: { 1.21 + label1: value => "Hello " + L10N.numberWithDecimals(value, 2), 1.22 + label2: value => "World " + L10N.numberWithDecimals(value, 2) 1.23 + } 1.24 + }); 1.25 + 1.26 + let node = table.node; 1.27 + let grid = node.querySelector(".table-chart-grid"); 1.28 + let totals = node.querySelector(".table-chart-totals"); 1.29 + let rows = grid.querySelectorAll(".table-chart-row"); 1.30 + let sums = node.querySelectorAll(".table-chart-summary-label"); 1.31 + 1.32 + is(rows.length, 1, 1.33 + "There should be 1 table chart row created."); 1.34 + 1.35 + ok(rows[0].querySelector(".table-chart-row-box.chart-colored-blob"), 1.36 + "A colored blob exists for the firt row."); 1.37 + is(rows[0].querySelectorAll("label")[0].getAttribute("name"), "size", 1.38 + "The first column of the first row exists."); 1.39 + is(rows[0].querySelectorAll("label")[1].getAttribute("name"), "label", 1.40 + "The second column of the first row exists."); 1.41 + is(rows[0].querySelectorAll("label")[0].getAttribute("value"), "", 1.42 + "The first column of the first row displays the correct text."); 1.43 + is(rows[0].querySelectorAll("label")[1].getAttribute("value"), L10N.getStr("tableChart.unavailable"), 1.44 + "The second column of the first row displays the correct text."); 1.45 + 1.46 + is(sums.length, 2, 1.47 + "There should be 2 total summaries created."); 1.48 + 1.49 + is(totals.querySelectorAll(".table-chart-summary-label")[0].getAttribute("name"), "label1", 1.50 + "The first sum's type is correct."); 1.51 + is(totals.querySelectorAll(".table-chart-summary-label")[0].getAttribute("value"), "Hello 0", 1.52 + "The first sum's value is correct."); 1.53 + 1.54 + is(totals.querySelectorAll(".table-chart-summary-label")[1].getAttribute("name"), "label2", 1.55 + "The second sum's type is correct."); 1.56 + is(totals.querySelectorAll(".table-chart-summary-label")[1].getAttribute("value"), "World 0", 1.57 + "The second sum's value is correct."); 1.58 + 1.59 + teardown(aMonitor).then(finish); 1.60 + }); 1.61 +}