1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/netmonitor/test/browser_net_pane-toggle.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,79 @@ 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 toggling the details pane works as expected. 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, NetMonitorView } = aMonitor.panelWin; 1.16 + let { RequestsMenu } = NetMonitorView; 1.17 + 1.18 + RequestsMenu.lazyUpdate = false; 1.19 + 1.20 + is(document.querySelector("#details-pane-toggle") 1.21 + .hasAttribute("disabled"), true, 1.22 + "The pane toggle button should be disabled when the frontend is opened."); 1.23 + is(document.querySelector("#details-pane-toggle") 1.24 + .hasAttribute("pane-collapsed"), true, 1.25 + "The pane toggle button should indicate that the details pane is " + 1.26 + "collapsed when the frontend is opened."); 1.27 + is(NetMonitorView.detailsPaneHidden, true, 1.28 + "The details pane should be hidden when the frontend is opened."); 1.29 + is(RequestsMenu.selectedItem, null, 1.30 + "There should be no selected item in the requests menu."); 1.31 + 1.32 + aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.NETWORK_EVENT, () => { 1.33 + is(document.querySelector("#details-pane-toggle") 1.34 + .hasAttribute("disabled"), false, 1.35 + "The pane toggle button should be enabled after the first request."); 1.36 + is(document.querySelector("#details-pane-toggle") 1.37 + .hasAttribute("pane-collapsed"), true, 1.38 + "The pane toggle button should still indicate that the details pane is " + 1.39 + "collapsed after the first request."); 1.40 + is(NetMonitorView.detailsPaneHidden, true, 1.41 + "The details pane should still be hidden after the first request."); 1.42 + is(RequestsMenu.selectedItem, null, 1.43 + "There should still be no selected item in the requests menu."); 1.44 + 1.45 + EventUtils.sendMouseEvent({ type: "mousedown" }, 1.46 + document.getElementById("details-pane-toggle")); 1.47 + 1.48 + is(document.querySelector("#details-pane-toggle") 1.49 + .hasAttribute("disabled"), false, 1.50 + "The pane toggle button should still be enabled after being pressed."); 1.51 + is(document.querySelector("#details-pane-toggle") 1.52 + .hasAttribute("pane-collapsed"), false, 1.53 + "The pane toggle button should now indicate that the details pane is " + 1.54 + "not collapsed anymore after being pressed."); 1.55 + is(NetMonitorView.detailsPaneHidden, false, 1.56 + "The details pane should not be hidden after toggle button was pressed."); 1.57 + isnot(RequestsMenu.selectedItem, null, 1.58 + "There should be a selected item in the requests menu."); 1.59 + is(RequestsMenu.selectedIndex, 0, 1.60 + "The first item should be selected in the requests menu."); 1.61 + 1.62 + EventUtils.sendMouseEvent({ type: "mousedown" }, 1.63 + document.getElementById("details-pane-toggle")); 1.64 + 1.65 + is(document.querySelector("#details-pane-toggle") 1.66 + .hasAttribute("disabled"), false, 1.67 + "The pane toggle button should still be enabled after being pressed again."); 1.68 + is(document.querySelector("#details-pane-toggle") 1.69 + .hasAttribute("pane-collapsed"), true, 1.70 + "The pane toggle button should now indicate that the details pane is " + 1.71 + "collapsed after being pressed again."); 1.72 + is(NetMonitorView.detailsPaneHidden, true, 1.73 + "The details pane should now be hidden after the toggle button was pressed again."); 1.74 + is(RequestsMenu.selectedItem, null, 1.75 + "There should now be no selected item in the requests menu."); 1.76 + 1.77 + teardown(aMonitor).then(finish); 1.78 + }); 1.79 + 1.80 + aDebuggee.location.reload(); 1.81 + }); 1.82 +}