summaryrefslogtreecommitdiffstats
path: root/devtools/client/webconsole/test/browser/browser_webconsole_network_reset_filter.js
blob: 52daeec7a1ad017765d2451e33acbbc5cab60c7d (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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

// Tests that network log messages bring up the network panel and select the
// right request even if it was previously filtered off.

"use strict";

const TEST_PATH =
  "https://example.com/browser/devtools/client/webconsole/" + "test/browser/";
const TEST_URI = "data:text/html;charset=utf8,<!DOCTYPE html><p>test file URI";

add_task(async function () {
  await pushPref("devtools.webconsole.filter.net", true);

  const toolbox = await openNewTabAndToolbox(TEST_URI, "webconsole");
  const hud = toolbox.getCurrentPanel().hud;

  const onMessages = waitForMessagesByType({
    hud,
    messages: [
      {
        text: "running network console logging tests",
        typeSelector: ".console-api",
      },
      {
        text: "test-network.html",
        typeSelector: ".network",
      },
      {
        text: "testscript.js",
        typeSelector: ".network",
      },
    ],
  });

  info("Wait for document to load");
  await navigateTo(TEST_PATH + "test-network.html");

  info("Wait for expected messages to appear");
  await onMessages;

  const url = TEST_PATH + "testscript.js?foo";
  // The url as it appears in the webconsole, without the GET parameters
  const shortUrl = TEST_PATH + "testscript.js";

  info("Open the testscript.js request in the network monitor");
  await openMessageInNetmonitor(toolbox, hud, url, shortUrl);

  const netmonitor = toolbox.getCurrentPanel();

  info(
    "Wait for the netmonitor headers panel to appear as it spawn RDP requests"
  );
  await waitUntil(() =>
    netmonitor.panelWin.document.querySelector(
      "#headers-panel .headers-overview"
    )
  );

  info("Filter out the current request");
  const { store, windowRequire } = netmonitor.panelWin;
  const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
  store.dispatch(Actions.toggleRequestFilterType("js"));

  info("Select back the webconsole");
  await toolbox.selectTool("webconsole");
  is(toolbox.currentToolId, "webconsole", "Web console was selected");

  info("Open the testscript.js request again in the network monitor");
  await openMessageInNetmonitor(toolbox, hud, url, shortUrl);

  info(
    "Wait for the netmonitor headers panel to appear as it spawn RDP requests"
  );
  await waitUntil(() =>
    netmonitor.panelWin.document.querySelector(
      "#headers-panel .headers-overview"
    )
  );
});