browser/devtools/netmonitor/test/browser_net_pane-collapse.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:cf58185c8a34
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
3
4 /**
5 * Tests if the network monitor panes collapse properly.
6 */
7
8 function test() {
9 initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => {
10 info("Starting test... ");
11
12 let { document, Prefs, NetMonitorView } = aMonitor.panelWin;
13 let detailsPane = document.getElementById("details-pane");
14 let detailsPaneToggleButton = document.getElementById("details-pane-toggle");
15
16 ok(detailsPane.hasAttribute("pane-collapsed") &&
17 detailsPaneToggleButton.hasAttribute("pane-collapsed"),
18 "The details pane should initially be hidden.");
19
20 NetMonitorView.toggleDetailsPane({ visible: true, animated: false });
21
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.");
34
35 NetMonitorView.toggleDetailsPane({ visible: false, animated: true });
36
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.");
49
50 NetMonitorView.toggleDetailsPane({ visible: true, animated: false });
51
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.");
63
64 teardown(aMonitor).then(finish);
65 });
66 }

mercurial