Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions test/common/wpt.js
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,7 @@ class WPTRunner {
switch (name) {
case 'Window': {
this.globalThisInitScripts.push('globalThis.Window = Object.getPrototypeOf(globalThis).constructor;');
this.globalThisInitScripts.push('globalThis.GLOBAL.isWindow = () => true;');
break;
}

Expand Down
1 change: 1 addition & 0 deletions test/common/wpt/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ if (workerData.needsGc) {
globalThis.self = global;
globalThis.GLOBAL = {
isWindow() { return false; },
isWorker() { return false; },
isShadowRealm() { return false; },
};
globalThis.require = require;
Expand Down
3 changes: 2 additions & 1 deletion test/fixtures/wpt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ Last update:
- dom/abort: https://github.com/web-platform-tests/wpt/tree/dc928169ee/dom/abort
- dom/events: https://github.com/web-platform-tests/wpt/tree/0a811c5161/dom/events
- encoding: https://github.com/web-platform-tests/wpt/tree/1ac8deee08/encoding
- fetch/api: https://github.com/web-platform-tests/wpt/tree/75b487b9ed/fetch/api
- fetch/data-urls/resources: https://github.com/web-platform-tests/wpt/tree/7c79d998ff/fetch/data-urls/resources
- FileAPI: https://github.com/web-platform-tests/wpt/tree/7f51301888/FileAPI
- hr-time: https://github.com/web-platform-tests/wpt/tree/34cafd797e/hr-time
- html/webappapis/atob: https://github.com/web-platform-tests/wpt/tree/f267e1dca6/html/webappapis/atob
- html/webappapis/microtask-queuing: https://github.com/web-platform-tests/wpt/tree/2c5c3c4c27/html/webappapis/microtask-queuing
- html/webappapis/structured-clone: https://github.com/web-platform-tests/wpt/tree/47d3fb280c/html/webappapis/structured-clone
- html/webappapis/timers: https://github.com/web-platform-tests/wpt/tree/5873f2d8f1/html/webappapis/timers
- interfaces: https://github.com/web-platform-tests/wpt/tree/e1b27be06b/interfaces
- interfaces: https://github.com/web-platform-tests/wpt/tree/b619cb7f23/interfaces
- performance-timeline: https://github.com/web-platform-tests/wpt/tree/94caab7038/performance-timeline
- resource-timing: https://github.com/web-platform-tests/wpt/tree/22d38586d0/resource-timing
- resources: https://github.com/web-platform-tests/wpt/tree/1d2c5fb36a/resources
Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/wpt/fetch/api/abort/WEB_FEATURES.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
features:
- name: abortable-fetch
files: "**"
47 changes: 47 additions & 0 deletions test/fixtures/wpt/fetch/api/abort/cache.https.any.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// META: title=Request signals & the cache API
// META: global=window,worker

promise_test(async () => {
await caches.delete('test');
const controller = new AbortController();
const signal = controller.signal;
const request = new Request('../resources/data.json', { signal });

const cache = await caches.open('test');
await cache.put(request, new Response(''));

const requests = await cache.keys();

assert_equals(requests.length, 1, 'Ensuring cleanup worked');

const [cachedRequest] = requests;

controller.abort();

assert_false(cachedRequest.signal.aborted, "Request from cache shouldn't be aborted");

const data = await fetch(cachedRequest).then(r => r.json());
assert_equals(data.key, 'value', 'Fetch fully completes');
}, "Signals are not stored in the cache API");

promise_test(async () => {
await caches.delete('test');
const controller = new AbortController();
const signal = controller.signal;
const request = new Request('../resources/data.json', { signal });
controller.abort();

const cache = await caches.open('test');
await cache.put(request, new Response(''));

const requests = await cache.keys();

assert_equals(requests.length, 1, 'Ensuring cleanup worked');

const [cachedRequest] = requests;

assert_false(cachedRequest.signal.aborted, "Request from cache shouldn't be aborted");

const data = await fetch(cachedRequest).then(r => r.json());
assert_equals(data.key, 'value', 'Fetch fully completes');
}, "Signals are not stored in the cache API, even if they're already aborted");
27 changes: 27 additions & 0 deletions test/fixtures/wpt/fetch/api/abort/destroyed-context.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<meta charset="utf-8">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
// This is a regression test for crbug.com/860063.
window.controller = new AbortController();
async_test(t => {
onmessage = t.step_func(event => {
assert_equals(event.data, 'started');
const iframe = document.querySelector('iframe');
document.body.removeChild(iframe);
controller.abort();
t.done();
});
}, 'aborting a fetch in a destroyed context should not crash');
</script>
<iframe srcdoc="
<!DOCTYPE html>
<meta charset=utf-8>
<script>
fetch('../resources/infinite-slow-response.py', { signal: parent.controller.signal }).then(() => {
parent.postMessage('started', '*');
});
</script>
">
</iframe>
Loading
Loading