1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/netmonitor/test/browser_net_html-preview.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,62 @@ 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 html responses show and properly populate a "Preview" tab. 1.9 + */ 1.10 + 1.11 +function test() { 1.12 + initNetMonitor(CONTENT_TYPE_URL).then(([aTab, aDebuggee, aMonitor]) => { 1.13 + info("Starting test... "); 1.14 + 1.15 + let { $, document, EVENTS, NetMonitorView } = aMonitor.panelWin; 1.16 + let { RequestsMenu } = NetMonitorView; 1.17 + 1.18 + RequestsMenu.lazyUpdate = false; 1.19 + 1.20 + waitForNetworkEvents(aMonitor, 6).then(() => { 1.21 + EventUtils.sendMouseEvent({ type: "mousedown" }, 1.22 + document.getElementById("details-pane-toggle")); 1.23 + 1.24 + is($("#event-details-pane").selectedIndex, 0, 1.25 + "The first tab in the details pane should be selected."); 1.26 + is($("#preview-tab").hidden, true, 1.27 + "The preview tab should be hidden for non html responses."); 1.28 + is($("#preview-tabpanel").hidden, true, 1.29 + "The preview tabpanel should be hidden for non html responses."); 1.30 + 1.31 + RequestsMenu.selectedIndex = 4; 1.32 + NetMonitorView.toggleDetailsPane({ visible: true, animated: false }, 5); 1.33 + 1.34 + is($("#event-details-pane").selectedIndex, 5, 1.35 + "The fifth tab in the details pane should be selected."); 1.36 + is($("#preview-tab").hidden, false, 1.37 + "The preview tab should be visible now."); 1.38 + is($("#preview-tabpanel").hidden, false, 1.39 + "The preview tabpanel should be visible now."); 1.40 + 1.41 + waitFor(aMonitor.panelWin, EVENTS.RESPONSE_HTML_PREVIEW_DISPLAYED).then(() => { 1.42 + let iframe = $("#response-preview"); 1.43 + ok(iframe, 1.44 + "There should be a response preview iframe available."); 1.45 + ok(iframe.contentDocument, 1.46 + "The iframe's content document should be available."); 1.47 + is(iframe.contentDocument.querySelector("blink").textContent, "Not Found", 1.48 + "The iframe's content document should be loaded and correct."); 1.49 + 1.50 + RequestsMenu.selectedIndex = 5; 1.51 + 1.52 + is($("#event-details-pane").selectedIndex, 0, 1.53 + "The first tab in the details pane should be selected again."); 1.54 + is($("#preview-tab").hidden, true, 1.55 + "The preview tab should be hidden again for non html responses."); 1.56 + is($("#preview-tabpanel").hidden, true, 1.57 + "The preview tabpanel should be hidden again for non html responses."); 1.58 + 1.59 + teardown(aMonitor).then(finish); 1.60 + }); 1.61 + }); 1.62 + 1.63 + aDebuggee.performRequests(); 1.64 + }); 1.65 +}