Skip to content

🐛 Accept application-created TrustedScriptURL worker URLs - #5233

Draft
theinterned wants to merge 1 commit into
DataDog:mainfrom
theinterned:theinterned/trusted-worker-url
Draft

theinterned wants to merge 1 commit into
DataDog:mainfrom
theinterned:theinterned/trusted-worker-url

Conversation

@theinterned

Copy link
Copy Markdown

Motivation

Applications that enforce Trusted Types and own their worker policy cannot pass a genuine TrustedScriptURL through workerUrl: configuration currently rejects it as a non-string. This also affects intake compression with Session Replay disabled.

Changes

  • Accept string | TrustedScriptURL, using the native trustedTypes.isScriptURL() brand check rather than accepting arbitrary stringifiable objects.
  • Preserve the trusted object through configuration, getInitConfiguration(), and the Worker constructor. Keep existing string and absent-value behavior.
  • Add unit coverage and a Chromium scenario that delivers a compressed RUM action under require-trusted-types-for 'script', with Session Replay sampling set to zero.

This is limited to application-created worker URLs. It creates no SDK policy or worker-factory API and does not address lazy chunks or the asynchronous CDN snippet. The implementation and tests were AI-assisted.

Test instructions

yarn test:unit \
  --spec packages/browser-rum-core/src/domain/configuration/configuration.spec.ts \
  --spec packages/browser-rum-core/src/boot/rumPublicApi.spec.ts \
  --spec packages/browser-rum/src/domain/deflate/deflateWorker.spec.ts
yarn test:e2e transport.scenario.ts -g 'TrustedScriptURL worker'

Locally: 227 unit tests passed; the Chromium scenario passed against freshly built production bundles. Type checking and focused lint/format checks passed. The local browser runner used installed Chrome, allowed static serving from a hidden checkout directory, and omitted unrelated app servers.

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

Validate workerUrl using the native Trusted Types brand check and preserve its identity through configuration and Worker construction.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@theinterned
theinterned requested a review from a team as a code owner November 3, 2026 20:07
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@datadog-official datadog-official Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bits Code Review: PASS

More details

Application-created TrustedScriptURL values are preserved through configuration and Worker construction, while arbitrary stringifiable objects remain rejected. Static review identified no actionable defect.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit 9e429e3

@theinterned
theinterned marked this pull request as draft November 3, 2026 22:55

This branch has not been deployed

No deployments
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.

1 participant