From ae849a72811857ba9755962ec48a1d76c9d1181a Mon Sep 17 00:00:00 2001 From: Iwakurakaoru0822 <208281322+kaoru0822-kitauji@users.noreply.github.com> Date: Tue, 6 Oct 2026 23:32:50 -0700 Subject: [PATCH] fix(javascript): never read window or document open as XHR `window.open(url, "/preview")` has a computed first argument and a path-shaped browsing-context name, so the computed-method XHR fallback reported the target name as an endpoint. Browsing-context and document `open` calls never take an XHR method and request URL; skip them. Co-Authored-By: Claude Opus 5.5 --- src/domain/javascriptStaticAnalysisHelpers.ts | 10 +++++++++- src/domain/webBundleAnalyzer.test.ts | 3 +++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/domain/javascriptStaticAnalysisHelpers.ts b/src/domain/javascriptStaticAnalysisHelpers.ts index 8400862a1..d13d2a7ac 100644 --- a/src/domain/javascriptStaticAnalysisHelpers.ts +++ b/src/domain/javascriptStaticAnalysisHelpers.ts @@ -383,6 +383,13 @@ const xhrOpenUrl = ( : undefined; }; +/** + * Browsing-context and document `open` take a URL or type first and a target + * name second, never an XHR method and request URL. + */ +const WINDOW_OPEN_CALL = + /(?:^|\.)(?:window|self|globalThis|top|parent|opener|frames|document)\.open$/u; + /** Select the literal URL argument for recognized network callees. */ export const endpointArgument = ( name: string, @@ -395,7 +402,8 @@ export const endpointArgument = ( ): string | undefined => { if (name === "fetch" || name.endsWith(".fetch") || name === "WebSocket") return stringValue(args[0]); - if (name.endsWith(".open")) return xhrOpenUrl(args[0], args[1]); + if (name.endsWith(".open") && !WINDOW_OPEN_CALL.test(name)) + return xhrOpenUrl(args[0], args[1]); if ( ["get", "post", "put", "patch", "delete", "request"].some( (method) => name === method || name.endsWith(`.${method}`), diff --git a/src/domain/webBundleAnalyzer.test.ts b/src/domain/webBundleAnalyzer.test.ts index 77c5df458..d4f5440be 100644 --- a/src/domain/webBundleAnalyzer.test.ts +++ b/src/domain/webBundleAnalyzer.test.ts @@ -185,6 +185,9 @@ describe("web bundle static-analysis parity", () => { xhr.open(method, "/dynamic-method"); fs.open(path, "r", done); window.open(url, "_blank"); + window.open(url, "/preview"); + globalThis.open(url, "./frame"); + document.open("text/html", "/replace"); `), ); expect(