1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
7 * Test basic search functionality.
8 * Search panel is visible and number of expected results are returned.
11 add_task(async
function () {
12 await
pushPref("devtools.netmonitor.features.search", true);
14 const { tab
, monitor
} = await
initNetMonitor(HTTPS_CUSTOM_GET_URL
, {
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
);
34 const searchButton
= document
.querySelector(".devtools-search-icon");
36 searchButton
.getAttribute("aria-pressed"),
38 "The search toolbar button should not be highlighted"
41 // Open the Search panel
44 // Wait till the panel opens.
45 await
waitForDOMIfNeeded(document
, ".search-panel");
48 searchButton
.getAttribute("aria-pressed"),
50 "The search toolbar button should now be highlighted"
54 .querySelector(".requests-list-blocking-button")
55 .getAttribute("aria-pressed"),
57 "The block toolbar button should not be highlighted"
61 .querySelector(".devtools-http-custom-request-icon")
62 .getAttribute("aria-pressed"),
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(
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,
85 EventUtils
.sendMouseEvent(
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
);