fix(javascript): preserve bound receivers for intrinsic invocation
This commit is contained in:
@@ -10,6 +10,26 @@ import { connectLocalToolsMcp } from "../../fixtures/localToolsMcp.js";
|
||||
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
||||
import { cliTest } from "../../support/cli/cliFixture.js";
|
||||
|
||||
const INTRINSIC_MUTATIONS = [
|
||||
["poisoned.cjs", "({Object} = replacements);"],
|
||||
[
|
||||
"projected.cjs",
|
||||
'const {defineProperty:change} = Object; change(Object,"create",{value:customCreate});',
|
||||
],
|
||||
[
|
||||
"decorated.cjs",
|
||||
'@(() => Object) class metadata {}; Object.defineProperty(metadata,"create",{value:customCreate});',
|
||||
],
|
||||
[
|
||||
"uncurried.cjs",
|
||||
'const change = Function.prototype.call.bind(Object.defineProperty,null); change(Object,"create",{value:customCreate});',
|
||||
],
|
||||
[
|
||||
"bound.cjs",
|
||||
'const change = Object.defineProperty.bind(null,Object,"create"); change({value:customCreate});',
|
||||
],
|
||||
] as const;
|
||||
|
||||
cliTest.for(["CLI", "stdio MCP"] as const)(
|
||||
"retains converted Electron windows and preload evidence through %s",
|
||||
async (surface, { cli }) => {
|
||||
@@ -22,21 +42,7 @@ cliTest.for(["CLI", "stdio MCP"] as const)(
|
||||
join(root, "preload.js"),
|
||||
'throw new Error("must stay inert");',
|
||||
);
|
||||
for (const [name, mutation] of [
|
||||
["poisoned.cjs", "({Object} = replacements);"],
|
||||
[
|
||||
"projected.cjs",
|
||||
'const {defineProperty:change} = Object; change(Object,"create",{value:customCreate});',
|
||||
],
|
||||
[
|
||||
"decorated.cjs",
|
||||
'@(() => Object) class metadata {}; Object.defineProperty(metadata,"create",{value:customCreate});',
|
||||
],
|
||||
[
|
||||
"bound.cjs",
|
||||
'const change = Object.defineProperty.bind(null,Object,"create"); change({value:customCreate});',
|
||||
],
|
||||
] as const)
|
||||
for (const [name, mutation] of INTRINSIC_MUTATIONS)
|
||||
await writeFile(
|
||||
join(root, name),
|
||||
`${mutation}
|
||||
@@ -86,6 +92,7 @@ cliTest.for(["CLI", "stdio MCP"] as const)(
|
||||
require("./projected.cjs");
|
||||
require("./decorated.cjs");
|
||||
require("./bound.cjs");
|
||||
require("./uncurried.cjs");
|
||||
throw new Error("must not execute main");
|
||||
`;
|
||||
await writeFile(join(root, "main.cjs"), source);
|
||||
@@ -112,7 +119,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(6);
|
||||
expect(result.statistics.parsed_javascript_files).toBe(7);
|
||||
const windows = result.graph.nodes.filter(
|
||||
({ kind }) => kind === "browser-window",
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user