Commit ad1651a8 authored by Yoichi Osato's avatar Yoichi Osato Committed by Commit Bot

[fetch] Expose Request.body property.

This CL implements https://fetch.spec.whatwg.org/#body-mixin:
"""
Request includes Body;

The body attribute’s getter must return null if body is null and body’s stream otherwise.
"""
Since this feature is required for fetch upload streaming, this CL makes
it under the flag FetchUploadStreaming.

Fixed: 1105704
Change-Id: I334d9e1a3494ff4ba31efc9dc8b319294d2e19d4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2297035Reviewed-by: default avatarAdam Rice <ricea@chromium.org>
Reviewed-by: default avatarYutaka Hirano <yhirano@chromium.org>
Commit-Queue: Yoichi Osato <yoichio@chromium.org>
Cr-Commit-Position: refs/heads/master@{#789852}
parent fb2f3499
......@@ -50,6 +50,8 @@ enum ReferrerPolicy {
[MeasureAs=RequestIsHistoryNavigation] readonly attribute boolean isHistoryNavigation;
[RaisesException, CallWith=ScriptState, DoNotTestNewObject, NewObject] Request clone();
[RuntimeEnabled=FetchUploadStreaming] readonly attribute ReadableStream? body;
};
Request includes Body;
......@@ -94,6 +94,10 @@ crbug.com/688906 http/tests/fetch/workers/fetch_upload-base-https-other-https.ht
crbug.com/688906 http/tests/fetch/workers/fetch_upload.html [ Failure ]
crbug.com/688906 external/wpt/fetch/api/basic/request-upload.any.html [ Failure ]
crbug.com/688906 external/wpt/fetch/api/basic/request-upload.any.worker.html [ Failure ]
crbug.com/688906 external/wpt/fetch/api/request/request-init-stream.any.html [ Failure ]
crbug.com/688906 external/wpt/fetch/api/request/request-init-stream.any.serviceworker.html [ Failure ]
crbug.com/688906 external/wpt/fetch/api/request/request-init-stream.any.sharedworker.html [ Failure ]
crbug.com/688906 external/wpt/fetch/api/request/request-init-stream.any.worker.html [ Failure ]
crbug.com/688906 virtual/omt-worker-fetch/external/wpt/fetch/api/basic/request-upload.any.html [ Failure ]
crbug.com/688906 virtual/omt-worker-fetch/external/wpt/fetch/api/basic/request-upload.any.worker.html [ Failure ]
crbug.com/688906 external/wpt/service-workers/service-worker/fetch-event.https.html [ Failure ]
......
......@@ -1482,6 +1482,10 @@ crbug.com/1053725 [ Win7 ] fast/forms/calendar-picker/date-picker-appearance-dis
crbug.com/1091139 virtual/cors/external/wpt/fetch/api/basic/keepalive.html [ Skip ]
crbug.com/1091139 virtual/cors/external/wpt/fetch/api/basic/request-upload.any.html [ Skip ]
crbug.com/1091139 virtual/cors/external/wpt/fetch/api/basic/request-upload.any.worker.html [ Skip ]
crbug.com/1091139 virtual/cors/external/wpt/fetch/api/request/request-init-stream.any.html [ Skip ]
crbug.com/1091139 virtual/cors/external/wpt/fetch/api/request/request-init-stream.any.serviceworker.html [ Skip ]
crbug.com/1091139 virtual/cors/external/wpt/fetch/api/request/request-init-stream.any.sharedworker.html [ Skip ]
crbug.com/1091139 virtual/cors/external/wpt/fetch/api/request/request-init-stream.any.worker.html [ Skip ]
crbug.com/1091139 virtual/cors/external/wpt/resource-timing/cors-preflight.any.html [ Skip ]
crbug.com/1091139 virtual/cors/external/wpt/resource-timing/cors-preflight.any.worker.html [ Skip ]
crbug.com/1091139 virtual/cors/external/wpt/resource-timing/redirects.sub.html [ Skip ]
......
This is a testharness.js-based test.
Found 139 tests; 135 PASS, 4 FAIL, 0 TIMEOUT, 0 NOTRUN.
Found 139 tests; 137 PASS, 2 FAIL, 0 TIMEOUT, 0 NOTRUN.
PASS idl_test setup
PASS idl_test validation
PASS Partial interface mixin WindowOrWorkerGlobalScope: original interface mixin defined
......@@ -60,7 +60,7 @@ FAIL Request interface: attribute isReloadNavigation assert_true: The prototype
PASS Request interface: attribute isHistoryNavigation
PASS Request interface: attribute signal
PASS Request interface: operation clone()
FAIL Request interface: attribute body assert_true: The prototype object must have a property "body" expected true got false
PASS Request interface: attribute body
PASS Request interface: attribute bodyUsed
PASS Request interface: operation arrayBuffer()
PASS Request interface: operation blob()
......@@ -85,7 +85,7 @@ FAIL Request interface: new Request('about:blank') must inherit property "isRelo
PASS Request interface: new Request('about:blank') must inherit property "isHistoryNavigation" with the proper type
PASS Request interface: new Request('about:blank') must inherit property "signal" with the proper type
PASS Request interface: new Request('about:blank') must inherit property "clone()" with the proper type
FAIL Request interface: new Request('about:blank') must inherit property "body" with the proper type assert_inherits: property "body" not found in prototype chain
PASS Request interface: new Request('about:blank') must inherit property "body" with the proper type
PASS Request interface: new Request('about:blank') must inherit property "bodyUsed" with the proper type
PASS Request interface: new Request('about:blank') must inherit property "arrayBuffer()" with the proper type
PASS Request interface: new Request('about:blank') must inherit property "blob()" with the proper type
......
This is a testharness.js-based test.
Found 139 tests; 135 PASS, 4 FAIL, 0 TIMEOUT, 0 NOTRUN.
Found 139 tests; 137 PASS, 2 FAIL, 0 TIMEOUT, 0 NOTRUN.
PASS idl_test setup
PASS idl_test validation
PASS Partial interface mixin WindowOrWorkerGlobalScope: original interface mixin defined
......@@ -60,7 +60,7 @@ FAIL Request interface: attribute isReloadNavigation assert_true: The prototype
PASS Request interface: attribute isHistoryNavigation
PASS Request interface: attribute signal
PASS Request interface: operation clone()
FAIL Request interface: attribute body assert_true: The prototype object must have a property "body" expected true got false
PASS Request interface: attribute body
PASS Request interface: attribute bodyUsed
PASS Request interface: operation arrayBuffer()
PASS Request interface: operation blob()
......@@ -85,7 +85,7 @@ FAIL Request interface: new Request('about:blank') must inherit property "isRelo
PASS Request interface: new Request('about:blank') must inherit property "isHistoryNavigation" with the proper type
PASS Request interface: new Request('about:blank') must inherit property "signal" with the proper type
PASS Request interface: new Request('about:blank') must inherit property "clone()" with the proper type
FAIL Request interface: new Request('about:blank') must inherit property "body" with the proper type assert_inherits: property "body" not found in prototype chain
PASS Request interface: new Request('about:blank') must inherit property "body" with the proper type
PASS Request interface: new Request('about:blank') must inherit property "bodyUsed" with the proper type
PASS Request interface: new Request('about:blank') must inherit property "arrayBuffer()" with the proper type
PASS Request interface: new Request('about:blank') must inherit property "blob()" with the proper type
......
This is a testharness.js-based test.
Found 139 tests; 135 PASS, 4 FAIL, 0 TIMEOUT, 0 NOTRUN.
Found 139 tests; 137 PASS, 2 FAIL, 0 TIMEOUT, 0 NOTRUN.
PASS idl_test setup
PASS idl_test validation
PASS Partial interface mixin WindowOrWorkerGlobalScope: original interface mixin defined
......@@ -60,7 +60,7 @@ FAIL Request interface: attribute isReloadNavigation assert_true: The prototype
PASS Request interface: attribute isHistoryNavigation
PASS Request interface: attribute signal
PASS Request interface: operation clone()
FAIL Request interface: attribute body assert_true: The prototype object must have a property "body" expected true got false
PASS Request interface: attribute body
PASS Request interface: attribute bodyUsed
PASS Request interface: operation arrayBuffer()
PASS Request interface: operation blob()
......@@ -85,7 +85,7 @@ FAIL Request interface: new Request('about:blank') must inherit property "isRelo
PASS Request interface: new Request('about:blank') must inherit property "isHistoryNavigation" with the proper type
PASS Request interface: new Request('about:blank') must inherit property "signal" with the proper type
PASS Request interface: new Request('about:blank') must inherit property "clone()" with the proper type
FAIL Request interface: new Request('about:blank') must inherit property "body" with the proper type assert_inherits: property "body" not found in prototype chain
PASS Request interface: new Request('about:blank') must inherit property "body" with the proper type
PASS Request interface: new Request('about:blank') must inherit property "bodyUsed" with the proper type
PASS Request interface: new Request('about:blank') must inherit property "arrayBuffer()" with the proper type
PASS Request interface: new Request('about:blank') must inherit property "blob()" with the proper type
......
This is a testharness.js-based test.
Found 139 tests; 135 PASS, 4 FAIL, 0 TIMEOUT, 0 NOTRUN.
Found 139 tests; 137 PASS, 2 FAIL, 0 TIMEOUT, 0 NOTRUN.
PASS idl_test setup
PASS idl_test validation
PASS Partial interface mixin WindowOrWorkerGlobalScope: original interface mixin defined
......@@ -60,7 +60,7 @@ FAIL Request interface: attribute isReloadNavigation assert_true: The prototype
PASS Request interface: attribute isHistoryNavigation
PASS Request interface: attribute signal
PASS Request interface: operation clone()
FAIL Request interface: attribute body assert_true: The prototype object must have a property "body" expected true got false
PASS Request interface: attribute body
PASS Request interface: attribute bodyUsed
PASS Request interface: operation arrayBuffer()
PASS Request interface: operation blob()
......@@ -85,7 +85,7 @@ FAIL Request interface: new Request('about:blank') must inherit property "isRelo
PASS Request interface: new Request('about:blank') must inherit property "isHistoryNavigation" with the proper type
PASS Request interface: new Request('about:blank') must inherit property "signal" with the proper type
PASS Request interface: new Request('about:blank') must inherit property "clone()" with the proper type
FAIL Request interface: new Request('about:blank') must inherit property "body" with the proper type assert_inherits: property "body" not found in prototype chain
PASS Request interface: new Request('about:blank') must inherit property "body" with the proper type
PASS Request interface: new Request('about:blank') must inherit property "bodyUsed" with the proper type
PASS Request interface: new Request('about:blank') must inherit property "arrayBuffer()" with the proper type
PASS Request interface: new Request('about:blank') must inherit property "blob()" with the proper type
......
This is a testharness.js-based test.
FAIL Request's body: initial state assert_equals: body's default value is null expected (object) null but got (undefined) undefined
PASS Request's body: initial state
PASS Request without body cannot be disturbed
PASS Check cloning a disturbed request
PASS Check creating a new request from a disturbed request
FAIL Check creating a new request with a new body from a disturbed request Failed to construct 'Request': Cannot construct a Request with a Request object that has already been used.
FAIL Input request used for creating new request became disturbed assert_not_equals: body should not be undefined got disallowed value undefined
FAIL Input request used for creating new request became disturbed even if body is not used assert_not_equals: body should not be undefined got disallowed value undefined
FAIL Input request used for creating new request became disturbed assert_equals: body should not change expected object "[object ReadableStream]" but got object "[object ReadableStream]"
FAIL Input request used for creating new request became disturbed even if body is not used assert_equals: body should not change expected object "[object ReadableStream]" but got object "[object ReadableStream]"
PASS Check consuming a disturbed request
PASS Request construction failure should not set "bodyUsed"
Harness: the test ran to completion.
......
This is a testharness.js-based test.
PASS Constructing a Request with a stream holds the original object.
FAIL Constructing a Request with a stream on which getReader() is called assert_throws_js: new Request() function "() => new Request(input, init)" did not throw
FAIL Constructing a Request with a stream on which read() is called assert_throws_js: new Request() function "() => new Request(input, init)" did not throw
FAIL Constructing a Request with a stream on which read() and releaseLock() are called assert_throws_js: new Request() function "() => new Request(input, init)" did not throw
FAIL Constructing a Request with a Request on which body.getReader() is called promise_test: Unhandled rejection with value: object "TypeError: Cannot read property 'getReader' of undefined"
FAIL Constructing a Request with a Request on which body.getReader().read() is called promise_test: Unhandled rejection with value: object "TypeError: Cannot read property 'getReader' of undefined"
FAIL Constructing a Request with a Request on which read() and releaseLock() are called promise_test: Unhandled rejection with value: object "TypeError: Cannot read property 'getReader' of undefined"
FAIL Constructing a Request with a Request on which body.getReader() is called assert_throws_js: new Request() function "() => new Request(input, init)" did not throw
FAIL Constructing a Request with a Request on which body.getReader().read() is called promise_test: Unhandled rejection with value: object "TypeError: Failed to construct 'Request': Cannot construct a Request with a Request object that has already been used."
FAIL Constructing a Request with a Request on which read() and releaseLock() are called promise_test: Unhandled rejection with value: object "TypeError: Failed to construct 'Request': Cannot construct a Request with a Request object that has already been used."
Harness: the test ran to completion.
......@@ -2,6 +2,12 @@
"use strict";
test(() => {
const stream = new ReadableStream();
const request = new Request("...", { method:"POST", body: stream });
assert_equals(request.body, stream);
}, "Constructing a Request with a stream holds the original object.");
async function assert_request(test, input, init) {
assert_throws_js(TypeError, () => new Request(input, init), "new Request()");
await promise_rejects_js(test, TypeError, fetch(input, init), "fetch()");
......
This is a testharness.js-based test.
PASS Constructing a Request with a stream holds the original object.
FAIL Constructing a Request with a stream on which getReader() is called assert_throws_js: new Request() function "() => new Request(input, init)" did not throw
FAIL Constructing a Request with a stream on which read() is called assert_throws_js: new Request() function "() => new Request(input, init)" did not throw
FAIL Constructing a Request with a stream on which read() and releaseLock() are called assert_throws_js: new Request() function "() => new Request(input, init)" did not throw
FAIL Constructing a Request with a Request on which body.getReader() is called promise_test: Unhandled rejection with value: object "TypeError: Cannot read property 'getReader' of undefined"
FAIL Constructing a Request with a Request on which body.getReader().read() is called promise_test: Unhandled rejection with value: object "TypeError: Cannot read property 'getReader' of undefined"
FAIL Constructing a Request with a Request on which read() and releaseLock() are called promise_test: Unhandled rejection with value: object "TypeError: Cannot read property 'getReader' of undefined"
FAIL Constructing a Request with a Request on which body.getReader() is called assert_throws_js: new Request() function "() => new Request(input, init)" did not throw
FAIL Constructing a Request with a Request on which body.getReader().read() is called promise_test: Unhandled rejection with value: object "TypeError: Failed to construct 'Request': Cannot construct a Request with a Request object that has already been used."
FAIL Constructing a Request with a Request on which read() and releaseLock() are called promise_test: Unhandled rejection with value: object "TypeError: Failed to construct 'Request': Cannot construct a Request with a Request object that has already been used."
Harness: the test ran to completion.
This is a testharness.js-based test.
PASS Constructing a Request with a stream holds the original object.
FAIL Constructing a Request with a stream on which getReader() is called assert_throws_js: new Request() function "() => new Request(input, init)" did not throw
FAIL Constructing a Request with a stream on which read() is called assert_throws_js: new Request() function "() => new Request(input, init)" did not throw
FAIL Constructing a Request with a stream on which read() and releaseLock() are called assert_throws_js: new Request() function "() => new Request(input, init)" did not throw
FAIL Constructing a Request with a Request on which body.getReader() is called promise_test: Unhandled rejection with value: object "TypeError: Cannot read property 'getReader' of undefined"
FAIL Constructing a Request with a Request on which body.getReader().read() is called promise_test: Unhandled rejection with value: object "TypeError: Cannot read property 'getReader' of undefined"
FAIL Constructing a Request with a Request on which read() and releaseLock() are called promise_test: Unhandled rejection with value: object "TypeError: Cannot read property 'getReader' of undefined"
FAIL Constructing a Request with a Request on which body.getReader() is called assert_throws_js: new Request() function "() => new Request(input, init)" did not throw
FAIL Constructing a Request with a Request on which body.getReader().read() is called promise_test: Unhandled rejection with value: object "TypeError: Failed to construct 'Request': Cannot construct a Request with a Request object that has already been used."
FAIL Constructing a Request with a Request on which read() and releaseLock() are called promise_test: Unhandled rejection with value: object "TypeError: Failed to construct 'Request': Cannot construct a Request with a Request object that has already been used."
Harness: the test ran to completion.
This is a testharness.js-based test.
PASS Constructing a Request with a stream holds the original object.
FAIL Constructing a Request with a stream on which getReader() is called assert_throws_js: new Request() function "() => new Request(input, init)" did not throw
FAIL Constructing a Request with a stream on which read() is called assert_throws_js: new Request() function "() => new Request(input, init)" did not throw
FAIL Constructing a Request with a stream on which read() and releaseLock() are called assert_throws_js: new Request() function "() => new Request(input, init)" did not throw
FAIL Constructing a Request with a Request on which body.getReader() is called promise_test: Unhandled rejection with value: object "TypeError: Cannot read property 'getReader' of undefined"
FAIL Constructing a Request with a Request on which body.getReader().read() is called promise_test: Unhandled rejection with value: object "TypeError: Cannot read property 'getReader' of undefined"
FAIL Constructing a Request with a Request on which read() and releaseLock() are called promise_test: Unhandled rejection with value: object "TypeError: Cannot read property 'getReader' of undefined"
FAIL Constructing a Request with a Request on which body.getReader() is called assert_throws_js: new Request() function "() => new Request(input, init)" did not throw
FAIL Constructing a Request with a Request on which body.getReader().read() is called promise_test: Unhandled rejection with value: object "TypeError: Failed to construct 'Request': Cannot construct a Request with a Request object that has already been used."
FAIL Constructing a Request with a Request on which read() and releaseLock() are called promise_test: Unhandled rejection with value: object "TypeError: Failed to construct 'Request': Cannot construct a Request with a Request object that has already been used."
Harness: the test ran to completion.
......@@ -1313,6 +1313,7 @@ interface ReportingObserver
method takeRecords
interface Request
attribute @@toStringTag
getter body
getter bodyUsed
getter cache
getter credentials
......
......@@ -1247,6 +1247,7 @@ Starting worker: resources/global-interface-listing-worker.js
[Worker] method takeRecords
[Worker] interface Request
[Worker] attribute @@toStringTag
[Worker] getter body
[Worker] getter bodyUsed
[Worker] getter cache
[Worker] getter credentials
......
......@@ -6699,6 +6699,7 @@ interface ReportingObserver
method takeRecords
interface Request
attribute @@toStringTag
getter body
getter bodyUsed
getter cache
getter credentials
......
......@@ -1203,6 +1203,7 @@ Starting worker: resources/global-interface-listing-worker.js
[Worker] method takeRecords
[Worker] interface Request
[Worker] attribute @@toStringTag
[Worker] getter body
[Worker] getter bodyUsed
[Worker] getter cache
[Worker] getter credentials
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment