1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/netmonitor/test/browser_net_pane-collapse.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,66 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +/** 1.8 + * Tests if the network monitor panes collapse properly. 1.9 + */ 1.10 + 1.11 +function test() { 1.12 + initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => { 1.13 + info("Starting test... "); 1.14 + 1.15 + let { document, Prefs, NetMonitorView } = aMonitor.panelWin; 1.16 + let detailsPane = document.getElementById("details-pane"); 1.17 + let detailsPaneToggleButton = document.getElementById("details-pane-toggle"); 1.18 + 1.19 + ok(detailsPane.hasAttribute("pane-collapsed") && 1.20 + detailsPaneToggleButton.hasAttribute("pane-collapsed"), 1.21 + "The details pane should initially be hidden."); 1.22 + 1.23 + NetMonitorView.toggleDetailsPane({ visible: true, animated: false }); 1.24 + 1.25 + let width = ~~(detailsPane.getAttribute("width")); 1.26 + is(width, Prefs.networkDetailsWidth, 1.27 + "The details pane has an incorrect width."); 1.28 + is(detailsPane.style.marginLeft, "0px", 1.29 + "The details pane has an incorrect left margin."); 1.30 + is(detailsPane.style.marginRight, "0px", 1.31 + "The details pane has an incorrect right margin."); 1.32 + ok(!detailsPane.hasAttribute("animated"), 1.33 + "The details pane has an incorrect animated attribute."); 1.34 + ok(!detailsPane.hasAttribute("pane-collapsed") && 1.35 + !detailsPaneToggleButton.hasAttribute("pane-collapsed"), 1.36 + "The details pane should at this point be visible."); 1.37 + 1.38 + NetMonitorView.toggleDetailsPane({ visible: false, animated: true }); 1.39 + 1.40 + let margin = -(width + 1) + "px"; 1.41 + is(width, Prefs.networkDetailsWidth, 1.42 + "The details pane has an incorrect width after collapsing."); 1.43 + is(detailsPane.style.marginLeft, margin, 1.44 + "The details pane has an incorrect left margin after collapsing."); 1.45 + is(detailsPane.style.marginRight, margin, 1.46 + "The details pane has an incorrect right margin after collapsing."); 1.47 + ok(detailsPane.hasAttribute("animated"), 1.48 + "The details pane has an incorrect attribute after an animated collapsing."); 1.49 + ok(detailsPane.hasAttribute("pane-collapsed") && 1.50 + detailsPaneToggleButton.hasAttribute("pane-collapsed"), 1.51 + "The details pane should not be visible after collapsing."); 1.52 + 1.53 + NetMonitorView.toggleDetailsPane({ visible: true, animated: false }); 1.54 + 1.55 + is(width, Prefs.networkDetailsWidth, 1.56 + "The details pane has an incorrect width after uncollapsing."); 1.57 + is(detailsPane.style.marginLeft, "0px", 1.58 + "The details pane has an incorrect left margin after uncollapsing."); 1.59 + is(detailsPane.style.marginRight, "0px", 1.60 + "The details pane has an incorrect right margin after uncollapsing."); 1.61 + ok(!detailsPane.hasAttribute("animated"), 1.62 + "The details pane has an incorrect attribute after an unanimated uncollapsing."); 1.63 + ok(!detailsPane.hasAttribute("pane-collapsed") && 1.64 + !detailsPaneToggleButton.hasAttribute("pane-collapsed"), 1.65 + "The details pane should be visible again after uncollapsing."); 1.66 + 1.67 + teardown(aMonitor).then(finish); 1.68 + }); 1.69 +}