michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: /** michael@0: * Tests if toggling the details pane works as expected. michael@0: */ michael@0: michael@0: function test() { michael@0: initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => { michael@0: info("Starting test... "); michael@0: michael@0: let { document, NetMonitorView } = aMonitor.panelWin; michael@0: let { RequestsMenu } = NetMonitorView; michael@0: michael@0: RequestsMenu.lazyUpdate = false; michael@0: michael@0: is(document.querySelector("#details-pane-toggle") michael@0: .hasAttribute("disabled"), true, michael@0: "The pane toggle button should be disabled when the frontend is opened."); michael@0: is(document.querySelector("#details-pane-toggle") michael@0: .hasAttribute("pane-collapsed"), true, michael@0: "The pane toggle button should indicate that the details pane is " + michael@0: "collapsed when the frontend is opened."); michael@0: is(NetMonitorView.detailsPaneHidden, true, michael@0: "The details pane should be hidden when the frontend is opened."); michael@0: is(RequestsMenu.selectedItem, null, michael@0: "There should be no selected item in the requests menu."); michael@0: michael@0: aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.NETWORK_EVENT, () => { michael@0: is(document.querySelector("#details-pane-toggle") michael@0: .hasAttribute("disabled"), false, michael@0: "The pane toggle button should be enabled after the first request."); michael@0: is(document.querySelector("#details-pane-toggle") michael@0: .hasAttribute("pane-collapsed"), true, michael@0: "The pane toggle button should still indicate that the details pane is " + michael@0: "collapsed after the first request."); michael@0: is(NetMonitorView.detailsPaneHidden, true, michael@0: "The details pane should still be hidden after the first request."); michael@0: is(RequestsMenu.selectedItem, null, michael@0: "There should still be no selected item in the requests menu."); michael@0: michael@0: EventUtils.sendMouseEvent({ type: "mousedown" }, michael@0: document.getElementById("details-pane-toggle")); michael@0: michael@0: is(document.querySelector("#details-pane-toggle") michael@0: .hasAttribute("disabled"), false, michael@0: "The pane toggle button should still be enabled after being pressed."); michael@0: is(document.querySelector("#details-pane-toggle") michael@0: .hasAttribute("pane-collapsed"), false, michael@0: "The pane toggle button should now indicate that the details pane is " + michael@0: "not collapsed anymore after being pressed."); michael@0: is(NetMonitorView.detailsPaneHidden, false, michael@0: "The details pane should not be hidden after toggle button was pressed."); michael@0: isnot(RequestsMenu.selectedItem, null, michael@0: "There should be a selected item in the requests menu."); michael@0: is(RequestsMenu.selectedIndex, 0, michael@0: "The first item should be selected in the requests menu."); michael@0: michael@0: EventUtils.sendMouseEvent({ type: "mousedown" }, michael@0: document.getElementById("details-pane-toggle")); michael@0: michael@0: is(document.querySelector("#details-pane-toggle") michael@0: .hasAttribute("disabled"), false, michael@0: "The pane toggle button should still be enabled after being pressed again."); michael@0: is(document.querySelector("#details-pane-toggle") michael@0: .hasAttribute("pane-collapsed"), true, michael@0: "The pane toggle button should now indicate that the details pane is " + michael@0: "collapsed after being pressed again."); michael@0: is(NetMonitorView.detailsPaneHidden, true, michael@0: "The details pane should now be hidden after the toggle button was pressed again."); michael@0: is(RequestsMenu.selectedItem, null, michael@0: "There should now be no selected item in the requests menu."); michael@0: michael@0: teardown(aMonitor).then(finish); michael@0: }); michael@0: michael@0: aDebuggee.location.reload(); michael@0: }); michael@0: }