Skip to content
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

Add tests for handling bad content encoding in fetch #10542

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 20 additions & 0 deletions fetch/content-encoding/bad-gzip-body.any.js
@@ -0,0 +1,20 @@
promise_test((test) => {
return fetch("resources/bad-gzip-body.py").then(res => {
assert_equals(res.status, 200);
});
}, "Fetching a resource with bad gzip content should still resolve");

[
"arrayBuffer",
"blob",
"formData",
"json",
"text"
].forEach(method => {
promise_test(t => {
return fetch("resources/bad-gzip-body.py").then(res => {
assert_equals(res.status, 200);
return promise_rejects(t, new TypeError(), res[method]());
});
}, "Consuming the body of a resource with bad gzip content with " + method + "() should reject");
});
3 changes: 3 additions & 0 deletions fetch/content-encoding/resources/bad-gzip-body.py
@@ -0,0 +1,3 @@
def main(request, response):
headers = [("Content-Encoding", "gzip")]
return headers, "not actually gzip"