From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- .../netmonitor/test/browser_net_basic-search.js | 68 ++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 devtools/client/netmonitor/test/browser_net_basic-search.js (limited to 'devtools/client/netmonitor/test/browser_net_basic-search.js') diff --git a/devtools/client/netmonitor/test/browser_net_basic-search.js b/devtools/client/netmonitor/test/browser_net_basic-search.js new file mode 100644 index 0000000000..b7e00fdd5f --- /dev/null +++ b/devtools/client/netmonitor/test/browser_net_basic-search.js @@ -0,0 +1,68 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +/** + * Test basic search functionality. + * Search panel is visible and number of expected results are returned. + */ + +add_task(async function () { + await pushPref("devtools.netmonitor.features.search", true); + + const { tab, monitor } = await initNetMonitor(HTTPS_CUSTOM_GET_URL, { + requestCount: 1, + }); + info("Starting test... "); + + const { document, store, windowRequire } = monitor.panelWin; + + // Action should be processed synchronously in tests. + const Actions = windowRequire("devtools/client/netmonitor/src/actions/index"); + store.dispatch(Actions.batchEnable(false)); + + // Execute two XHRs (the same URL) and wait till it's finished. + const URL = HTTPS_SEARCH_SJS + "?value=test"; + const wait = waitForNetworkEvents(monitor, 2); + + await SpecialPowers.spawn(tab.linkedBrowser, [URL], async function (url) { + content.wrappedJSObject.performRequests(2, url); + }); + await wait; + + // Open the Search panel + store.dispatch(Actions.openSearch()); + + // Fill Filter input with text and check displayed messages. + // The filter should be focused automatically. + typeInNetmonitor("test", monitor); + EventUtils.synthesizeKey("KEY_Enter"); + + // Wait till there are two resources rendered in the results. + await waitForDOMIfNeeded( + document, + ".search-panel-content .treeRow.resourceRow", + 2 + ); + + // Click on the first resource to expand it + AccessibilityUtils.setEnv({ + // Keyboard users use arrow keys to expand/collapse tree items. + // Accessibility is handled on the container level. + mustHaveAccessibleRule: false, + }); + EventUtils.sendMouseEvent( + { type: "click" }, + document.querySelector(".search-panel-content .treeRow .treeIcon") + ); + AccessibilityUtils.resetEnv(); + + // Check that there is 5 matches. + const matches = document.querySelectorAll( + ".search-panel-content .treeRow.resultRow" + ); + is(matches.length, 5, "There must be 5 matches"); + + await teardown(monitor); +}); -- cgit v1.2.3