Skip to content

Commit 9c3f34c

Browse files
authored
feat: WPT runner (nodejs#1662)
* feat: WPT runner * fix: add runner to ci
1 parent e5e5b97 commit 9c3f34c

File tree

7 files changed

+5198
-2
lines changed

7 files changed

+5198
-2
lines changed

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,14 @@
4646
"build:wasm": "node build/wasm.js --docker",
4747
"lint": "standard | snazzy",
4848
"lint:fix": "standard --fix | snazzy",
49-
"test": "npm run test:tap && npm run test:node-fetch && npm run test:fetch && npm run test:jest && tsd",
49+
"test": "npm run test:tap && npm run test:node-fetch && npm run test:fetch && npm run test:wpt && npm run test:jest && tsd",
5050
"test:node-fetch": "node scripts/verifyVersion.js 16 || mocha test/node-fetch",
5151
"test:fetch": "node scripts/verifyVersion.js 16 || (npm run build:node && tap test/fetch/*.js && tap test/webidl/*.js)",
5252
"test:jest": "node scripts/verifyVersion.js 14 || jest",
5353
"test:tap": "tap test/*.js test/diagnostics-channel/*.js",
5454
"test:tdd": "tap test/*.js test/diagnostics-channel/*.js -w",
5555
"test:typescript": "tsd",
56+
"test:wpt": "node scripts/verifyVersion 18 || node test/wpt/runner/start.mjs",
5657
"coverage": "nyc --reporter=text --reporter=html npm run test",
5758
"coverage:ci": "nyc --reporter=lcov npm run test",
5859
"bench": "PORT=3042 concurrently -k -s first npm:bench:server npm:bench:run",
@@ -106,7 +107,9 @@
106107
],
107108
"ignore": [
108109
"lib/llhttp/constants.js",
109-
"lib/llhttp/utils.js"
110+
"lib/llhttp/utils.js",
111+
"test/wpt/runner/fetch",
112+
"test/wpt/runner/resources"
110113
]
111114
},
112115
"tsd": {
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
[
2+
() => new Request("about:blank", { headers: { "Content-Type": "text/plain" } }),
3+
() => new Response("", { headers: { "Content-Type": "text/plain" } })
4+
].forEach(bodyContainerCreator => {
5+
const bodyContainer = bodyContainerCreator();
6+
promise_test(async t => {
7+
assert_equals(bodyContainer.headers.get("Content-Type"), "text/plain");
8+
const newMIMEType = "test/test";
9+
bodyContainer.headers.set("Content-Type", newMIMEType);
10+
const blob = await bodyContainer.blob();
11+
assert_equals(blob.type, newMIMEType);
12+
}, `${bodyContainer.constructor.name}: overriding explicit Content-Type`);
13+
});
14+
15+
[
16+
() => new Request("about:blank", { body: new URLSearchParams(), method: "POST" }),
17+
() => new Response(new URLSearchParams()),
18+
].forEach(bodyContainerCreator => {
19+
const bodyContainer = bodyContainerCreator();
20+
promise_test(async t => {
21+
assert_equals(bodyContainer.headers.get("Content-Type"), "application/x-www-form-urlencoded;charset=UTF-8");
22+
bodyContainer.headers.delete("Content-Type");
23+
const blob = await bodyContainer.blob();
24+
assert_equals(blob.type, "");
25+
}, `${bodyContainer.constructor.name}: removing implicit Content-Type`);
26+
});
27+
28+
[
29+
() => new Request("about:blank", { body: new ArrayBuffer(), method: "POST" }),
30+
() => new Response(new ArrayBuffer()),
31+
].forEach(bodyContainerCreator => {
32+
const bodyContainer = bodyContainerCreator();
33+
promise_test(async t => {
34+
assert_equals(bodyContainer.headers.get("Content-Type"), null);
35+
const newMIMEType = "test/test";
36+
bodyContainer.headers.set("Content-Type", newMIMEType);
37+
const blob = await bodyContainer.blob();
38+
assert_equals(blob.type, newMIMEType);
39+
}, `${bodyContainer.constructor.name}: setting missing Content-Type`);
40+
});

0 commit comments

Comments
 (0)