diff --git a/devtools/client/debugger/src/components/ProjectSearch.js b/devtools/client/debugger/src/components/ProjectSearch.js
index 53489559c549..71cf78d817b2 100644
--- a/devtools/client/debugger/src/components/ProjectSearch.js
+++ b/devtools/client/debugger/src/components/ProjectSearch.js
@@ -12,6 +12,7 @@ import { getEditor } from "../utils/editor";
import { statusType } from "../reducers/project-text-search";
import { getRelativePath } from "../utils/sources-tree/utils";
+import { getFormattedSourceId } from "../utils/source";
import {
getActiveSearch,
getTextSearchResults,
@@ -204,7 +205,6 @@ export class ProjectSearch extends Component {
renderFile = (file, focused, expanded) => {
const matchesLength = file.matches.length;
const matches = ` (${matchesLength} match${matchesLength > 1 ? "es" : ""})`;
-
return (
-
{getRelativePath(file.filepath)}
+
+ {file.filepath
+ ? getRelativePath(file.filepath)
+ : getFormattedSourceId(file.sourceId)}
+
{matches}
);
diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-project-search.js b/devtools/client/debugger/test/mochitest/browser_dbg-project-search.js
index caeed6f0425d..68d33bfa5fa6 100644
--- a/devtools/client/debugger/test/mochitest/browser_dbg-project-search.js
+++ b/devtools/client/debugger/test/mochitest/browser_dbg-project-search.js
@@ -69,6 +69,30 @@ add_task(async function testSimpleProjectSearch() {
);
});
+add_task(async function testSearchDynamicScripts() {
+ const dbg = await initDebugger("doc-minified.html");
+
+ const executeComplete = dbg.commands.scriptCommand.execute(
+ `const foo = 5; debugger; console.log(foo)`
+ );
+ await waitForPaused(dbg);
+
+ await openProjectSearch(dbg);
+ type(dbg, "foo");
+ pressKey(dbg, "Enter");
+
+ const fileResults = await waitForSearchResults(dbg, 1);
+
+ ok(
+ /source\d+/g.test(fileResults[0].innerText),
+ "The search result was found in the eval script."
+ );
+
+ await closeProjectSearch(dbg);
+ await resume(dbg);
+ await executeComplete;
+});
+
// Tests that minified sources are ignored when the prettyfied versions
// exist.
add_task(async function testIgnoreMinifiedSourceForPrettySource() {