From d55ef36d13ae56e77bc8417502a72df3b4de959c Mon Sep 17 00:00:00 2001 From: CruzLiu Date: Tue, 3 Feb 2026 11:53:30 +0800 Subject: [PATCH] fix(trace): convert file path to URI in StdinServer._loadTrace When receiving trace paths via stdin (used by VS Code extension), StdinServer._loadTrace() was sending raw file paths to the frontend instead of converting them to `file?path=` URI format. This caused the trace viewer to fail with "Not allowed to load local resource: file:///" error because the Service Worker tried to fetch the raw path directly. The fix calls validateTraceUrl() to properly convert the file path to URI format before sending to the frontend, consistent with how other entry points (runTraceViewerApp, runTraceInBrowser) handle trace paths. Fixes #39096 --- .../playwright-core/src/server/trace/viewer/traceViewer.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/playwright-core/src/server/trace/viewer/traceViewer.ts b/packages/playwright-core/src/server/trace/viewer/traceViewer.ts index 0e83a15f387f7..78af6b999a88c 100644 --- a/packages/playwright-core/src/server/trace/viewer/traceViewer.ts +++ b/packages/playwright-core/src/server/trace/viewer/traceViewer.ts @@ -244,9 +244,10 @@ class StdinServer implements Transport { close?: () => void; private _loadTrace(traceUrl: string) { - this._traceUrl = traceUrl; + const validatedUrl = validateTraceUrl(traceUrl); + this._traceUrl = validatedUrl; clearTimeout(this._pollTimer); - this.sendEvent?.('loadTraceRequested', { traceUrl }); + this.sendEvent?.('loadTraceRequested', { traceUrl: validatedUrl }); } private _pollLoadTrace(url: string) {