summaryrefslogtreecommitdiffstats
path: root/devtools/client/netmonitor/test/browser_net_html-preview.js
blob: 351009de561a9d83db8a9292b877f7b0224e0eda (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

/**
 * Tests if html responses show and properly populate a "Preview" tab.
 */

add_task(function* () {
  let { tab, monitor } = yield initNetMonitor(CONTENT_TYPE_URL);
  info("Starting test... ");

  let { $, document, EVENTS, NetMonitorView } = monitor.panelWin;
  let { RequestsMenu } = NetMonitorView;

  RequestsMenu.lazyUpdate = false;

  let wait = waitForNetworkEvents(monitor, 6);
  yield ContentTask.spawn(tab.linkedBrowser, {}, function* () {
    content.wrappedJSObject.performRequests();
  });
  yield wait;

  EventUtils.sendMouseEvent({ type: "mousedown" },
    document.getElementById("details-pane-toggle"));

  is($("#event-details-pane").selectedIndex, 0,
    "The first tab in the details pane should be selected.");
  is($("#preview-tab").hidden, true,
    "The preview tab should be hidden for non html responses.");
  is($("#preview-tabpanel").hidden, false,
    "The preview tabpanel is not hidden for non html responses.");

  RequestsMenu.selectedIndex = 4;
  NetMonitorView.toggleDetailsPane({ visible: true, animated: false }, 6);

  is($("#event-details-pane").selectedIndex, 6,
    "The sixth tab in the details pane should be selected.");
  is($("#preview-tab").hidden, false,
    "The preview tab should be visible now.");

  yield monitor.panelWin.once(EVENTS.RESPONSE_HTML_PREVIEW_DISPLAYED);
  let iframe = $("#response-preview");
  ok(iframe,
    "There should be a response preview iframe available.");
  ok(iframe.contentDocument,
    "The iframe's content document should be available.");
  is(iframe.contentDocument.querySelector("blink").textContent, "Not Found",
    "The iframe's content document should be loaded and correct.");

  RequestsMenu.selectedIndex = 5;

  is($("#event-details-pane").selectedIndex, 0,
    "The first tab in the details pane should be selected again.");
  is($("#preview-tab").hidden, true,
    "The preview tab should be hidden again for non html responses.");
  is($("#preview-tabpanel").hidden, false,
    "The preview tabpanel is not hidden again for non html responses.");

  yield teardown(monitor);
});