|
509 | 509 | 'the network fallback request should include the request body');
|
510 | 510 | }, 'FetchEvent#body is a ReadableStream and is passed to network fallback');
|
511 | 511 |
|
| 512 | + // Test that the request body is sent to network upon network fallback, |
| 513 | +// for a ReadableStream body. |
| 514 | +promise_test(async t => { |
| 515 | + const rs = new ReadableStream({start(c) { |
| 516 | + c.enqueue('i a'); |
| 517 | + c.enqueue('m the request'); |
| 518 | + t.step_timeout(t.step_func(() => { |
| 519 | + c.enqueue(' body'); |
| 520 | + c.close(); |
| 521 | + }, 10)); |
| 522 | + }}); |
| 523 | + // Set page_url to "?ignore" so the service worker falls back to network |
| 524 | + // for the main resource request, and add a suffix to avoid colliding |
| 525 | + // with other tests. |
| 526 | + const page_url = 'resources/?ignore-for-request-body-fallback-string'; |
| 527 | + const frame = await with_iframe(page_url); |
| 528 | + t.add_cleanup(() => { frame.remove(); }); |
| 529 | + // Add "?ignore" so the service worker falls back to echo-content.py. |
| 530 | + const echo_url = '/fetch/api/resources/echo-content.py?ignore'; |
| 531 | + const w = frame.contentWindow; |
| 532 | + await promise_rejects_js(t, w.TypeError, w.fetch(echo_url, { |
| 533 | + method: 'POST', |
| 534 | + body: rs |
| 535 | + })); |
| 536 | + }, 'FetchEvent#body is a none Uint8Array ReadableStream and is passed to a service worker'); |
| 537 | + |
512 | 538 | // Test that the request body is sent to network upon network fallback even when
|
513 | 539 | // the request body is used in the service worker, for a string body.
|
514 | 540 | promise_test(async t => {
|
|
0 commit comments