diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /devtools/client/inspector/test/browser_inspector_search-05.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/client/inspector/test/browser_inspector_search-05.js')
-rw-r--r-- | devtools/client/inspector/test/browser_inspector_search-05.js | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/devtools/client/inspector/test/browser_inspector_search-05.js b/devtools/client/inspector/test/browser_inspector_search-05.js new file mode 100644 index 0000000000..7be5c66d56 --- /dev/null +++ b/devtools/client/inspector/test/browser_inspector_search-05.js @@ -0,0 +1,107 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + +// Testing that when search results contain suggestions for nodes in other +// frames, selecting these suggestions actually selects the right nodes. + +requestLongerTimeout(2); + +add_task(async function () { + const { inspector } = await openInspectorForURL( + `${URL_ROOT_ORG_SSL}doc_inspector_search-iframes.html` + ); + + info("Focus the search box"); + await focusSearchBoxUsingShortcut(inspector.panelWin); + + info("Enter # to search for all ids"); + let processingDone = once(inspector.searchSuggestions, "processing-done"); + EventUtils.synthesizeKey("#", {}, inspector.panelWin); + + info("Wait for search query to complete"); + await processingDone; + + info("Press tab to fill the search input with the first suggestion"); + processingDone = once(inspector.searchSuggestions, "processing-done"); + EventUtils.synthesizeKey("VK_TAB", {}, inspector.panelWin); + await processingDone; + + info("Press enter and expect a new selection"); + let onSelect = inspector.once("inspector-updated"); + EventUtils.synthesizeKey("VK_RETURN", {}, inspector.panelWin); + await onSelect; + + await checkCorrectButton(inspector, ["#iframe-1"]); + + info("Press enter to cycle through multiple nodes matching this suggestion"); + onSelect = inspector.once("inspector-updated"); + EventUtils.synthesizeKey("VK_RETURN", {}, inspector.panelWin); + await onSelect; + + await checkCorrectButton(inspector, ["#iframe-2"]); + + info("Press enter to cycle through multiple nodes matching this suggestion"); + onSelect = inspector.once("inspector-updated"); + EventUtils.synthesizeKey("VK_RETURN", {}, inspector.panelWin); + await onSelect; + + await checkCorrectButton(inspector, ["#iframe-3"]); + + info("Press enter to cycle through multiple nodes matching this suggestion"); + onSelect = inspector.once("inspector-updated"); + EventUtils.synthesizeKey("VK_RETURN", {}, inspector.panelWin); + await onSelect; + + await checkCorrectButton(inspector, ["#iframe-3", "#iframe-4"]); + + info("Press enter to cycle through multiple nodes matching this suggestion"); + onSelect = inspector.once("inspector-updated"); + EventUtils.synthesizeKey("VK_RETURN", {}, inspector.panelWin); + await onSelect; + + await checkCorrectButton(inspector, ["#iframe-1"]); +}); + +const checkCorrectButton = async function (inspector, frameSelector) { + const nodeFrontInfo = await getSelectedNodeFrontInfo(inspector); + is(nodeFrontInfo.nodeFront.id, "b1", "The selected node is #b1"); + is( + nodeFrontInfo.nodeFront.tagName.toLowerCase(), + "button", + "The selected node is <button>" + ); + + const iframe = await getNodeFrontInFrames(frameSelector, inspector); + const expectedDocument = (await iframe.walkerFront.children(iframe)).nodes[0]; + + is( + nodeFrontInfo.document, + expectedDocument, + "The selected node is in " + frameSelector + ); +}; +/** + * Gets the currently selected nodefront. It also finds the + * document node which contains the node. + * @param {Object} inspector + * @returns {Object} + * nodeFront - The currently selected nodeFront + * document - The document which contains the node. + * + */ +async function getSelectedNodeFrontInfo(inspector) { + const { selection, commands } = inspector; + + const nodeFront = selection.nodeFront; + const inspectors = await commands.inspectorCommand.getAllInspectorFronts(); + + for (let i = 0; i < inspectors.length; i++) { + const inspectorFront = inspectors[i]; + if (inspectorFront.walker == nodeFront.walkerFront) { + const document = await inspectorFront.walker.document(nodeFront); + return { nodeFront, document }; + } + } + return null; +} |