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 FetchEvent test that should reject none Uint8Array ReadableStream. #28203

Merged
merged 1 commit into from
Apr 14, 2021
Merged
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
26 changes: 26 additions & 0 deletions service-workers/service-worker/fetch-event.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,32 @@
'the network fallback request should include the request body');
}, 'FetchEvent#body is a ReadableStream and is passed to network fallback');

// Test that the request body is sent to network upon network fallback,
// for a ReadableStream body.
promise_test(async t => {
const rs = new ReadableStream({start(c) {
c.enqueue('i a');
c.enqueue('m the request');
t.step_timeout(t.step_func(() => {
c.enqueue(' body');
c.close();
}, 10));
}});
// Set page_url to "?ignore" so the service worker falls back to network
// for the main resource request, and add a suffix to avoid colliding
// with other tests.
const page_url = 'resources/?ignore-for-request-body-fallback-string';
const frame = await with_iframe(page_url);
t.add_cleanup(() => { frame.remove(); });
// Add "?ignore" so the service worker falls back to echo-content.py.
const echo_url = '/fetch/api/resources/echo-content.py?ignore';
const w = frame.contentWindow;
await promise_rejects_js(t, w.TypeError, w.fetch(echo_url, {
method: 'POST',
body: rs
}));
}, 'FetchEvent#body is a none Uint8Array ReadableStream and is passed to a service worker');

// Test that the request body is sent to network upon network fallback even when
// the request body is used in the service worker, for a string body.
promise_test(async t => {
Expand Down