Bug 1924993 - [devtools] Debugger tests wait before typing in conditional panel r...
[gecko.git] / devtools / client / netmonitor / test / browser_net_basic-search.js
blob0395e90e54e3ae6575664ed8116610047c7c0ea3
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
4 "use strict";
6 /**
7 * Test basic search functionality.
8 * Search panel is visible and number of expected results are returned.
9 */
11 add_task(async function () {
12 await pushPref("devtools.netmonitor.features.search", true);
14 const { tab, monitor } = await initNetMonitor(HTTPS_CUSTOM_GET_URL, {
15 requestCount: 1,
16 });
17 info("Starting test... ");
19 const { document, store, windowRequire } = monitor.panelWin;
21 // Action should be processed synchronously in tests.
22 const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
23 store.dispatch(Actions.batchEnable(false));
25 // Execute two XHRs (the same URL) and wait till it's finished.
26 const URL = HTTPS_SEARCH_SJS + "?value=test";
27 const wait = waitForNetworkEvents(monitor, 2);
29 await SpecialPowers.spawn(tab.linkedBrowser, [URL], async function (url) {
30 content.wrappedJSObject.performRequests(2, url);
31 });
32 await wait;
34 const searchButton = document.querySelector(".devtools-search-icon");
35 is(
36 searchButton.getAttribute("aria-pressed"),
37 "false",
38 "The search toolbar button should not be highlighted"
41 // Open the Search panel
42 searchButton.click();
44 // Wait till the panel opens.
45 await waitForDOMIfNeeded(document, ".search-panel");
47 is(
48 searchButton.getAttribute("aria-pressed"),
49 "true",
50 "The search toolbar button should now be highlighted"
52 is(
53 document
54 .querySelector(".requests-list-blocking-button")
55 .getAttribute("aria-pressed"),
56 "false",
57 "The block toolbar button should not be highlighted"
59 is(
60 document
61 .querySelector(".devtools-http-custom-request-icon")
62 .getAttribute("aria-pressed"),
63 "false",
64 "The custom request toolbar button should not be highlighted"
67 // Fill Filter input with text and check displayed messages.
68 // The filter should be focused automatically.
69 typeInNetmonitor("test", monitor);
70 EventUtils.synthesizeKey("KEY_Enter");
72 // Wait till there are two resources rendered in the results.
73 await waitForDOMIfNeeded(
74 document,
75 ".search-panel-content .treeRow.resourceRow",
79 // Click on the first resource to expand it
80 AccessibilityUtils.setEnv({
81 // Keyboard users use arrow keys to expand/collapse tree items.
82 // Accessibility is handled on the container level.
83 mustHaveAccessibleRule: false,
84 });
85 EventUtils.sendMouseEvent(
86 { type: "click" },
87 document.querySelector(".search-panel-content .treeRow .treeIcon")
89 AccessibilityUtils.resetEnv();
91 // Check that there is 5 matches.
92 const matches = document.querySelectorAll(
93 ".search-panel-content .treeRow.resultRow"
95 is(matches.length, 5, "There must be 5 matches");
97 await teardown(monitor);
98 });