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 html responses show and properly populate a "Preview" tab. michael@0: */ michael@0: michael@0: function test() { michael@0: initNetMonitor(CONTENT_TYPE_URL).then(([aTab, aDebuggee, aMonitor]) => { michael@0: info("Starting test... "); michael@0: michael@0: let { $, document, EVENTS, NetMonitorView } = aMonitor.panelWin; michael@0: let { RequestsMenu } = NetMonitorView; michael@0: michael@0: RequestsMenu.lazyUpdate = false; michael@0: michael@0: waitForNetworkEvents(aMonitor, 6).then(() => { michael@0: EventUtils.sendMouseEvent({ type: "mousedown" }, michael@0: document.getElementById("details-pane-toggle")); michael@0: michael@0: is($("#event-details-pane").selectedIndex, 0, michael@0: "The first tab in the details pane should be selected."); michael@0: is($("#preview-tab").hidden, true, michael@0: "The preview tab should be hidden for non html responses."); michael@0: is($("#preview-tabpanel").hidden, true, michael@0: "The preview tabpanel should be hidden for non html responses."); michael@0: michael@0: RequestsMenu.selectedIndex = 4; michael@0: NetMonitorView.toggleDetailsPane({ visible: true, animated: false }, 5); michael@0: michael@0: is($("#event-details-pane").selectedIndex, 5, michael@0: "The fifth tab in the details pane should be selected."); michael@0: is($("#preview-tab").hidden, false, michael@0: "The preview tab should be visible now."); michael@0: is($("#preview-tabpanel").hidden, false, michael@0: "The preview tabpanel should be visible now."); michael@0: michael@0: waitFor(aMonitor.panelWin, EVENTS.RESPONSE_HTML_PREVIEW_DISPLAYED).then(() => { michael@0: let iframe = $("#response-preview"); michael@0: ok(iframe, michael@0: "There should be a response preview iframe available."); michael@0: ok(iframe.contentDocument, michael@0: "The iframe's content document should be available."); michael@0: is(iframe.contentDocument.querySelector("blink").textContent, "Not Found", michael@0: "The iframe's content document should be loaded and correct."); michael@0: michael@0: RequestsMenu.selectedIndex = 5; michael@0: michael@0: is($("#event-details-pane").selectedIndex, 0, michael@0: "The first tab in the details pane should be selected again."); michael@0: is($("#preview-tab").hidden, true, michael@0: "The preview tab should be hidden again for non html responses."); michael@0: is($("#preview-tabpanel").hidden, true, michael@0: "The preview tabpanel should be hidden again for non html responses."); michael@0: michael@0: teardown(aMonitor).then(finish); michael@0: }); michael@0: }); michael@0: michael@0: aDebuggee.performRequests(); michael@0: }); michael@0: }