browser/devtools/netmonitor/test/browser_net_charts-07.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.

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

mercurial