diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /devtools/client/debugger/test/mochitest/browser_dbg-search-file-paused.js | |
parent | Initial commit. (diff) | |
download | firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/client/debugger/test/mochitest/browser_dbg-search-file-paused.js')
-rw-r--r-- | devtools/client/debugger/test/mochitest/browser_dbg-search-file-paused.js | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-search-file-paused.js b/devtools/client/debugger/test/mochitest/browser_dbg-search-file-paused.js new file mode 100644 index 0000000000..cb5be5cfa2 --- /dev/null +++ b/devtools/client/debugger/test/mochitest/browser_dbg-search-file-paused.js @@ -0,0 +1,71 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */ + +// Tests the search bar correctly responds to queries, enter, shift enter + +add_task(async function() { + const dbg = await initDebugger("doc-scripts.html", "simple1.js", "simple2.js"); + const { + selectors: { getBreakpoints, getBreakpoint, getActiveSearch }, + getState + } = dbg; + + info("Add a breakpoint, wait for pause"); + const source = findSource(dbg, "simple2.js"); + await selectSource(dbg, source.url); + await addBreakpoint(dbg, source, 5); + invokeInTab("main"); + await waitForPaused(dbg); + + info("Starting a search for 'bar'"); + const cm = getCM(dbg); + pressKey(dbg, "fileSearch"); + is(dbg.selectors.getActiveSearch(), "file"); + const el = getFocusedEl(dbg); + type(dbg, "bar"); + await waitForSearchState(dbg); + + info("Ensuring 'bar' matches are highlighted"); + pressKey(dbg, "Enter"); + is(cm.state.search.posFrom.line, 1); + pressKey(dbg, "Enter"); + is(cm.state.search.posFrom.line, 4); + + info("Switching files via frame click"); + const frames = findAllElements(dbg, "frames"); + await pressMouseDown(dbg, frames[1]) + + // Ensure that the debug line is in view, and not the first "bar" instance, + // which the user would have to scroll down for + const { top } = cm.getScrollInfo(); + is(top, 0, "First search term is not in view"); + + // Change the search term and go back to the first source in stack + info("Switching to paused file via frame click"); + pressKey(dbg, "fileSearch"); + el.value = ""; + type(dbg, "func"); + await waitForSearchState(dbg); + await pressMouseDown(dbg, frames[0]); + await waitFor(() => cm.state.search.query === "func"); + + // Ensure there is a match for the new term + pressKey(dbg, "Enter"); + is(cm.state.search.posFrom.line, 0); + pressKey(dbg, "Enter"); + is(cm.state.search.posFrom.line, 1); +}); + +function waitForSearchState(dbg) { + return waitForState(dbg, () => getCM(dbg).state.search); +} + +function getFocusedEl(dbg) { + const doc = dbg.win.document; + return doc.activeElement; +} + +async function pressMouseDown(dbg, node) { + await EventUtils.sendMouseEvent({ type: "mousedown" }, node, dbg.win); +} |