browser/devtools/netmonitor/test/browser_net_charts-04.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

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 Pie Charts have the right internal structure when
michael@0 6 * initialized with empty data.
michael@0 7 */
michael@0 8
michael@0 9 function test() {
michael@0 10 initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => {
michael@0 11 info("Starting test... ");
michael@0 12
michael@0 13 let { document, L10N, Chart } = aMonitor.panelWin;
michael@0 14 let container = document.createElement("box");
michael@0 15
michael@0 16 let table = Chart.Table(document, {
michael@0 17 title: "Table title",
michael@0 18 data: null,
michael@0 19 totals: {
michael@0 20 label1: value => "Hello " + L10N.numberWithDecimals(value, 2),
michael@0 21 label2: value => "World " + L10N.numberWithDecimals(value, 2)
michael@0 22 }
michael@0 23 });
michael@0 24
michael@0 25 let node = table.node;
michael@0 26 let title = node.querySelector(".table-chart-title");
michael@0 27 let grid = node.querySelector(".table-chart-grid");
michael@0 28 let totals = node.querySelector(".table-chart-totals");
michael@0 29 let rows = grid.querySelectorAll(".table-chart-row");
michael@0 30 let sums = node.querySelectorAll(".table-chart-summary-label");
michael@0 31
michael@0 32 ok(node.classList.contains("table-chart-container") &&
michael@0 33 node.classList.contains("generic-chart-container"),
michael@0 34 "A table chart container was created successfully.");
michael@0 35
michael@0 36 ok(title,
michael@0 37 "A title node was created successfully.");
michael@0 38 is(title.getAttribute("value"), "Table title",
michael@0 39 "The title node displays the correct text.");
michael@0 40
michael@0 41 is(rows.length, 1,
michael@0 42 "There should be 1 table chart row created.");
michael@0 43
michael@0 44 ok(rows[0].querySelector(".table-chart-row-box.chart-colored-blob"),
michael@0 45 "A colored blob exists for the firt row.");
michael@0 46 is(rows[0].querySelectorAll("label")[0].getAttribute("name"), "size",
michael@0 47 "The first column of the first row exists.");
michael@0 48 is(rows[0].querySelectorAll("label")[1].getAttribute("name"), "label",
michael@0 49 "The second column of the first row exists.");
michael@0 50 is(rows[0].querySelectorAll("label")[0].getAttribute("value"), "",
michael@0 51 "The first column of the first row displays the correct text.");
michael@0 52 is(rows[0].querySelectorAll("label")[1].getAttribute("value"), L10N.getStr("tableChart.loading"),
michael@0 53 "The second column of the first row displays the correct text.");
michael@0 54
michael@0 55 is(sums.length, 2,
michael@0 56 "There should be 2 total summaries created.");
michael@0 57
michael@0 58 is(totals.querySelectorAll(".table-chart-summary-label")[0].getAttribute("name"), "label1",
michael@0 59 "The first sum's type is correct.");
michael@0 60 is(totals.querySelectorAll(".table-chart-summary-label")[0].getAttribute("value"), "Hello 0",
michael@0 61 "The first sum's value is correct.");
michael@0 62
michael@0 63 is(totals.querySelectorAll(".table-chart-summary-label")[1].getAttribute("name"), "label2",
michael@0 64 "The second sum's type is correct.");
michael@0 65 is(totals.querySelectorAll(".table-chart-summary-label")[1].getAttribute("value"), "World 0",
michael@0 66 "The second sum's value is correct.");
michael@0 67
michael@0 68 teardown(aMonitor).then(finish);
michael@0 69 });
michael@0 70 }

mercurial