Repository navigation
Open a trace from a URL in the hosted player, and deep-link into it - #534
Open
vishnuv688 wants to merge 1 commit into
Open
vishnuv688 wants to merge 1 commit into
vishnuv688 wants to merge 1 commit into
Conversation
CI jobs and bug reports could not link to a trace: the hosted player only opened files picked or dropped by hand. It now opens ?trace=<https url> from any host that sends CORS headers, without credentials, refusing other schemes, redirects off https, a stalled host, a body over 512 MB and anything that is not a zip. Its CSP gains connect-src https: for that fetch; the backend's policy is unchanged. #action=<callId>&tab=<tab> opens a trace on an action and a dock tab, in the hosted player and show-trace, and the address follows the viewer's picks with replaceState. The link applies only to the trace it came with, and a run of several traces links the tab only. CommandLog gains an optional callId, kept by the trace reader. Opening a trace no longer moves the dock to Log, so a linked tab holds. Closes #500 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Closes #500. Part of #494.
The hosted player could only open a trace someone picked or dropped by hand, so a CI job or a bug report could not link to one, let alone to the failing step. Now:
?trace=<url>opens a zip from any https host that sendsAccess-Control-Allow-Origin(or from the player's own origin).#action=<callId>&tab=<tab>opens the trace on that action with that bottom tab open, in the hosted player andshow-trace. The address follows the viewer's picks, so the address bar always links to what is on screen.Example:
https://trace.webdriver.io/?trace=https%3A%2F%2Fci.example%2Ftrace.zip#action=call@12&tab=networkType of change
Packages touched
shared(types and contracts)core(framework-agnostic capture/reporting)elements(published element/snapshot API —@wdio/elements)service(WebdriverIO adapter)nightwatch-devtools(Nightwatch adapter)selenium-devtools(Selenium adapter)selenium-devtools-py(Selenium Python adapter)backend(server)app(UI)script(page-injected runtime)trace(Trace mode)Plus
conformance(the hosted-player check) andvercel.json.backendhas no source change; it bundles the trace reader, which now keepscallId, and that is what givesshow-tracedeep links.selenium-devtools-pyonly regenerates its wire types for the new optionalCommandLog.callId(patch fragment); its behaviour is unchanged.Capability matrix
packages/conformance/src/features.tsupdated, and tables regenerated withpnpm docs:capabilities, if this adds or changes user-facing behaviourA player feature, not an adapter capability; the tables are unchanged.
Notes for reviewers
The trust decision (recorded on #500): the hosted player's
connect-srcgainshttps:so it can fetch the zip.hostedPlayerCsp()inshared/player-csp.tsis the single source;vercel.jsonmust equal it and a test checks it differs fromplayerCsp()inconnect-srconly. The backend (show-trace, live dashboard) keeps its policy and ignores?trace=. An opened trace still never leaves the tab: the only fetch is the download itself.The download (
app/src/controller/trace-download.ts):javascript:,data:,blob:,file:, other-originhttp:and URLs carrying credentials are refused before any request.credentials: 'omit',referrerPolicy: 'no-referrer', and the final URL after redirects is checked again.Access-Control-Allow-Origin. Errors name the host and path only, never a signed URL's query.traceis the last parameter, or percent-encoded anywhere.Deep links:
callId, kept by the reader on a new optionalCommandLog.callId(old zips get one too).controller/trace-link.tsreads or writes the address. The link is applied once, to the trace the page opened with; opening another trace by hand clears it, so a second trace starts on its own first action. A run of several traces links the tab only, since the hash names no run entry.replaceState(no history entries). A pasted link in an open tab is followed throughhashchange. The live dashboard never touches the address.Behaviour change: opening a trace no longer switches the dock to Log on its own; it opens on the last-used tab, so a linked tab holds. A viewer's pick still opens Log.
Scheduled hosted-player check: it now compares production's CSP to
hostedPlayerCsp()directive by directive, so it will report drift until production is deployed from amainthat includes this PR. Production does not exist yet (hosting is still being set up), so this is the policy the first deploy must serve.Review: three independent rounds. The first found one blocking bug (a stale hash steered every later trace opened in the same tab) plus ten more; the second confirmed the fixes and found six small edges; all are fixed, each with a test that fails without it. No security findings: scheme tricks, redirects, exfiltration, injection and the CSP scope were checked.
Testing
pnpm build,pnpm typecheck,pnpm test(3704 passed, 1 skipped),pnpm test:ui(31 of 31),pnpm lint,pnpm docs:capabilities --checkare green; no workspace import leaks in any bundle.?trace=with#action=…&tab=network, asserts that action and tab are shown, and that a pick is written back to the address. It passes locally.test_instrumentation.pytests fail locally with and without this PR.Needs checking by hand
pnpm player:hosted, copy a zip intopackages/app/dist-hosted/t.zip, openhttp://localhost:4173/?trace=/t.zip#action=call@3&tab=network: the download phase shows, then the trace opens on that action with Network open. Picks and tab changes update the address without adding back-button entries.?trace=http://example.com/t.zip,?trace=javascript:alert(1), a 404 URL,?trace=/index.htmland an empty?trace=each show their own message.npx http-server <dir> --cors -S -C cert.pem -K key.pem -p 8443) and open it by?trace=; without--corsthe CORS message shows.show-trace <zip>with#action=call@2&tab=consoleappended opens there, and the address follows picks.pnpm demo:wdio) leaves the address unchanged.Not in this PR: the docs-site mirror.
Screenshots / recordings
To be added: a
?trace=deep link opening on the Network tab.🤖 Generated with Claude Code