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.

michael@0 1 /* Any copyright is dedicated to the Public Domain.
michael@0 2 http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0 3
michael@0 4 /**
michael@0 5 * Tests if the network monitor panes collapse properly.
michael@0 6 */
michael@0 7
michael@0 8 function test() {
michael@0 9 initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => {
michael@0 10 info("Starting test... ");
michael@0 11
michael@0 12 let { document, Prefs, NetMonitorView } = aMonitor.panelWin;
michael@0 13 let detailsPane = document.getElementById("details-pane");
michael@0 14 let detailsPaneToggleButton = document.getElementById("details-pane-toggle");
michael@0 15
michael@0 16 ok(detailsPane.hasAttribute("pane-collapsed") &&
michael@0 17 detailsPaneToggleButton.hasAttribute("pane-collapsed"),
michael@0 18 "The details pane should initially be hidden.");
michael@0 19
michael@0 20 NetMonitorView.toggleDetailsPane({ visible: true, animated: false });
michael@0 21
michael@0 22 let width = ~~(detailsPane.getAttribute("width"));
michael@0 23 is(width, Prefs.networkDetailsWidth,
michael@0 24 "The details pane has an incorrect width.");
michael@0 25 is(detailsPane.style.marginLeft, "0px",
michael@0 26 "The details pane has an incorrect left margin.");
michael@0 27 is(detailsPane.style.marginRight, "0px",
michael@0 28 "The details pane has an incorrect right margin.");
michael@0 29 ok(!detailsPane.hasAttribute("animated"),
michael@0 30 "The details pane has an incorrect animated attribute.");
michael@0 31 ok(!detailsPane.hasAttribute("pane-collapsed") &&
michael@0 32 !detailsPaneToggleButton.hasAttribute("pane-collapsed"),
michael@0 33 "The details pane should at this point be visible.");
michael@0 34
michael@0 35 NetMonitorView.toggleDetailsPane({ visible: false, animated: true });
michael@0 36
michael@0 37 let margin = -(width + 1) + "px";
michael@0 38 is(width, Prefs.networkDetailsWidth,
michael@0 39 "The details pane has an incorrect width after collapsing.");
michael@0 40 is(detailsPane.style.marginLeft, margin,
michael@0 41 "The details pane has an incorrect left margin after collapsing.");
michael@0 42 is(detailsPane.style.marginRight, margin,
michael@0 43 "The details pane has an incorrect right margin after collapsing.");
michael@0 44 ok(detailsPane.hasAttribute("animated"),
michael@0 45 "The details pane has an incorrect attribute after an animated collapsing.");
michael@0 46 ok(detailsPane.hasAttribute("pane-collapsed") &&
michael@0 47 detailsPaneToggleButton.hasAttribute("pane-collapsed"),
michael@0 48 "The details pane should not be visible after collapsing.");
michael@0 49
michael@0 50 NetMonitorView.toggleDetailsPane({ visible: true, animated: false });
michael@0 51
michael@0 52 is(width, Prefs.networkDetailsWidth,
michael@0 53 "The details pane has an incorrect width after uncollapsing.");
michael@0 54 is(detailsPane.style.marginLeft, "0px",
michael@0 55 "The details pane has an incorrect left margin after uncollapsing.");
michael@0 56 is(detailsPane.style.marginRight, "0px",
michael@0 57 "The details pane has an incorrect right margin after uncollapsing.");
michael@0 58 ok(!detailsPane.hasAttribute("animated"),
michael@0 59 "The details pane has an incorrect attribute after an unanimated uncollapsing.");
michael@0 60 ok(!detailsPane.hasAttribute("pane-collapsed") &&
michael@0 61 !detailsPaneToggleButton.hasAttribute("pane-collapsed"),
michael@0 62 "The details pane should be visible again after uncollapsing.");
michael@0 63
michael@0 64 teardown(aMonitor).then(finish);
michael@0 65 });
michael@0 66 }

mercurial