|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Tests if html responses show and properly populate a "Preview" tab. |
|
6 */ |
|
7 |
|
8 function test() { |
|
9 initNetMonitor(CONTENT_TYPE_URL).then(([aTab, aDebuggee, aMonitor]) => { |
|
10 info("Starting test... "); |
|
11 |
|
12 let { $, document, EVENTS, NetMonitorView } = aMonitor.panelWin; |
|
13 let { RequestsMenu } = NetMonitorView; |
|
14 |
|
15 RequestsMenu.lazyUpdate = false; |
|
16 |
|
17 waitForNetworkEvents(aMonitor, 6).then(() => { |
|
18 EventUtils.sendMouseEvent({ type: "mousedown" }, |
|
19 document.getElementById("details-pane-toggle")); |
|
20 |
|
21 is($("#event-details-pane").selectedIndex, 0, |
|
22 "The first tab in the details pane should be selected."); |
|
23 is($("#preview-tab").hidden, true, |
|
24 "The preview tab should be hidden for non html responses."); |
|
25 is($("#preview-tabpanel").hidden, true, |
|
26 "The preview tabpanel should be hidden for non html responses."); |
|
27 |
|
28 RequestsMenu.selectedIndex = 4; |
|
29 NetMonitorView.toggleDetailsPane({ visible: true, animated: false }, 5); |
|
30 |
|
31 is($("#event-details-pane").selectedIndex, 5, |
|
32 "The fifth tab in the details pane should be selected."); |
|
33 is($("#preview-tab").hidden, false, |
|
34 "The preview tab should be visible now."); |
|
35 is($("#preview-tabpanel").hidden, false, |
|
36 "The preview tabpanel should be visible now."); |
|
37 |
|
38 waitFor(aMonitor.panelWin, EVENTS.RESPONSE_HTML_PREVIEW_DISPLAYED).then(() => { |
|
39 let iframe = $("#response-preview"); |
|
40 ok(iframe, |
|
41 "There should be a response preview iframe available."); |
|
42 ok(iframe.contentDocument, |
|
43 "The iframe's content document should be available."); |
|
44 is(iframe.contentDocument.querySelector("blink").textContent, "Not Found", |
|
45 "The iframe's content document should be loaded and correct."); |
|
46 |
|
47 RequestsMenu.selectedIndex = 5; |
|
48 |
|
49 is($("#event-details-pane").selectedIndex, 0, |
|
50 "The first tab in the details pane should be selected again."); |
|
51 is($("#preview-tab").hidden, true, |
|
52 "The preview tab should be hidden again for non html responses."); |
|
53 is($("#preview-tabpanel").hidden, true, |
|
54 "The preview tabpanel should be hidden again for non html responses."); |
|
55 |
|
56 teardown(aMonitor).then(finish); |
|
57 }); |
|
58 }); |
|
59 |
|
60 aDebuggee.performRequests(); |
|
61 }); |
|
62 } |