chore: merge main into intrinsic invocation fixes

This commit is contained in:
morluto
2026-10-12 01:29:18 +08:00
15 changed files with 1973 additions and 130 deletions
@@ -41,8 +41,29 @@ const INTRINSIC_MUTATIONS = [
"sequence.cjs",
'(0,Object.defineProperty)(Object,"create",{value:customCreate});',
],
[
"deep-call.cjs",
'Function.prototype.call.call.call(Object.defineProperty,null,Object,"create",{value:customCreate});',
],
[
"deep-apply.cjs",
'Function.prototype.apply.apply(Object.defineProperty,[null,[Object,"create",{value:customCreate}]]);',
],
] as const;
const writePoisonedModules = async (root: string): Promise<void> => {
for (const [name, mutation] of INTRINSIC_MUTATIONS)
await writeFile(
join(root, name),
`${mutation}
${ROLLDOWN_MODULE_INTEROP}
let poisoned = require("electron");
poisoned = __toESM(poisoned, 1);
new poisoned.BrowserWindow({});
throw new Error("must not execute poisoned source");`,
);
};
cliTest.for(["CLI", "stdio MCP"] as const)(
"retains converted Electron windows and preload evidence through %s",
async (surface, { cli }) => {
@@ -55,20 +76,13 @@ cliTest.for(["CLI", "stdio MCP"] as const)(
join(root, "preload.js"),
'throw new Error("must stay inert");',
);
for (const [name, mutation] of INTRINSIC_MUTATIONS)
await writeFile(
join(root, name),
`${mutation}
${ROLLDOWN_MODULE_INTEROP}
let poisoned = require("electron");
poisoned = __toESM(poisoned, 1);
new poisoned.BrowserWindow({});
throw new Error("must not execute poisoned source");`,
);
await writePoisonedModules(root);
const source = `const metadata = {};
Object.defineProperty(metadata,"x",{value:1});
const decorateMetadata = Object.defineProperty.bind(null,metadata,"bound");
decorateMetadata({value:1});
const decorateViaCall = Function.prototype.call.bind(Object.defineProperty);
decorateViaCall(null,metadata,"uncurried",{value:1});
const localFunction = () => {};
Object.defineProperty(localFunction,"x",{value:1});
const localClass = class {};
@@ -111,6 +125,8 @@ cliTest.for(["CLI", "stdio MCP"] as const)(
require("./replaced-apply.cjs");
require("./receiver.cjs");
require("./sequence.cjs");
require("./deep-call.cjs");
require("./deep-apply.cjs");
throw new Error("must not execute main");
`;
await writeFile(join(root, "main.cjs"), source);
@@ -137,7 +153,7 @@ cliTest.for(["CLI", "stdio MCP"] as const)(
preload_entrypoints: 1,
});
expect(result.statistics.parse_failures).toBe(0);
expect(result.statistics.parsed_javascript_files).toBe(11);
expect(result.statistics.parsed_javascript_files).toBe(13);
const windows = result.graph.nodes.filter(
({ kind }) => kind === "browser-window",
);