Skip to content

Commit f02ef88

Browse files
committed
test: enable wpt fetch/api idlharness tests
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.
1 parent da5efc4 commit f02ef88

File tree

273 files changed

+13526
-606
lines changed

Some content is hidden

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

273 files changed

+13526
-606
lines changed

test/common/wpt.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,7 @@ class WPTRunner {
624624
switch (name) {
625625
case 'Window': {
626626
this.globalThisInitScripts.push('globalThis.Window = Object.getPrototypeOf(globalThis).constructor;');
627+
this.globalThisInitScripts.push('globalThis.GLOBAL.isWindow = () => true;');
627628
break;
628629
}
629630

test/common/wpt/worker.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ if (workerData.needsGc) {
1616
globalThis.self = global;
1717
globalThis.GLOBAL = {
1818
isWindow() { return false; },
19+
isWorker() { return false; },
1920
isShadowRealm() { return false; },
2021
};
2122
globalThis.require = require;

test/fixtures/wpt/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@ Last update:
1616
- dom/abort: https://github.com/web-platform-tests/wpt/tree/dc928169ee/dom/abort
1717
- dom/events: https://github.com/web-platform-tests/wpt/tree/0a811c5161/dom/events
1818
- encoding: https://github.com/web-platform-tests/wpt/tree/1ac8deee08/encoding
19+
- fetch/api: https://github.com/web-platform-tests/wpt/tree/75b487b9ed/fetch/api
1920
- fetch/data-urls/resources: https://github.com/web-platform-tests/wpt/tree/7c79d998ff/fetch/data-urls/resources
2021
- FileAPI: https://github.com/web-platform-tests/wpt/tree/7f51301888/FileAPI
2122
- hr-time: https://github.com/web-platform-tests/wpt/tree/34cafd797e/hr-time
2223
- html/webappapis/atob: https://github.com/web-platform-tests/wpt/tree/f267e1dca6/html/webappapis/atob
2324
- html/webappapis/microtask-queuing: https://github.com/web-platform-tests/wpt/tree/2c5c3c4c27/html/webappapis/microtask-queuing
2425
- html/webappapis/structured-clone: https://github.com/web-platform-tests/wpt/tree/47d3fb280c/html/webappapis/structured-clone
2526
- html/webappapis/timers: https://github.com/web-platform-tests/wpt/tree/5873f2d8f1/html/webappapis/timers
26-
- interfaces: https://github.com/web-platform-tests/wpt/tree/e1b27be06b/interfaces
27+
- interfaces: https://github.com/web-platform-tests/wpt/tree/b619cb7f23/interfaces
2728
- performance-timeline: https://github.com/web-platform-tests/wpt/tree/94caab7038/performance-timeline
2829
- resource-timing: https://github.com/web-platform-tests/wpt/tree/22d38586d0/resource-timing
2930
- resources: https://github.com/web-platform-tests/wpt/tree/1d2c5fb36a/resources
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
features:
2+
- name: abortable-fetch
3+
files: "**"
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// META: title=Request signals & the cache API
2+
// META: global=window,worker
3+
4+
promise_test(async () => {
5+
await caches.delete('test');
6+
const controller = new AbortController();
7+
const signal = controller.signal;
8+
const request = new Request('../resources/data.json', { signal });
9+
10+
const cache = await caches.open('test');
11+
await cache.put(request, new Response(''));
12+
13+
const requests = await cache.keys();
14+
15+
assert_equals(requests.length, 1, 'Ensuring cleanup worked');
16+
17+
const [cachedRequest] = requests;
18+
19+
controller.abort();
20+
21+
assert_false(cachedRequest.signal.aborted, "Request from cache shouldn't be aborted");
22+
23+
const data = await fetch(cachedRequest).then(r => r.json());
24+
assert_equals(data.key, 'value', 'Fetch fully completes');
25+
}, "Signals are not stored in the cache API");
26+
27+
promise_test(async () => {
28+
await caches.delete('test');
29+
const controller = new AbortController();
30+
const signal = controller.signal;
31+
const request = new Request('../resources/data.json', { signal });
32+
controller.abort();
33+
34+
const cache = await caches.open('test');
35+
await cache.put(request, new Response(''));
36+
37+
const requests = await cache.keys();
38+
39+
assert_equals(requests.length, 1, 'Ensuring cleanup worked');
40+
41+
const [cachedRequest] = requests;
42+
43+
assert_false(cachedRequest.signal.aborted, "Request from cache shouldn't be aborted");
44+
45+
const data = await fetch(cachedRequest).then(r => r.json());
46+
assert_equals(data.key, 'value', 'Fetch fully completes');
47+
}, "Signals are not stored in the cache API, even if they're already aborted");
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!DOCTYPE html>
2+
<meta charset="utf-8">
3+
<script src="/resources/testharness.js"></script>
4+
<script src="/resources/testharnessreport.js"></script>
5+
<script>
6+
// This is a regression test for crbug.com/860063.
7+
window.controller = new AbortController();
8+
async_test(t => {
9+
onmessage = t.step_func(event => {
10+
assert_equals(event.data, 'started');
11+
const iframe = document.querySelector('iframe');
12+
document.body.removeChild(iframe);
13+
controller.abort();
14+
t.done();
15+
});
16+
}, 'aborting a fetch in a destroyed context should not crash');
17+
</script>
18+
<iframe srcdoc="
19+
<!DOCTYPE html>
20+
<meta charset=utf-8>
21+
<script>
22+
fetch('../resources/infinite-slow-response.py', { signal: parent.controller.signal }).then(() => {
23+
parent.postMessage('started', '*');
24+
});
25+
</script>
26+
">
27+
</iframe>

0 commit comments

Comments
 (0)