-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Aborting fetch #6484
Aborting fetch #6484
Changes from 11 commits
f6426f7
dafbd68
b076f77
fdf63fc
568ae5d
c1000fc
ee16ec3
3c232fc
c2741a5
e9f1003
3e36e5e
2951a23
b7e0b64
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Request signals & the cache API</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
</head> | ||
<body> | ||
<script> | ||
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"); | ||
</script> | ||
</body> | ||
</html> | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>General fetch abort tests in a service worker</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
</head> | ||
<body> | ||
<script> | ||
(async function() { | ||
const scope = 'does/not/exist'; | ||
|
||
let reg = await navigator.serviceWorker.getRegistration(scope); | ||
if (reg) await reg.unregister(); | ||
|
||
reg = await navigator.serviceWorker.register('general.js', {scope}); | ||
|
||
fetch_tests_from_worker(reg.installing); | ||
})(); | ||
</script> | ||
</body> | ||
</html> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add newline. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>General fetch abort tests</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/common/utils.js"></script> | ||
<script src="general.js"></script> | ||
</head> | ||
<body> | ||
<script> | ||
fetch_tests_from_worker(new Worker("general.js")); | ||
if (window.SharedWorker) { | ||
fetch_tests_from_worker(new SharedWorker("general.js")); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FWIW I found generating multiple tests with a wrapper simpler than contextualTestName: see https://github.com/w3c/web-platform-tests/tree/master/streams readme and https://github.com/w3c/web-platform-tests/blob/master/streams/generate-test-wrappers.js |
||
</script> | ||
</body> | ||
</html> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add newline. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add newline.