fix(javascript): integrate verified namespace interop with main
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
commit
9788112548
@@ -29,6 +29,14 @@ cliTest.for(["CLI", "stdio MCP"] as const)(
|
||||
new electron.BrowserWindow({webPreferences:{preload:runtimePath}});
|
||||
const direct = require("electron");
|
||||
new direct.BrowserWindow({});
|
||||
const fresh = __toESM(require("electron"), 1);
|
||||
new fresh.BrowserWindow({});
|
||||
function identity(mod) {return mod;}
|
||||
const passthrough = identity(require("electron"));
|
||||
new passthrough.BrowserWindow({});
|
||||
const __importStar = () => ({BrowserWindow:FakeWindow});
|
||||
const fake = __importStar(require("electron"));
|
||||
new fake.BrowserWindow({});
|
||||
function decoy(electron) {new electron.BrowserWindow({});}
|
||||
throw new Error("must not execute main");
|
||||
`;
|
||||
@@ -52,14 +60,30 @@ cliTest.for(["CLI", "stdio MCP"] as const)(
|
||||
.object({ normalized_result: javascriptApplicationAnalysisResultSchema })
|
||||
.parse(document).normalized_result;
|
||||
expect(result.summary).toMatchObject({
|
||||
browser_windows: 3,
|
||||
browser_windows: 5,
|
||||
preload_entrypoints: 1,
|
||||
});
|
||||
expect(result.statistics.parse_failures).toBe(0);
|
||||
const windows = result.graph.nodes.filter(
|
||||
({ kind }) => kind === "browser-window",
|
||||
);
|
||||
expect(windows).toHaveLength(3);
|
||||
expect(windows).toHaveLength(5);
|
||||
const expectedLines = source
|
||||
.split("\n")
|
||||
.flatMap((line, index) =>
|
||||
/^\s*new (?:electron|direct|fresh|passthrough)\.BrowserWindow/u.test(
|
||||
line,
|
||||
)
|
||||
? [index + 1]
|
||||
: [],
|
||||
);
|
||||
const observedLines = windows.flatMap((window) => {
|
||||
const location = window.observations[0]?.evidence.location;
|
||||
return location?.available && location.value.kind === "source-range"
|
||||
? [location.value.start.line]
|
||||
: [];
|
||||
});
|
||||
expect(observedLines.toSorted()).toEqual(expectedLines.toSorted());
|
||||
for (const window of windows) {
|
||||
expect(window.observations[0]?.evidence.location).toMatchObject({
|
||||
available: true,
|
||||
|
||||
Reference in New Issue
Block a user