Repository navigation
Description
Note
🤖 Claude Opus 5.5 opening this issue on behalf of Will
Version
1.65.1 (also 1.66.0-alpha-2026-11-14)
Steps to reproduce
Minimal reproduction: https://github.com/ceolinwill/playwright-tracing-user-activation
git clone https://github.com/ceolinwill/playwright-tracing-user-activation
cd playwright-tracing-user-activation
npm install
npx playwright install chromium
npm run reproThe script serves one static HTML page, opens it in two fresh contexts (one with context.tracing.start({ snapshots: true }), one without), and reads navigator.userActivation.hasBeenActive through a CDP session with userGesture: false, since page.evaluate itself grants activation.
Output:
without tracing: navigator.userActivation.hasBeenActive = false
with tracing: navigator.userActivation.hasBeenActive = true
BUG: tracing marked a page nobody interacted with as user-activated.
Expected behavior
Recording a trace doesn't change the page: navigator.userActivation.hasBeenActive stays false until the test acts on the page, as it does without tracing.
Actual behavior
With tracing on, a page nobody clicked reports hasBeenActive === true right after page.goto(). Any app code that waits for the user's first gesture (sending something only after the first interaction, unmuting audio, opening a popup) behaves differently while a trace is recorded, so a test that checks the page wasn't activated passes without --trace and fails with it (trace: 'retain-on-failure' or 'on' in the config, or --trace on the command line).
Where it comes from: starting tracing with snapshots starts a HarTracer (packages/playwright-core/src/server/trace/recorder/tracing.ts). On the main frame's domcontentloaded and load, HarTracer._onDOMContentLoaded and _onLoad (packages/playwright-core/src/server/har/harTracer.ts) read the page title and timings with page.mainFrame().evaluateExpression(...) in the utility world. On Chromium every such evaluation goes through CRExecutionContext.evaluateWithArguments, which sends Runtime.callFunctionOn with userGesture: true (packages/playwright-core/src/server/chromium/crExecutionContext.ts). User activation is per frame, not per world, so these internal reads activate the page. Running the script with DEBUG=pw:protocol shows both calls with "userGesture":true.
Additional context
A possible fix: run these internal reads without a user gesture (for example with rawEvaluateJSON, which the snapshotter already uses for its captures), or pass userGesture: false for evaluations Playwright makes on its own behalf.
In our app's E2E suite, a test that checks a reload doesn't activate the page failed 10 of 10 times with tracing on and passed 10 of 10 with it off. We now turn tracing off for that one file with test.use({ trace: 'off' }).
Environment
- Operating System: macOS 27.2.1 (arm64)
- Browser: Chromium 159.0.8154.6
- Node.js: 24.22.0
- npm: 11.19.1
- Playwright: 1.65.1 and 1.66.0-alpha-2026-11-14
Activity
microsoft-playwright-automation commentedon Nov 16, 2026
microsoft-playwright-automation commentedon Nov 16, 2026
Hi, I'm the Playwright bot and I reproduced this on macOS.
Reproduced on
1.66.0-next(826ce42b8664ea940424e77ce51f1cdf96dcd37f). The HAR recorder's title and timing reads grant user activation. Changing both reads to raw evaluation in the utility world fixes the reported Chromium case and also fixes WebKit.Firefox still reports activation: its browser-side
Runtime.evaluateunconditionally grants a user gesture, including for raw evaluations. This proposal does not change Firefox's protocol.Condensed regression
The existing tracing test is extended with this check before its first click. A mouse move reads the value without granting activation;
page.evaluatewould grant activation itself.What I ran
All runs used macOS, headless browsers, and the checkout above.
truefalsetruefalsetruetrueA separate data-page check returned
falsein every browser with tracing off or with snapshots disabled. The activation assertion covers Chromium and WebKit; the existing tracing assertions still run in Firefox.The build and
npm run flintpassed. The fulltracing.spec.ts,har.spec.ts, andbrowsercontext-har.spec.tssuites passed across all three browsers: 431 passed, 7 skipped, no retries.Draft PR: #44152
Triaged on macOS by the Playwright bot - agent run
fix(har): avoid user activation when reading page metadata
fix(har): avoid user activation when reading page metadata
dcrousso commentedon Nov 17, 2026
lets file an issue in https://github.com/microsoft/playwright-browsers/ as per #44152 (comment)
microsoft-playwright-automation commentedon Nov 17, 2026
microsoft-playwright-automation commentedon Nov 17, 2026
Hi, I'm the Playwright bot. The Firefox browser report is prepared for filing, as requested in the review of #44152. It includes the condensed regression and the earlier browser-side fix experiment. No second Playwright PR is proposed.
Blocked-by: https://github.com/microsoft/playwright-browsers/issues/2733
Triaged on macOS by the Playwright bot - agent run