Skip to content

Comments

test: enable wpt fetch/api idlharness tests#61940

Closed
vitkarpov wants to merge 1 commit intonodejs:mainfrom
vitkarpov:issue-45099-enable-wpt-fetch-api-idlharness-tests
Closed

test: enable wpt fetch/api idlharness tests#61940
vitkarpov wants to merge 1 commit intonodejs:mainfrom
vitkarpov:issue-45099-enable-wpt-fetch-api-idlharness-tests

Conversation

@vitkarpov
Copy link
Contributor

Refs: #45099

Summary

Enables fetch/api/idlharness.https.any.js from the WPT suite in Node's test runner. This test formally documents the property descriptor regression reported in #45099 β€” Headers, Request, and Response are currently exposed on globalThis as getter/setter accessor pairs rather than plain { value, writable, enumerable: false, configurable: true } data properties as required by WebIDL.

Enabling the test with known failures as fail.expected creates a CI gate so the regression can't silently worsen and the fix (targeted in a follow-up PR, if you guys think this work makes sense) will be verified automatically.


Changes

WPT fixture sync (git node wpt fetch/api + git node wpt interfaces)

  • Adds test/fixtures/wpt/fetch/api/ β€” the full upstream fetch/api test tree
  • Adds test/fixtures/wpt/interfaces/fetch.idl and referrer-policy.idl β€” required by the
    idlharness test's idl_test(['fetch'], ['referrer-policy', 'html', 'dom'], ...) call
  • Updates other interfaces/*.idl files and versions.json to match the synced commit

New test driver (test/wpt/test-fetch.js)

  • Runs fetch/api with pretendGlobalThisAs('Window') since the idlharness test branches on
    self.GLOBAL.isWindow()

New status file (test/wpt/status/fetch/api.json)

  • 110 server-dependent test files marked skip: "Requires a WPT HTTP server" β€” these tests need
    a running wptserve/Python backend and are already covered in nodejs/undici's WPT CI
    (see comment in test/common/wpt/worker.js)
  • idlharness.https.any.js gets 15 fail.expected entries:
    • 3 for the Headers, Request, Response property descriptor bug (FormData, Response, Request, and Headers have incorrect property descriptorsΒ #45099)
    • 5 for FetchLaterResult (unimplemented API)
    • 2 for Window: fetchLater instance checks (unimplemented API)
    • 2 for Window: fetch instance checks (lazy accessor means fetch is an own property of
      globalThis, not prototype-inherited as idlharness expects)
    • 1 for Window: operation fetchLater (unimplemented API)

WPT runner infrastructure fixes (test/common/wpt/worker.js, test/common/wpt.js)

worker.js defined globalThis.GLOBAL without isWorker():

globalThis.GLOBAL = {
   isWindow() { return false; },
+  isWorker() { return false; },
   isShadowRealm() { return false; },
};

Any test calling self.GLOBAL.isWorker() would throw TypeError: self.GLOBAL.isWorker is not a function. The test/wpt/test-hr-time.js driver was already working around this by patching it in an init script; that workaround remains but is now redundant.

pretendGlobalThisAs('Window') in wpt.js was setting globalThis.Window but leaving GLOBAL.isWindow() returning false, so tests pretending to be a Window context still reported themselves as non-Window. Fixed by pushing globalThis.GLOBAL.isWindow = () => true alongside the existing globalThis.Window assignment.


Test result

Ran 27/138 tests, 111 skipped, 26 passed, 1 expected failures, 0 unexpected failures, 0 unexpected passes

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/web-standards

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. test Issues and PRs related to the tests. labels Feb 22, 2026
Enables fetch/api/idlharness.https.any.js from the WPT suite in
Node's test runner. This test formally documents the property
descriptor regression reported in nodejs#45099 β€” Headers, Request, and
Response are currently exposed on globalThis as getter/setter
accessor pairs rather than plain { value, writable, enumerable:
false, configurable: true } data properties as required by WebIDL.
@vitkarpov vitkarpov force-pushed the issue-45099-enable-wpt-fetch-api-idlharness-tests branch from f02ef88 to 45ee342 Compare February 22, 2026 15:07
@vitkarpov vitkarpov closed this Feb 22, 2026
@vitkarpov vitkarpov deleted the issue-45099-enable-wpt-fetch-api-idlharness-tests branch February 22, 2026 16:00
@codecov
Copy link

codecov bot commented Feb 22, 2026

Codecov Report

βœ… All modified and coverable lines are covered by tests.
βœ… Project coverage is 89.77%. Comparing base (da5efc4) to head (45ee342).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #61940      +/-   ##
==========================================
+ Coverage   88.84%   89.77%   +0.92%     
==========================================
  Files         674      674              
  Lines      204957   204957              
  Branches    39309    39381      +72     
==========================================
+ Hits       182087   183990    +1903     
+ Misses      15088    13271    -1817     
+ Partials     7782     7696      -86     

see 105 files with indirect coverage changes

πŸš€ 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ci PRs that need a full CI run. test Issues and PRs related to the tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants