summaryrefslogtreecommitdiffstats
path: root/devtools/client/netmonitor/test/browser_net_filter-value-preserved.js
blob: 59eccc25f748000d5db620728bb62d8f1dab0344 (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
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

/**
 * Test that filter input keeps its value when host or panel changes
 */

add_task(async function () {
  const { monitor } = await initNetMonitor(FILTERING_URL, { requestCount: 1 });
  const { document, store, windowRequire } = monitor.panelWin;
  const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");

  store.dispatch(Actions.batchEnable(false));

  info("Starting test... ");

  const toolbars = document.querySelector("#netmonitor-toolbar-container");
  let input = toolbars.querySelector(".devtools-filterinput");
  input.value = "hello";

  await monitor.toolbox.switchHost("right");
  await waitForTick();

  is(
    toolbars.querySelectorAll(".devtools-toolbar").length,
    2,
    "Should be in 2 toolbar mode"
  );

  input = toolbars.querySelector(".devtools-filterinput");
  is(
    input.value,
    "hello",
    "Value should be preserved after switching to right host"
  );

  await monitor.toolbox.switchHost("bottom");

  input = toolbars.querySelector(".devtools-filterinput");
  is(
    input.value,
    "hello",
    "Value should be preserved after switching to bottom host"
  );

  await monitor.toolbox.selectTool("inspector");
  await monitor.toolbox.selectTool("netmonitor");

  input = toolbars.querySelector(".devtools-filterinput");
  is(input.value, "hello", "Value should be preserved after switching tools");

  await teardown(monitor);
});