Skip to content

Commit 5ceaf61

Browse files
authored
real wpt test server (#4486)
fix(websocketerror): inheriting DOMException on node v24 refs: nodejs/node#59677 fix(websocket, eventsource): properly set event handlers fixup fixup fixup fixup fixup fixup fixup fixup add WPT report fixup fixup catch failures outside of tests expand test expectations add attribution and mark tests as flaky add attribution and mark tests as flaky fixup fixup
1 parent b4019ee commit 5ceaf61

File tree

3,146 files changed

+45064
-210225
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,146 files changed

+45064
-210225
lines changed

.github/dependabot.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,3 @@ updates:
2828
directory: /build
2929
schedule:
3030
interval: daily
31-
32-
- package-ecosystem: pip
33-
directory: /test/wpt/tests/resources/test
34-
schedule:
35-
interval: daily

.github/workflows/codeql.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
strategy:
3636
fail-fast: false
3737
matrix:
38-
language: ["javascript", "python", "typescript"]
38+
language: ["javascript", "typescript"]
3939
# CodeQL supports [ $supported-codeql-languages ]
4040
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
4141

.github/workflows/nodejs.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ jobs:
8686
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
8787
with:
8888
persist-credentials: false
89+
submodules: recursive
8990

9091
# Setup node, install deps, and build undici prior to building icu-less node and testing
9192
- name: Setup Node.js@${{ inputs.version }}
@@ -140,6 +141,19 @@ jobs:
140141
echo git: $(git --version)
141142
echo icu config: $(node -e "console.log(process.config)" | grep icu)
142143
144+
- name: Configure hosts file for WPT (Windows)
145+
if: runner.os == 'Windows'
146+
run: |
147+
cd ${{ github.workspace }}\test\web-platform-tests\wpt
148+
python wpt make-hosts-file | Out-File $env:SystemRoot\System32\drivers\etc\hosts -Encoding ascii -Append
149+
shell: powershell
150+
151+
- name: Configure hosts file for WPT (Unix)
152+
if: runner.os != 'Windows'
153+
run: |
154+
cd ${{ github.workspace }}/test/web-platform-tests/wpt
155+
python3 wpt make-hosts-file | sudo tee -a /etc/hosts
156+
143157
- name: Run tests
144158
run: npm run test:javascript:without-intl
145159

.github/workflows/test.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ jobs:
2323
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
2424
with:
2525
persist-credentials: false
26+
submodules: recursive
2627

2728
- name: Setup Node.js@${{ inputs.node-version }}
2829
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
@@ -43,6 +44,19 @@ jobs:
4344
run: npm ls --all
4445
continue-on-error: true
4546

47+
- name: Configure hosts file for WPT (Windows)
48+
if: runner.os == 'Windows'
49+
run: |
50+
cd ${{ github.workspace }}\test\web-platform-tests\wpt
51+
python wpt make-hosts-file | Out-File $env:SystemRoot\System32\drivers\etc\hosts -Encoding ascii -Append
52+
shell: powershell
53+
54+
- name: Configure hosts file for WPT (Unix)
55+
if: runner.os != 'Windows'
56+
run: |
57+
cd ${{ github.workspace }}/test/web-platform-tests/wpt
58+
python3 wpt make-hosts-file | sudo tee -a /etc/hosts
59+
4660
- name: Run tests with coverage
4761
id: coverage
4862
if: inputs.runs-on == 'ubuntu-latest' && inputs.node-version == 22

.github/workflows/update-wpt.yml

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,9 @@ jobs:
1919
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
2020
git config --global user.name "github-actions[bot]"
2121
22-
- name: Checkout Repository
23-
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
2422
- name: Update WPT
2523
run: |
26-
rm -rf test/fixtures/wpt && mkdir test/fixtures/wpt &&
27-
28-
git clone https://github.com/web-platform-tests/wpt.git --depth=1 test/fixtures/tmp-wpt &&
29-
30-
mv test/fixtures/tmp-wpt/LICENSE.md test/fixtures/wpt/LICENSE.md &&
31-
32-
mv test/fixtures/tmp-wpt/common test/fixtures/wpt/common &&
33-
mv test/fixtures/tmp-wpt/eventsource test/fixtures/wpt/eventsource &&
34-
mv test/fixtures/tmp-wpt/fetch test/fixtures/wpt/fetch &&
35-
mv test/fixtures/tmp-wpt/interfaces test/fixtures/wpt/interfaces &&
36-
mv test/fixtures/tmp-wpt/mimesniff test/fixtures/wpt/mimesniff &&
37-
mv test/fixtures/tmp-wpt/resources test/fixtures/wpt/resources &&
38-
mv test/fixtures/tmp-wpt/service-workers test/fixtures/wpt/service-workers &&
39-
mv test/fixtures/tmp-wpt/storage test/fixtures/wpt/storage &&
40-
mv test/fixtures/tmp-wpt/websockets test/fixtures/wpt/websockets &&
41-
mv test/fixtures/tmp-wpt/xhr test/fixtures/wpt/xhr &&
42-
43-
rm -rf test/fixtures/tmp-wpt
24+
git submodule update --init --recursive
4425
- name: Create Pull Request
4526
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
4627
with:

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "test/web-platform-tests/wpt"]
2+
path = test/web-platform-tests/wpt
3+
url = https://github.com/web-platform-tests/wpt.git

CONTRIBUTING.md

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -94,34 +94,50 @@ Create a commit which includes all of the updated files in lib/llhttp.
9494

9595
`undici` runs a subset of the [`web-platform-tests`](https://github.com/web-platform-tests/wpt).
9696

97-
### Requirements:
98-
- [Node core utils](https://github.com/nodejs/node-core-utils) setup with credentials.
99-
100-
To update every test, run the following commands. Typically you would only need to update the tests in a specific directory.
97+
### Steps:
10198

10299
```bash
103-
git node wpt resources
104-
git node wpt interfaces
105-
git node wpt common
106-
git node wpt fetch
107-
git node wpt xhr
108-
git node wpt websockets
109-
git node wpt mimesniff
110-
git node wpt storage
111-
git node wpt service-workers
112-
git node wpt eventsource
100+
git submodule update --init --recursive
113101
```
114102

115-
#### Run the tests
103+
### Run the tests
116104

117105
Run the tests to ensure that any new failures are marked as such.
118106

119-
You can mark tests as failing in their corresponding [status](./test/wpt/status) file.
107+
Before running the tests for the first time, you must setup the testing environment.
108+
```bash
109+
cd test/web-platform-tests
110+
node wpt-runner.mjs setup
111+
```
112+
113+
To run all tests:
120114

121115
```bash
122116
npm run test:wpt
123117
```
124118

119+
To run a subset of tests:
120+
```bash
121+
cd test/web-platform-tests
122+
node wpt-runner.mjs run [filter] [filterb]
123+
```
124+
125+
To run a single file:
126+
```bash
127+
cd test/web-platform-tests
128+
node wpt-runner.mjs run /path/to/test
129+
```
130+
131+
### Debugging
132+
133+
Verbose logging can be enabled by setting the [`NODE_DEBUG`](https://nodejs.org/api/cli.html#node_debugmodule) flag:
134+
135+
```bash
136+
npx cross-env NODE_DEBUG=UNDICI_WPT node --run test:wpt
137+
```
138+
139+
(`npx cross-env` can be omitted on Linux and Mac)
140+
125141
<a id="lint"></a>
126142
### Lint
127143

eslint.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ module.exports = [
77
...neo({
88
ignores: [
99
'lib/llhttp',
10-
'test/fixtures/wpt',
1110
'test/fixtures/cache-tests',
12-
'undici-fetch.js'
11+
'undici-fetch.js',
12+
'test/web-platform-tests/wpt'
1313
],
1414
noJsx: true,
1515
ts: true

index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,6 @@ module.exports.getGlobalOrigin = getGlobalOrigin
139139
const { CacheStorage } = require('./lib/web/cache/cachestorage')
140140
const { kConstruct } = require('./lib/core/symbols')
141141

142-
// Cache & CacheStorage are tightly coupled with fetch. Even if it may run
143-
// in an older version of Node, it doesn't have any use without fetch.
144142
module.exports.caches = new CacheStorage(kConstruct)
145143

146144
const { deleteCookie, getCookies, getSetCookies, setCookie, parseCookie } = require('./lib/web/cookies')

lib/web/eventsource/eventsource-stream.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ class EventSourceStream extends Transform {
236236
this.buffer = this.buffer.subarray(this.pos + 1)
237237
this.pos = 0
238238
if (
239-
this.event.data !== undefined || this.event.event || this.event.id || this.event.retry) {
239+
this.event.data !== undefined || this.event.event || this.event.id !== undefined || this.event.retry) {
240240
this.processEvent(this.event)
241241
}
242242
this.clearEvent()
@@ -367,7 +367,7 @@ class EventSourceStream extends Transform {
367367
this.state.reconnectionTime = parseInt(event.retry, 10)
368368
}
369369

370-
if (event.id && isValidLastEventId(event.id)) {
370+
if (event.id !== undefined && isValidLastEventId(event.id)) {
371371
this.state.lastEventId = event.id
372372
}
373373

0 commit comments

Comments
 (0)