fix(javascript): retain wrapped isolated-world bridge exposures
Share contextBridge argument ownership between direct and wrapped analysis, seed intact isolated-world calls, and preserve dynamic world IDs and conditional metadata as unknown. Keep callee evaluation scoped to each invocation. Validation: 99 focused source tests and bundled isolated-world acceptance through dedicated and generic CLI routes. Removed duplicate literal source regression in favor of public workflow coverage. Fixes #2174.
This commit is contained in:
@@ -140,6 +140,60 @@ it("preserves an observed empty contextBridge API object", () => {
|
||||
expect(result.parse_status).toBe("complete");
|
||||
});
|
||||
|
||||
describe("wrapped contextBridge exposure methods", () => {
|
||||
it("retains the original expression for a dynamic isolated world id", () => {
|
||||
const result = analyzeJavaScriptStaticSource(
|
||||
bundle(
|
||||
`const worldId = selectWorld(); electron.contextBridge.exposeInIsolatedWorld(worldId, "isolatedApi", {ping: true});`,
|
||||
),
|
||||
);
|
||||
expect(result.electron.context_bridge_apis).toContainEqual(
|
||||
expect.objectContaining({
|
||||
world: "isolated",
|
||||
world_id: {
|
||||
status: "dynamic",
|
||||
value: null,
|
||||
expression: "worldId",
|
||||
},
|
||||
api_key: "isolatedApi",
|
||||
members: ["ping"],
|
||||
resolution_basis: "wrapper-substitution",
|
||||
}),
|
||||
);
|
||||
expect(result.parse_status).toBe("partial");
|
||||
});
|
||||
|
||||
it("does not report a conditionally selected world as unconditional", () => {
|
||||
const result = analyzeJavaScriptStaticSource(
|
||||
bundle(
|
||||
`if (useIsolated) electron.contextBridge.exposeInIsolatedWorld(1001, "isolatedApi", {ping: true});`,
|
||||
),
|
||||
);
|
||||
expect(result.electron.context_bridge_apis).not.toContainEqual(
|
||||
expect.objectContaining({
|
||||
api_key: "isolatedApi",
|
||||
resolution_basis: "wrapper-substitution",
|
||||
}),
|
||||
);
|
||||
expect(result.parse_status).toBe("partial");
|
||||
});
|
||||
|
||||
it("does not report conditionally resolved world ids as unconditional", () => {
|
||||
const result = analyzeJavaScriptStaticSource(
|
||||
bundle(
|
||||
`const worldId = useFirstWorld ? 1001 : 1002; electron.contextBridge.exposeInIsolatedWorld(worldId, "isolatedApi", {ping: true});`,
|
||||
),
|
||||
);
|
||||
expect(result.electron.context_bridge_apis).not.toContainEqual(
|
||||
expect.objectContaining({
|
||||
api_key: "isolatedApi",
|
||||
resolution_basis: "wrapper-substitution",
|
||||
}),
|
||||
);
|
||||
expect(result.parse_status).toBe("partial");
|
||||
});
|
||||
});
|
||||
|
||||
it("connects exposed closures to IPC sends and text clipboard calls", () => {
|
||||
const result = analyzeJavaScriptStaticSource(
|
||||
bundle(`
|
||||
|
||||
Reference in New Issue
Block a user