summaryrefslogtreecommitdiffstats
path: root/devtools/client/debugger/test/mochitest/browser_dbg-fission-project-search.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /devtools/client/debugger/test/mochitest/browser_dbg-fission-project-search.js
parentInitial commit. (diff)
downloadfirefox-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/debugger/test/mochitest/browser_dbg-fission-project-search.js')
-rw-r--r--devtools/client/debugger/test/mochitest/browser_dbg-fission-project-search.js52
1 files changed, 52 insertions, 0 deletions
diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-fission-project-search.js b/devtools/client/debugger/test/mochitest/browser_dbg-fission-project-search.js
new file mode 100644
index 0000000000..1924e4b9bf
--- /dev/null
+++ b/devtools/client/debugger/test/mochitest/browser_dbg-fission-project-search.js
@@ -0,0 +1,52 @@
+/* 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/>. */
+
+"use strict";
+
+const TEST_COM_URI = `${URL_ROOT_COM_SSL}examples/doc_dbg-fission-frame-sources.html`;
+
+// Testing project search for remote frames.
+add_task(async function () {
+ // Load page and wait for sources. simple.js is loaded from
+ // the top-level document in the dot com domain, while simple2.js
+ // is loaded from the remote frame in the dot org domain
+ const dbg = await initDebuggerWithAbsoluteURL(
+ TEST_COM_URI,
+ "simple1.js",
+ "simple2.js"
+ );
+
+ pressKey(dbg, "projectSearch");
+ type(dbg, "foo");
+ pressKey(dbg, "Enter");
+
+ await waitForSearchResults(dbg, 2);
+
+ const fileResults = findAllElements(dbg, "projectSearchFileResults");
+ const matches = findAllElements(dbg, "projectSearchExpandedResults");
+
+ is(fileResults.length, 2, "Two results found");
+ is(matches.length, 6, "Total no of matches found");
+
+ // Asserts that we find a matches in the js file included in the top-level document
+ assertFileResult("simple1.js", 5);
+ // Asserts that we find the match in the js file included
+ assertFileResult("simple2.js", 1);
+
+ function assertFileResult(fileMatched, noOfMatches) {
+ // The results can be out of order so let find it from the collection
+ const match = [...fileResults].find(result =>
+ result.querySelector(".file-path").innerText.includes(fileMatched)
+ );
+
+ ok(match, `Matches were found in ${fileMatched} file.`);
+
+ const matchText = noOfMatches > 1 ? "matches" : "match";
+ is(
+ match.querySelector(".matches-summary").innerText.trim(),
+ `(${noOfMatches} ${matchText})`,
+ `${noOfMatches} ${matchText} were found in ${fileMatched} file.`
+ );
+ }
+});