fix(electron): unwrap transparent inline window options

Use the shared expression owner for BrowserWindow options and webPreferences. Retain overwrite and spread uncertainty through CLI and MCP evidence.

Refs: #4250, #4281

Co-authored-by: Geekwolf <geekwolf@163.com>
This commit is contained in:
morlutoandGeekwolf committed 2026-10-16 08:14:51 +08:00
1 parent 38f92d108e
commit b67baede2e
3 files changed
+165 -7

No files matched your search

@@ -3,6 +3,34 @@ import { describe, expect, it } from "vitest";
import { analyzeJavaScriptStaticSource } from "./javascriptStaticAnalysis.js";
describe("Electron option evidence", () => {
it.each([
'({ webPreferences: { preload: "./preload.js", sandbox: true } } as const)',
'{ webPreferences: ({ preload: "./preload.js", sandbox: true } as const) }',
'{ webPreferences: { preload: "./preload.js" as const, sandbox: true } }',
])("unwraps type-only wrappers around inline options: %s", (options) => {
const analysis = analyzeJavaScriptStaticSource(`
import { BrowserWindow } from "electron";
new BrowserWindow(${options});
`);
expect(analysis.parse_error_count).toBe(0);
expect(analysis.electron.browser_windows).toMatchObject([
{
options_status: "object-literal",
web_preferences_status: "object-literal",
preload_path: "./preload.js",
preload_resolution_context: "module-specifier",
web_preferences: [
{
name: "preload",
value: { status: "literal", value: "./preload.js" },
},
{ name: "sandbox", value: { status: "literal", value: true } },
],
},
]);
});
it("keeps the final explicit preload and service name with unrelated keys", () => {
const analysis = analyzeJavaScriptStaticSource(`
const { BrowserWindow, utilityProcess } = require("electron");