Skip to content

Commit

Permalink
feat: WPT runner (#1662)
Browse files Browse the repository at this point in the history
* feat: WPT runner

* fix: add runner to ci
  • Loading branch information
KhafraDev authored Sep 23, 2022
1 parent e5e5b97 commit 9c3f34c
Show file tree
Hide file tree
Showing 7 changed files with 5,198 additions and 2 deletions.
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,14 @@
"build:wasm": "node build/wasm.js --docker",
"lint": "standard | snazzy",
"lint:fix": "standard --fix | snazzy",
"test": "npm run test:tap && npm run test:node-fetch && npm run test:fetch && npm run test:jest && tsd",
"test": "npm run test:tap && npm run test:node-fetch && npm run test:fetch && npm run test:wpt && npm run test:jest && tsd",
"test:node-fetch": "node scripts/verifyVersion.js 16 || mocha test/node-fetch",
"test:fetch": "node scripts/verifyVersion.js 16 || (npm run build:node && tap test/fetch/*.js && tap test/webidl/*.js)",
"test:jest": "node scripts/verifyVersion.js 14 || jest",
"test:tap": "tap test/*.js test/diagnostics-channel/*.js",
"test:tdd": "tap test/*.js test/diagnostics-channel/*.js -w",
"test:typescript": "tsd",
"test:wpt": "node scripts/verifyVersion 18 || node test/wpt/runner/start.mjs",
"coverage": "nyc --reporter=text --reporter=html npm run test",
"coverage:ci": "nyc --reporter=lcov npm run test",
"bench": "PORT=3042 concurrently -k -s first npm:bench:server npm:bench:run",
Expand Down Expand Up @@ -106,7 +107,9 @@
],
"ignore": [
"lib/llhttp/constants.js",
"lib/llhttp/utils.js"
"lib/llhttp/utils.js",
"test/wpt/runner/fetch",
"test/wpt/runner/resources"
]
},
"tsd": {
Expand Down
40 changes: 40 additions & 0 deletions test/wpt/runner/fetch/api/body/mime-type.any.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[
() => new Request("about:blank", { headers: { "Content-Type": "text/plain" } }),
() => new Response("", { headers: { "Content-Type": "text/plain" } })
].forEach(bodyContainerCreator => {
const bodyContainer = bodyContainerCreator();
promise_test(async t => {
assert_equals(bodyContainer.headers.get("Content-Type"), "text/plain");
const newMIMEType = "test/test";
bodyContainer.headers.set("Content-Type", newMIMEType);
const blob = await bodyContainer.blob();
assert_equals(blob.type, newMIMEType);
}, `${bodyContainer.constructor.name}: overriding explicit Content-Type`);
});

[
() => new Request("about:blank", { body: new URLSearchParams(), method: "POST" }),
() => new Response(new URLSearchParams()),
].forEach(bodyContainerCreator => {
const bodyContainer = bodyContainerCreator();
promise_test(async t => {
assert_equals(bodyContainer.headers.get("Content-Type"), "application/x-www-form-urlencoded;charset=UTF-8");
bodyContainer.headers.delete("Content-Type");
const blob = await bodyContainer.blob();
assert_equals(blob.type, "");
}, `${bodyContainer.constructor.name}: removing implicit Content-Type`);
});

[
() => new Request("about:blank", { body: new ArrayBuffer(), method: "POST" }),
() => new Response(new ArrayBuffer()),
].forEach(bodyContainerCreator => {
const bodyContainer = bodyContainerCreator();
promise_test(async t => {
assert_equals(bodyContainer.headers.get("Content-Type"), null);
const newMIMEType = "test/test";
bodyContainer.headers.set("Content-Type", newMIMEType);
const blob = await bodyContainer.blob();
assert_equals(blob.type, newMIMEType);
}, `${bodyContainer.constructor.name}: setting missing Content-Type`);
});
Loading

0 comments on commit 9c3f34c

Please sign in to comment.