-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Merged
jakearchibald
merged 13 commits into
web-platform-tests:master
from
jakearchibald:fetch-abort
Aug 2, 2017
Merged
Aborting fetch #6484
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
f6426f7
Some initial tests
jakearchibald dafbd68
More tests
jakearchibald b076f77
Stream & no-cors tests
jakearchibald fdf63fc
Don't need a promise here
jakearchibald 568ae5d
Intercepted by service worker tests
jakearchibald c1000fc
Whitespace fixing
jakearchibald ee16ec3
Asserting unreached rather than logging events
jakearchibald 3c232fc
Removing custom abort error checks. Adding reader.closed test.
jakearchibald c2741a5
Streaming body test
jakearchibald e9f1003
Remove forbidden header
jakearchibald 3e36e5e
Making test names unique
jakearchibald 2951a23
Addressing nits
jakearchibald b7e0b64
Better comment
jakearchibald File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")); | ||
} | ||
</script> | ||
</body> | ||
</html> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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