browser/devtools/netmonitor/test/browser_net_pane-collapse.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  * Tests if the network monitor panes collapse properly.
     6  */
     8 function test() {
     9   initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => {
    10     info("Starting test... ");
    12     let { document, Prefs, NetMonitorView } = aMonitor.panelWin;
    13     let detailsPane = document.getElementById("details-pane");
    14     let detailsPaneToggleButton = document.getElementById("details-pane-toggle");
    16     ok(detailsPane.hasAttribute("pane-collapsed") &&
    17        detailsPaneToggleButton.hasAttribute("pane-collapsed"),
    18       "The details pane should initially be hidden.");
    20     NetMonitorView.toggleDetailsPane({ visible: true, animated: false });
    22     let width = ~~(detailsPane.getAttribute("width"));
    23     is(width, Prefs.networkDetailsWidth,
    24       "The details pane has an incorrect width.");
    25     is(detailsPane.style.marginLeft, "0px",
    26       "The details pane has an incorrect left margin.");
    27     is(detailsPane.style.marginRight, "0px",
    28       "The details pane has an incorrect right margin.");
    29     ok(!detailsPane.hasAttribute("animated"),
    30       "The details pane has an incorrect animated attribute.");
    31     ok(!detailsPane.hasAttribute("pane-collapsed") &&
    32        !detailsPaneToggleButton.hasAttribute("pane-collapsed"),
    33       "The details pane should at this point be visible.");
    35     NetMonitorView.toggleDetailsPane({ visible: false, animated: true });
    37     let margin = -(width + 1) + "px";
    38     is(width, Prefs.networkDetailsWidth,
    39       "The details pane has an incorrect width after collapsing.");
    40     is(detailsPane.style.marginLeft, margin,
    41       "The details pane has an incorrect left margin after collapsing.");
    42     is(detailsPane.style.marginRight, margin,
    43       "The details pane has an incorrect right margin after collapsing.");
    44     ok(detailsPane.hasAttribute("animated"),
    45       "The details pane has an incorrect attribute after an animated collapsing.");
    46     ok(detailsPane.hasAttribute("pane-collapsed") &&
    47        detailsPaneToggleButton.hasAttribute("pane-collapsed"),
    48       "The details pane should not be visible after collapsing.");
    50     NetMonitorView.toggleDetailsPane({ visible: true, animated: false });
    52     is(width, Prefs.networkDetailsWidth,
    53       "The details pane has an incorrect width after uncollapsing.");
    54     is(detailsPane.style.marginLeft, "0px",
    55       "The details pane has an incorrect left margin after uncollapsing.");
    56     is(detailsPane.style.marginRight, "0px",
    57       "The details pane has an incorrect right margin after uncollapsing.");
    58     ok(!detailsPane.hasAttribute("animated"),
    59       "The details pane has an incorrect attribute after an unanimated uncollapsing.");
    60     ok(!detailsPane.hasAttribute("pane-collapsed") &&
    61        !detailsPaneToggleButton.hasAttribute("pane-collapsed"),
    62       "The details pane should be visible again after uncollapsing.");
    64     teardown(aMonitor).then(finish);
    65   });
    66 }

mercurial