Skip to content

Add WPT target for html/webappapis/structured-clone - #8135

Merged
npaun merged 1 commit into
automatic-update-wptfrom
npaun/wpt-html-structured-clone
Nov 2, 2026
Merged

npaun merged 1 commit into
automatic-update-wptfrom
npaun/wpt-html-structured-clone

Conversation

@npaun

@npaun npaun commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

Adds a WPT target for html/webappapis/structured-clone: 117 of 135 subtests pass and 18 are expected failures.

  • The ImageBitmap and OffscreenCanvas subtests are omitted because workerd has no canvas APIs.

The expected failures:

  • The enhanced_error_serialization compat flag copies an error's custom own properties, and gives an Error with an empty message its own message property. The spec does neither, but workerd does this on purpose.
  • File can't be cloned, although Blob can.
  • structuredClone(new Response()) succeeds; the spec requires a DataCloneError.
  • Only ArrayBuffers can be transferred. Transferring a MessagePort or ReadableStream throws a TypeError, and so does transferring a Blob, which should be a DataCloneError.
  • Transferring an ArrayBuffer that is already detached succeeds instead of throwing.
  • "Growable SharedArrayBuffer" fails because of a bug in the test: it checks a SharedArrayBuffer with instanceof ArrayBuffer, which is never true.

@npaun
npaun marked this pull request as ready for review November 1, 2026 23:04
@npaun
npaun requested review from a team as code owners November 1, 2026 23:04
clanky-the-clanker[bot]

This comment was marked as outdated.

@npaun
npaun force-pushed the npaun/wpt-html-structured-clone branch from 476815d to 1c630d3 Compare November 2, 2026 01:26

@clanky-the-clanker clanky-the-clanker 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.

💬 Approved with comments — The test configuration is clean and every expected failure is explained. One optional comment-wording suggestion remains.

Findings: 1 suggestion

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


📝 Documentation: 💬 1 suggestion

One wording suggestion remains: the comment does not say the transfer limitation is specific to workerd.

Recommendation: 💬 Optional Nits

  • [SUGGESTION] Say that the transfer limitation is specific to workerd (e.g. "workerd's structuredClone can only transfer ArrayBuffers"). As written, the comment suggests the standard API only supports transferring ArrayBuffers. (src/wpt/html/webappapis/structured-clone-test.ts:45)
View full review
  • src/wpt/html/webappapis/structured-clone-test.ts:45-46: "structuredClone can only transfer ArrayBuffers" can be read as a statement about the API in general. The standard also allows transferring MessagePorts and ReadableStreams. Saying "workerd's structuredClone" would make it clear that this is a workerd limitation.

✅ All other checks passed

📋 Code Quality: ✅ LGTM

The new html/webappapis/structured-clone target in src/wpt/BUILD.bazel is correct. The module is listed as both wpt_directory and extra_wpt_directories on purpose: build/wpt_test.bzl removes the duplicate from data and still binds the module under its absolute path. The tests' META: script=/html/webappapis/structured-clone/... lines need that path. In the test config, the battery helper files are omitted and every expected failure has a comment explaining it.


Reviewed commit: 1c630d35

@codecov-commenter

codecov-commenter commented Nov 2, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (automatic-update-wpt@3f9d2b6). Learn more about missing BASE report.

Additional details and impacted files
@@                   Coverage Diff                   @@
##             automatic-update-wpt    #8135   +/-   ##
=======================================================
  Coverage                        ?   68.31%           
=======================================================
  Files                           ?      726           
  Lines                           ?   189662           
  Branches                        ?    29672           
=======================================================
  Hits                            ?   129568           
  Misses                          ?    42719           
  Partials                        ?    17375           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Runs the structuredClone() battery of tests
(structured-clone.any.js), which clones and transfers primitives,
wrappers, dates, regexps, errors, buffers, views, Blobs, Files,
MessagePorts and more. The three battery helper files that discovery
picks up are omitted.

117 of 135 subtests pass; 18 are expected failures and 2 (ImageBitmap,
OffscreenCanvas) are omitted because workerd has no canvas APIs.

The expected failures fall into these groups:
- enhanced_error_serialization deliberately clones custom error
  properties (8 subtests).
- File is not serializable, although Blob is.
- structuredClone(new Response()) succeeds instead of throwing a
  DataCloneError.
- Only ArrayBuffers can be transferred: MessagePort and ReadableStream
  transfers throw TypeError, and transferring a Blob throws TypeError
  instead of a DataCloneError.
- Transferring a detached ArrayBuffer succeeds.
- "Growable SharedArrayBuffer" compares a SharedArrayBuffer with
  `instanceof ArrayBuffer`, which only passes in browsers because they
  refuse to clone SABs without cross-origin isolation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@npaun
npaun force-pushed the npaun/wpt-html-structured-clone branch from 1c630d3 to c815485 Compare November 2, 2026 02:16
@npaun
npaun merged commit f82d7af into automatic-update-wpt Nov 2, 2026
18 checks passed
@npaun
npaun deleted the npaun/wpt-html-structured-clone branch November 2, 2026 02:16
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.

3 participants