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

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 /**
     5  * Makes sure Pie 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 pie = Chart.Pie(document, {
    16       data: [],
    17       width: 100,
    18       height: 100
    19     });
    21     let node = pie.node;
    22     let slices = node.querySelectorAll(".pie-chart-slice.chart-colored-blob");
    23     let labels = node.querySelectorAll(".pie-chart-label");
    25     is(slices.length, 1,
    26       "There should be 1 pie chart slice created.");
    27     ok(slices[0].getAttribute("d").match(/\s*M 50,50 L 50\.\d+,2\.5\d* A 47\.5,47\.5 0 1 1 49\.\d+,2\.5\d* Z/),
    28       "The slice has the correct data.");
    30     ok(slices[0].hasAttribute("largest"),
    31       "The slice should be the largest one.");
    32     ok(slices[0].hasAttribute("smallest"),
    33       "The slice should also be the smallest one.");
    34     ok(slices[0].getAttribute("name"), L10N.getStr("pieChart.unavailable"),
    35       "The slice's name is correct.");
    37     is(labels.length, 1,
    38       "There should be 1 pie chart label created.");
    39     is(labels[0].textContent, "Empty",
    40       "The label's text is correct.");
    42     teardown(aMonitor).then(finish);
    43   });
    44 }

mercurial