Diff
Modified: trunk/LayoutTests/ChangeLog (210859 => 210860)
--- trunk/LayoutTests/ChangeLog 2017-01-18 19:35:49 UTC (rev 210859)
+++ trunk/LayoutTests/ChangeLog 2017-01-18 19:51:49 UTC (rev 210860)
@@ -1,5 +1,14 @@
2017-01-18 Youenn Fablet <[email protected]>
+ Reject fetch promise in case of ReadableStream upload
+ https://bugs.webkit.org/show_bug.cgi?id=167145
+
+ Reviewed by Alex Christensen.
+
+ * TestExpectations:
+
+2017-01-18 Youenn Fablet <[email protected]>
+
[Fetch API] Update content-type in case of form data
https://bugs.webkit.org/show_bug.cgi?id=167143
Modified: trunk/LayoutTests/TestExpectations (210859 => 210860)
--- trunk/LayoutTests/TestExpectations 2017-01-18 19:35:49 UTC (rev 210859)
+++ trunk/LayoutTests/TestExpectations 2017-01-18 19:51:49 UTC (rev 210860)
@@ -311,9 +311,6 @@
webkit.org/b/157145 imported/w3c/web-platform-tests/fetch/nosniff/stylesheet.html [ Failure Pass ]
webkit.org/b/161312 imported/w3c/web-platform-tests/html/semantics/document-metadata/the-link-element/document-without-browsing-context.html [ Failure Pass ]
-[ Debug ] imported/w3c/web-platform-tests/fetch/api/basic/request-upload.html [ Skip ]
-[ Debug ] imported/w3c/web-platform-tests/fetch/api/basic/request-upload-worker.html [ Skip ]
-
imported/w3c/web-platform-tests/fetch/api/cors/cors-origin.html [ DumpJSConsoleLogInStdErr ]
imported/w3c/web-platform-tests/fetch/api/cors/cors-preflight.html [ DumpJSConsoleLogInStdErr ]
imported/w3c/web-platform-tests/fetch/api/cors/cors-preflight-redirect.html [ DumpJSConsoleLogInStdErr ]
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (210859 => 210860)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2017-01-18 19:35:49 UTC (rev 210859)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2017-01-18 19:51:49 UTC (rev 210860)
@@ -1,5 +1,15 @@
2017-01-18 Youenn Fablet <[email protected]>
+ Reject fetch promise in case of ReadableStream upload
+ https://bugs.webkit.org/show_bug.cgi?id=167145
+
+ Reviewed by Alex Christensen.
+
+ * web-platform-tests/fetch/api/basic/request-upload-expected.txt:
+ * web-platform-tests/fetch/api/basic/request-upload-worker-expected.txt:
+
+2017-01-18 Youenn Fablet <[email protected]>
+
[Fetch API] Update content-type in case of form data
https://bugs.webkit.org/show_bug.cgi?id=167143
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-upload-expected.txt (210859 => 210860)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-upload-expected.txt 2017-01-18 19:35:49 UTC (rev 210859)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-upload-expected.txt 2017-01-18 19:51:49 UTC (rev 210860)
@@ -10,7 +10,7 @@
PASS Fetch with POST with Float64Array body
PASS Fetch with POST with DataView body
PASS Fetch with POST with Blob body with mime type
-FAIL Fetch with POST with ReadableStream assert_equals: expected "Test" but got ""
+FAIL Fetch with POST with ReadableStream promise_test: Unhandled rejection with value: object "TypeError: ReadableStream uploading is not supported"
FAIL Fetch with POST with ReadableStream containing String undefined is not an object (evaluating 'promise.then')
FAIL Fetch with POST with ReadableStream containing null undefined is not an object (evaluating 'promise.then')
FAIL Fetch with POST with ReadableStream containing number undefined is not an object (evaluating 'promise.then')
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-upload-worker-expected.txt (210859 => 210860)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-upload-worker-expected.txt 2017-01-18 19:35:49 UTC (rev 210859)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/request-upload-worker-expected.txt 2017-01-18 19:51:49 UTC (rev 210860)
@@ -10,7 +10,7 @@
PASS Fetch with POST with Float64Array body
PASS Fetch with POST with DataView body
PASS Fetch with POST with Blob body with mime type
-FAIL Fetch with POST with ReadableStream assert_equals: expected "Test" but got ""
+FAIL Fetch with POST with ReadableStream promise_test: Unhandled rejection with value: object "TypeError: ReadableStream uploading is not supported"
FAIL Fetch with POST with ReadableStream containing String undefined is not an object (evaluating 'promise.then')
FAIL Fetch with POST with ReadableStream containing null undefined is not an object (evaluating 'promise.then')
FAIL Fetch with POST with ReadableStream containing number undefined is not an object (evaluating 'promise.then')
Modified: trunk/Source/WebCore/ChangeLog (210859 => 210860)
--- trunk/Source/WebCore/ChangeLog 2017-01-18 19:35:49 UTC (rev 210859)
+++ trunk/Source/WebCore/ChangeLog 2017-01-18 19:51:49 UTC (rev 210860)
@@ -1,3 +1,20 @@
+2017-01-18 Youenn Fablet <[email protected]>
+
+ Reject fetch promise in case of ReadableStream upload
+ https://bugs.webkit.org/show_bug.cgi?id=167145
+
+ Reviewed by Alex Christensen.
+
+ Covered by rebased tests.
+
+ * Modules/fetch/FetchBody.cpp:
+ (WebCore::FetchBody::extract): Storing the fact that body data is represented as a ReadableStream.
+ * Modules/fetch/FetchBody.h:
+ (WebCore::FetchBody::isReadableStream):
+ * Modules/fetch/FetchRequest.h:
+ * Modules/fetch/FetchResponse.cpp:
+ (WebCore::FetchResponse::fetch): Rejecting if request body data is a ReadableStream.
+
2017-01-18 Andreas Kling <[email protected]>
Document::securityOrigin() should return a reference.
Modified: trunk/Source/WebCore/Modules/fetch/FetchBody.cpp (210859 => 210860)
--- trunk/Source/WebCore/Modules/fetch/FetchBody.cpp 2017-01-18 19:35:49 UTC (rev 210859)
+++ trunk/Source/WebCore/Modules/fetch/FetchBody.cpp 2017-01-18 19:51:49 UTC (rev 210860)
@@ -68,8 +68,11 @@
contentType = HTTPHeaderValues::formURLEncodedContentType();
return FetchBody(*JSURLSearchParams::toWrapped(value));
}
- if (value.inherits(JSReadableStream::info()))
- return FetchBody();
+ if (value.inherits(JSReadableStream::info())) {
+ FetchBody body;
+ body.m_isReadableStream = true;
+ return WTFMove(body);
+ }
if (value.inherits(JSC::JSArrayBuffer::info())) {
ArrayBuffer* data = ""
ASSERT(data);
Modified: trunk/Source/WebCore/Modules/fetch/FetchBody.h (210859 => 210860)
--- trunk/Source/WebCore/Modules/fetch/FetchBody.h 2017-01-18 19:35:49 UTC (rev 210859)
+++ trunk/Source/WebCore/Modules/fetch/FetchBody.h 2017-01-18 19:51:49 UTC (rev 210860)
@@ -68,6 +68,7 @@
bool isArrayBufferView() const { return WTF::holds_alternative<Ref<const ArrayBufferView>>(m_data); }
bool isURLSearchParams() const { return WTF::holds_alternative<Ref<const URLSearchParams>>(m_data); }
bool isText() const { return WTF::holds_alternative<String>(m_data); }
+ bool isReadableStream() const { return m_isReadableStream; }
static std::optional<FetchBody> extract(ScriptExecutionContext&, JSC::ExecState&, JSC::JSValue, String&);
static FetchBody loadingBody() { return { }; }
@@ -114,6 +115,9 @@
FetchBodyConsumer m_consumer { FetchBodyConsumer::Type::None };
RefPtr<DeferredPromise> m_consumePromise;
+
+ // FIXME: We probably want to keep the stream as a specific field in m_data when we will support stream data upload.
+ bool m_isReadableStream { false };
};
} // namespace WebCore
Modified: trunk/Source/WebCore/Modules/fetch/FetchRequest.h (210859 => 210860)
--- trunk/Source/WebCore/Modules/fetch/FetchRequest.h 2017-01-18 19:35:49 UTC (rev 210859)
+++ trunk/Source/WebCore/Modules/fetch/FetchRequest.h 2017-01-18 19:51:49 UTC (rev 210860)
@@ -96,6 +96,7 @@
const FetchOptions& fetchOptions() const { return m_internalRequest.options; }
ResourceRequest internalRequest() const;
+ bool isBodyReadableStream() const { return !isBodyNull() && body().isReadableStream(); }
const String& internalRequestReferrer() const { return m_internalRequest.referrer; }
Modified: trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp (210859 => 210860)
--- trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp 2017-01-18 19:35:49 UTC (rev 210859)
+++ trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp 2017-01-18 19:51:49 UTC (rev 210860)
@@ -100,6 +100,10 @@
void FetchResponse::fetch(ScriptExecutionContext& context, FetchRequest& request, FetchPromise&& promise)
{
+ if (request.isBodyReadableStream()) {
+ promise.reject(TypeError, "ReadableStream uploading is not supported");
+ return;
+ }
auto response = adoptRef(*new FetchResponse(context, FetchBody::loadingBody(), FetchHeaders::create(FetchHeaders::Guard::Immutable), { }));
// Setting pending activity until BodyLoader didFail or didSucceed callback is called.