fix(javascript): stop reading media preload attributes as Electron preloads

HTML audio and video elements have their own `preload` attribute ("none",
"metadata", "auto"). A React renderer compiles `<audio preload="metadata">`
to `jsx("audio", { preload: "metadata" })`, and the `property:preload`
heuristic reported it as an Electron preload script named `metadata`.

Skip `preload` properties in the props object of a call whose first
argument is the static tag `audio` or `video`. The callee is not checked,
because minified element factories have arbitrary names.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XPY2GmufMNGQKoEgRUx1pd
This commit is contained in:
Claude
2026-10-10 22:12:56 +08:00
committed by Ysopwnable
parent e4cc0f09de
commit 649661dc8b
3 changed files with 37 additions and 0 deletions
@@ -24,6 +24,20 @@ describe("Electron option evidence", () => {
});
});
it("does not read an audio or video preload attribute as a preload script", () => {
const analysis = analyzeJavaScriptStaticSource(`
jsx("audio", { controls: true, preload: "metadata", src });
(0, React.createElement)(\`video\`, { preload: "auto" });
jsx("webview", { preload: "./guest.js" });
const options = { preload: "./preload.js" };
`);
expect(analysis.role_paths.map(({ path }) => path)).toEqual([
"./guest.js",
"./preload.js",
]);
});
it("keeps values unknown when a later computed key can override them", () => {
const analysis = analyzeJavaScriptStaticSource(`
new BrowserWindow({ webPreferences: { preload: "./maybe.js" }, [key]: null });