Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | /** |
michael@0 | 5 | * Makes sure Table Charts correctly handle empty source data. |
michael@0 | 6 | */ |
michael@0 | 7 | |
michael@0 | 8 | function test() { |
michael@0 | 9 | initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => { |
michael@0 | 10 | info("Starting test... "); |
michael@0 | 11 | |
michael@0 | 12 | let { document, L10N, Chart } = aMonitor.panelWin; |
michael@0 | 13 | let container = document.createElement("box"); |
michael@0 | 14 | |
michael@0 | 15 | let table = Chart.Table(document, { |
michael@0 | 16 | data: [], |
michael@0 | 17 | totals: { |
michael@0 | 18 | label1: value => "Hello " + L10N.numberWithDecimals(value, 2), |
michael@0 | 19 | label2: value => "World " + L10N.numberWithDecimals(value, 2) |
michael@0 | 20 | } |
michael@0 | 21 | }); |
michael@0 | 22 | |
michael@0 | 23 | let node = table.node; |
michael@0 | 24 | let grid = node.querySelector(".table-chart-grid"); |
michael@0 | 25 | let totals = node.querySelector(".table-chart-totals"); |
michael@0 | 26 | let rows = grid.querySelectorAll(".table-chart-row"); |
michael@0 | 27 | let sums = node.querySelectorAll(".table-chart-summary-label"); |
michael@0 | 28 | |
michael@0 | 29 | is(rows.length, 1, |
michael@0 | 30 | "There should be 1 table chart row created."); |
michael@0 | 31 | |
michael@0 | 32 | ok(rows[0].querySelector(".table-chart-row-box.chart-colored-blob"), |
michael@0 | 33 | "A colored blob exists for the firt row."); |
michael@0 | 34 | is(rows[0].querySelectorAll("label")[0].getAttribute("name"), "size", |
michael@0 | 35 | "The first column of the first row exists."); |
michael@0 | 36 | is(rows[0].querySelectorAll("label")[1].getAttribute("name"), "label", |
michael@0 | 37 | "The second column of the first row exists."); |
michael@0 | 38 | is(rows[0].querySelectorAll("label")[0].getAttribute("value"), "", |
michael@0 | 39 | "The first column of the first row displays the correct text."); |
michael@0 | 40 | is(rows[0].querySelectorAll("label")[1].getAttribute("value"), L10N.getStr("tableChart.unavailable"), |
michael@0 | 41 | "The second column of the first row displays the correct text."); |
michael@0 | 42 | |
michael@0 | 43 | is(sums.length, 2, |
michael@0 | 44 | "There should be 2 total summaries created."); |
michael@0 | 45 | |
michael@0 | 46 | is(totals.querySelectorAll(".table-chart-summary-label")[0].getAttribute("name"), "label1", |
michael@0 | 47 | "The first sum's type is correct."); |
michael@0 | 48 | is(totals.querySelectorAll(".table-chart-summary-label")[0].getAttribute("value"), "Hello 0", |
michael@0 | 49 | "The first sum's value is correct."); |
michael@0 | 50 | |
michael@0 | 51 | is(totals.querySelectorAll(".table-chart-summary-label")[1].getAttribute("name"), "label2", |
michael@0 | 52 | "The second sum's type is correct."); |
michael@0 | 53 | is(totals.querySelectorAll(".table-chart-summary-label")[1].getAttribute("value"), "World 0", |
michael@0 | 54 | "The second sum's value is correct."); |
michael@0 | 55 | |
michael@0 | 56 | teardown(aMonitor).then(finish); |
michael@0 | 57 | }); |
michael@0 | 58 | } |