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

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

     1 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 /**
     5  * Makes sure Pie+Table Charts have the right internal structure.
     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 chart = Chart.PieTable(document, {
    16       title: "Table title",
    17       data: [{
    18         size: 1,
    19         label: 11.1
    20       }, {
    21         size: 2,
    22         label: 12.2
    23       }, {
    24         size: 3,
    25         label: 13.3
    26       }],
    27       strings: {
    28         label2: (value, index) => value + ["foo", "bar", "baz"][index]
    29       },
    30       totals: {
    31         size: value => "Hello " + L10N.numberWithDecimals(value, 2),
    32         label: value => "World " + L10N.numberWithDecimals(value, 2)
    33       }
    34     });
    36     ok(chart.pie, "The pie chart proxy is accessible.");
    37     ok(chart.table, "The table chart proxy is accessible.");
    39     let node = chart.node;
    40     let slices = node.querySelectorAll(".pie-chart-slice");
    41     let rows = node.querySelectorAll(".table-chart-row");
    42     let sums = node.querySelectorAll(".table-chart-summary-label");
    44     ok(node.classList.contains("pie-table-chart-container"),
    45       "A pie+table chart container was created successfully.");
    47     ok(node.querySelector(".table-chart-title"),
    48       "A title node was created successfully.");
    49     ok(node.querySelector(".pie-chart-container"),
    50       "A pie chart was created successfully.");
    51     ok(node.querySelector(".table-chart-container"),
    52       "A table chart was created successfully.");
    54     is(rows.length, 3,
    55       "There should be 3 pie chart slices created.");
    56     is(rows.length, 3,
    57       "There should be 3 table chart rows created.");
    58     is(sums.length, 2,
    59       "There should be 2 total summaries created.");
    61     teardown(aMonitor).then(finish);
    62   });
    63 }

mercurial