Skip to content

test(e2e): work around Playwright WebKit click and session bugs#4616

Draft
rgaignault wants to merge 1 commit into
mainfrom
romanG/webkit-e2e-workaround
Draft

test(e2e): work around Playwright WebKit click and session bugs#4616
rgaignault wants to merge 1 commit into
mainfrom
romanG/webkit-e2e-workaround

Conversation

@rgaignault
Copy link
Copy Markdown
Contributor

@rgaignault rgaignault commented May 13, 2026

Motivation

Running the e2e suite with --project=webkit currently fails on some click-action and session-dependent scenario. Two unrelated quirks in Playwright's WebKit fork combine to silently break the SDK:

  1. Trusted PointerEvent.timeStamp returns a Cocoa-epoch-derived value (~8e11 ms) instead of a DOMHighResTimeStamp. The SDK feeds it into relativeToClocks(...) in trackClickActions, computes a click-start ~25 years in the future, and the "clock looks weird" guard discards every click.
  2. window.cookieStore.set() resolves without error but does not persist. The next poll sees an empty cookie, handleStateChange treats it as an expired session within ~50ms, and every later event is dropped by the session/view assembly hook.

Changes

  • Add a WEBKIT_PLAYWRIGHT_WORKAROUND init script in test/e2e/lib/framework/createTest.ts.
  • Apply it via context.addInitScript(...) in declareTest when browserName === 'webkit'.

The workaround wraps Event.prototype.timeStamp to fall back to performance.now() when the raw value is implausibly large (>1 year), and removes window.cookieStore so the SDK takes its document.cookie fallback (which works correctly on Playwright WebKit). Scoped to test infrastructure — no SDK behaviour change.

Test instructions

yarn playwright test --config test/e2e/playwright.config.ts --project=webkit test/e2e/scenario/rum/actions.scenario.ts should pass all three variants. Without this change, all three fail.

Checklist

  • Tested locally
  • Tested on staging
  • Added unit tests for this change.
  • Added e2e/integration tests for this change.
  • Updated documentation and/or relevant AGENTS.md file

@rgaignault rgaignault requested a review from a team as a code owner May 13, 2026 12:48
@cit-pr-commenter-54b7da
Copy link
Copy Markdown

cit-pr-commenter-54b7da Bot commented May 13, 2026

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 169.51 KiB 169.51 KiB 0 B 0.00%
Rum Profiler 5.97 KiB 5.97 KiB 0 B 0.00%
Rum Recorder 21.23 KiB 21.23 KiB 0 B 0.00%
Logs 54.70 KiB 54.70 KiB 0 B 0.00%
Rum Slim 127.85 KiB 127.85 KiB 0 B 0.00%
Worker 22.99 KiB 22.99 KiB 0 B 0.00%
🚀 CPU Performance
Action Name Base CPU Time (ms) Local CPU Time (ms) 𝚫%
RUM - add global context 0.0021 0.0027 +28.57%
RUM - add action 0.0105 0.0158 +50.48%
RUM - add error 0.0097 0.0143 +47.42%
RUM - add timing 0.0004 0.0005 +25.00%
RUM - start view 0.0092 0.0162 +76.09%
RUM - start/stop session replay recording 0.0007 0.001 +42.86%
Logs - log message 0.0139 0.0168 +20.86%
🧠 Memory Performance
Action Name Base Memory Consumption Local Memory Consumption 𝚫
RUM - add global context 38.24 KiB 37.52 KiB -729 B
RUM - add action 64.64 KiB 63.02 KiB -1.62 KiB
RUM - add timing 36.73 KiB 38.20 KiB +1.46 KiB
RUM - add error 70.01 KiB 68.01 KiB -2.00 KiB
RUM - start/stop session replay recording 45.58 KiB 41.24 KiB -4.33 KiB
RUM - start view 483.88 KiB 487.51 KiB +3.64 KiB
Logs - log message 55.00 KiB 54.34 KiB -669 B

🔗 RealWorld

@datadog-datadog-prod-us1
Copy link
Copy Markdown

datadog-datadog-prod-us1 Bot commented May 13, 2026

Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 76.96% (+0.00%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 4f6c97d | Docs | Datadog PR Page | Give us feedback!

@rgaignault rgaignault marked this pull request as draft May 13, 2026 14:53
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.

2 participants