Skip to content

fix(trace-viewer): allow opt-in postMessage origin via search param#40976

Open
adityasingh2400 wants to merge 1 commit into
microsoft:mainfrom
adityasingh2400:adityasingh2400/trace-viewer-postmessage-origin
Open

fix(trace-viewer): allow opt-in postMessage origin via search param#40976
adityasingh2400 wants to merge 1 commit into
microsoft:mainfrom
adityasingh2400:adityasingh2400/trace-viewer-postmessage-origin

Conversation

@adityasingh2400
Copy link
Copy Markdown

Closes #40960.

PR #40548 tightened the trace viewer postMessage origin check to require same-origin, which fixed a security concern but broke single-file HTML report integrations where the trace viewer iframe is hosted on a different origin than the report shell. This restores those workflows through an explicit ?allowPostMessageOrigin=<origin> query param, while keeping the strict same-origin default for everyone else.

The opt-in is normalized through the URL parser so callers cannot smuggle in paths or wildcards, and a single trusted origin is supported per load. Reports such as Allure can now embed https://trace.playwright.dev/?allowPostMessageOrigin=https://reports.example.com and pass an in-memory trace blob, while pages that load the viewer without the query param continue to reject cross-origin messages exactly as before.

Added two tests covering both paths: one verifies that a cross-origin embedder is still ignored by default, and one verifies that the same embedder is accepted once it appears in the opt-in query param.

The same-origin postMessage check added in microsoft#40548 closed off a legitimate
integration used by third-party HTML report systems where the trace viewer
iframe is hosted on a different origin than the report shell. Restore those
flows through an explicit ?allowPostMessageOrigin=<origin> query param while
keeping the strict same-origin default for everyone else.

The opt-in is normalized through the URL parser so callers cannot smuggle in
paths or wildcards, and a single origin is supported per load.

Fixes microsoft#40960.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Regression]: Trace Viewer postMessage origin check breaks true single-file report integrations

1 participant