summaryrefslogtreecommitdiffstats
path: root/devtools/client/webconsole/test/browser/browser_webconsole_network_messages_after_target_switching.js
blob: ac2eb3b925d25b6ea31d15b83f6336208bacc555 (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
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

// Tests that after a target switch, the network details (headers, cookies etc) are available
// when the request message is expanded.

"use strict";

const TEST_FILE = "test-network-request.html";
const TEST_PATH =
  "https://example.com/browser/devtools/client/webconsole/test/browser/";

const TEST_URI = TEST_PATH + TEST_FILE;

pushPref("devtools.webconsole.filter.net", true);
pushPref("devtools.webconsole.filter.netxhr", true);

registerCleanupFunction(async function () {
  await new Promise(resolve => {
    Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, () =>
      resolve()
    );
  });
});

add_task(async function task() {
  info("Add an empty tab and open the console");
  const hud = await openNewTabAndConsole("");

  const onMessageAvailable = waitForMessageByType(hud, TEST_URI, ".network");
  info(`Navigate to ${TEST_URI}`);
  await navigateTo(TEST_URI);
  const { node } = await onMessageAvailable;

  info(`Click on ${TEST_FILE} request`);
  node.querySelector(".url").click();

  info("Wait for the network detail panel to be displayed");
  await waitFor(
    () => node.querySelector(".network-info"),
    "Wait for .network-info to be rendered"
  );

  // Test that headers information is showing
  await waitFor(
    () => node.querySelector("#headers-panel .headers-overview"),
    "Headers overview info is visible"
  );
});