Repository navigation
test(octane): cover Trusted Types hydration, streamed table/SVG boundaries and deferred activation - #2224
Merged
Conversation
Re-lands #2162. It merged into `next` on 2026-10-20, after #2103 had already integrated `next` into `main`, and `next` was then deleted, so the change never reached `main`. This is the #2162 squash commit (424e5cc) cherry-picked onto `main` without changes. A TrustedHTML, TrustedScript, or TrustedScriptURL passed to dangerouslySetInnerHTML or an attribute now reaches its DOM sink as the object, as in React 19.3, so it works under an enforced require-trusted-types-for 'script' CSP. Markup Octane parses itself (compiled templates, binding fragments, streamed regions) goes through a module-private `octane` policy, created at module load with the native `String` as its rule, and the streaming bootstrap's JSON carrier through `octane-stream`. Application strings never go through either. Refs #2053. Co-Authored-By: Claude Opus 5.5 <[email protected]>
main's test config rejects reading a server fixture's export through its index signature, so name the fixture module type, as other tests do. Co-Authored-By: Claude Opus 5.5 <[email protected]>
setScriptText updated an existing Text node in place, so after the first write a TrustedScript never reached the script's textContent sink, and under enforcement a string update was not rejected. An unchanged body still writes nothing; a changed one now always assigns textContent. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…aries and deferred activation Run the enforced `require-trusted-types-for 'script'` browser suite, which has no default policy, over the cases the streaming design doc lists: hydrateRoot of renderToString output, a streamed page whose <tbody> and <svg> boundaries reveal after the shell hydrates, and a deferred <Hydrate> boundary that a click activates. Each page then mounts fresh table and SVG content and rewrites its adopted dangerouslySetInnerHTML. A report-only run checks that the same pages raise no violations. Each case passes in dev and prod bundles and fails when the template, stream-bootstrap, setHTML or dev hydration-compare sink writes a string. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
octane-website-mcp | a66718d | Commit Preview URL Branch Preview URL |
Oct 23 2026, 06:42 PM |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
octane-website | a66718d | Commit Preview URL Branch Preview URL |
Oct 23 2026, 06:41 PM |
…verage # Conflicts: # packages/octane/tests/browser/trusted-types/app.tsrx # packages/octane/tests/browser/trusted-types/client.ts # packages/octane/tests/browser/trusted-types/trusted-types.test.ts
trueadm
marked this pull request as ready for review
October 23, 2026 18:39
Contributor
Benchmark report🟢 No byte growth, no added work, and no timing changes beyond ±3%. Compares js-framework: 1k/10k row operationsAll 20 timed operations (20 without a verdict)
All 64 work counters are unchanged. Application bundle size (bytes)No changes across 111 measured values. Public-import reachability bundles (bytes)No changes across 123 measured values. |
6 of 9 tasks
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.
Summary
Follows #2221, the re-land of Trusted Types support (#2162) on
main. #2221 has merged, and this PR now targetsmainwith only its test changes.This extends the enforced Trusted Types browser suite to the cases that
docs/async-signals-streaming-ssr.md(Trusted Types compatibility) lists and #2162 did not test. Every case runs underrequire-trusted-types-for 'script'; trusted-types octane octane-stream app, with no default policy, in both development and production bundles:hydrateRoot: hydratesrenderToStringoutput.<tbody>and one inside<svg>are still pending. Both segments then reveal through theoctane-streamJSON carrier and hydrate.<Hydrate when={interaction({ events: 'click' })}>stays dormant until a click activates it, then replays the click.Content-Security-Policy-Report-Onlyvisits all three pages and asserts zero violations.After hydration, each page mounts a fresh
<tr>in<tbody>and a fresh<rect>in<svg>, so their templates parse in table and SVG context. It also rewrites the adopteddangerouslySetInnerHTMLwith the application's TrustedHTML.Each case asserts:
securitypolicyviolation;The tests found no Octane sink writing a string on these paths, so this PR has no source change.
Validation
pnpm format:check: not run repo-wide.pnpm format:files:check packages/octane/tests/browser/trusted-types/passes.pnpm typecheck: not run. Browser tests are outside every typecheck program (packages/octane/tsconfig.jsonexcludestests).pnpm typecheck:fileson the three files reports only the two pre-existingexactOptionalPropertyTypeserrors in the untouchedtests/_server-fixture.ts, which main's existing browser tests share.pnpm test: not run.targeted tests:
vitest run --project octane-events-browser packages/octane/tests/browser/trusted-types/trusted-types.test.ts. 10/10 pass on the merge with main af767d7 (a66718d), and three consecutive runs on an earlier base were clean.Each case fails against a realistic broken sink. Each sink was reverted temporarily, and the reverts were not committed:
parseTemplate(runtime/templates.ts)octane-streampolicy in the stream bootstrapsetHTMLpassing the string to the dev hydration comparesetHTMLtrustedOrperf-review: not applicable. The diff is test-only.concise-code:trusted-typesfixture, client and test file; there are no new files.app.tsrx:PAGE_HTML,HydratedPage,StreamedPageandDeferredPage, used by the server routes and the client entry.Risk / follow-ups
placeFullRegion(hydration/stream-receiver.ts, fetched regions) and binding-view fragments (dom-binding-program.tscreateFragment). Reverting either breaks nothing here.runtime/head.ts(preinit,preinitModule,<script async src>) assignscript.srca sanitized string.srcis stringified, where React 19.3 likely passes the object through.Provenance
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need.Note
Low Risk
Test-only changes to the trusted-types browser fixture and Playwright suite; no runtime or production code paths are modified.
Overview
Extends the enforced Trusted Types Playwright suite beyond client-only sinks to SSR hydration, streaming, and deferred
<Hydrate>—all underrequire-trusted-types-for 'script'withoctane,octane-stream, andapppolicies, in development and production bundles.The fixture gains
HydratedPage,StreamedPage, andDeferredPage(plus table/SVG rows that mount after a toggle) so the client canhydrateRootserver HTML where the server used a plain string and the app supplies TrustedHTML. The test HTTP server now serves/hydrate,/stream, and/deferred(with a controllable stream release for pending boundaries inside<tbody>and<svg>), and the client entry routes by pathname between the existing client-render path and hydration.New assertions cover no CSP violations, no recoverable hydration errors, DOM adoption of server nodes, correct table/SVG placement, and post-update
dangerouslySetInnerHTMLwith TrustedHTML. A report-only CSP block runs the same hydration scenarios and expects zero violations.Reviewed by Cursor Bugbot for commit d01f53d. Bugbot is set up for automated code reviews on this repo. Configure here.