browser/devtools/netmonitor/test/browser_net_charts-02.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 Pie Charts have the right internal structure when
     6  * initialized with empty data.
     7  */
     9 function test() {
    10   initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => {
    11     info("Starting test... ");
    13     let { document, L10N, Chart } = aMonitor.panelWin;
    14     let container = document.createElement("box");
    16     let pie = Chart.Pie(document, {
    17       data: null,
    18       width: 100,
    19       height: 100
    20     });
    22     let node = pie.node;
    23     let slices = node.querySelectorAll(".pie-chart-slice.chart-colored-blob");
    24     let labels = node.querySelectorAll(".pie-chart-label");
    26     ok(node.classList.contains("pie-chart-container") &&
    27        node.classList.contains("generic-chart-container"),
    28       "A pie chart container was created successfully.");
    30     is(slices.length, 1,
    31       "There should be 1 pie chart slice created.");
    32     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/),
    33       "The first slice has the correct data.");
    35     ok(slices[0].hasAttribute("largest"),
    36       "The first slice should be the largest one.");
    37     ok(slices[0].hasAttribute("smallest"),
    38       "The first slice should also be the smallest one.");
    39     ok(slices[0].getAttribute("name"), L10N.getStr("pieChart.loading"),
    40       "The first slice's name is correct.");
    42     is(labels.length, 1,
    43       "There should be 1 pie chart label created.");
    44     is(labels[0].textContent, "Loading",
    45       "The first label's text is correct.");
    47     teardown(aMonitor).then(finish);
    48   });
    49 }

mercurial