Diff
Modified: trunk/LayoutTests/ChangeLog (287674 => 287675)
--- trunk/LayoutTests/ChangeLog 2022-01-06 05:51:41 UTC (rev 287674)
+++ trunk/LayoutTests/ChangeLog 2022-01-06 09:29:55 UTC (rev 287675)
@@ -1,3 +1,14 @@
+2022-01-06 Youenn Fablet <[email protected]>
+
+ "ReadableStream uploading is not supported" when fetch()ing a Request that has been logged to console
+ https://bugs.webkit.org/show_bug.cgi?id=203617
+ <rdar://problem/56772045>
+
+ Reviewed by Alex Christensen.
+
+ * http/wpt/fetch/fetch-request-with-stream-body-expected.txt: Added.
+ * http/wpt/fetch/fetch-request-with-stream-body.html: Added.
+
2022-01-05 Alan Bujtas <[email protected]>
Text-decoration color not changing back after input blur with outline removed
Added: trunk/LayoutTests/http/wpt/fetch/fetch-request-with-stream-body-expected.txt (0 => 287675)
--- trunk/LayoutTests/http/wpt/fetch/fetch-request-with-stream-body-expected.txt (rev 0)
+++ trunk/LayoutTests/http/wpt/fetch/fetch-request-with-stream-body-expected.txt 2022-01-06 09:29:55 UTC (rev 287675)
@@ -0,0 +1,5 @@
+
+PASS Creating a request body stream should not prevent a request from being fetched
+PASS Locking a request body stream should prevent a request from being fetched
+PASS Uploading a readable stream body request is not supported
+
Added: trunk/LayoutTests/http/wpt/fetch/fetch-request-with-stream-body.html (0 => 287675)
--- trunk/LayoutTests/http/wpt/fetch/fetch-request-with-stream-body.html (rev 0)
+++ trunk/LayoutTests/http/wpt/fetch/fetch-request-with-stream-body.html 2022-01-06 09:29:55 UTC (rev 287675)
@@ -0,0 +1,32 @@
+<!doctype html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <script src=""
+ <script src=""
+ </head>
+ <body>
+ <script>
+promise_test(test => {
+ const request = new Request("", {body: "value", method: "POST"});
+ request.body;
+ return fetch(request);
+}, "Creating a request body stream should not prevent a request from being fetched");
+
+promise_test(test => {
+ const request = new Request("", {body: "value", method: "POST"});
+ request.body.getReader();
+ return promise_rejects_js(test, TypeError, fetch(request));
+}, "Locking a request body stream should prevent a request from being fetched");
+
+promise_test(test => {
+ var stream = new ReadableStream({start: controller => {
+ controller.enqueue(new ArrayBuffer(10));
+ controller.close();
+ }});
+ var request = new Request("", {body: stream, mode:"cors", method: "POST"});
+ return promise_rejects_dom(test, "NotSupportedError", fetch(request));
+}, "Uploading a readable stream body request is not supported");
+ </script>
+ </body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (287674 => 287675)
--- trunk/Source/WebCore/ChangeLog 2022-01-06 05:51:41 UTC (rev 287674)
+++ trunk/Source/WebCore/ChangeLog 2022-01-06 09:29:55 UTC (rev 287675)
@@ -1,3 +1,21 @@
+2022-01-06 Youenn Fablet <[email protected]>
+
+ "ReadableStream uploading is not supported" when fetch()ing a Request that has been logged to console
+ https://bugs.webkit.org/show_bug.cgi?id=203617
+ <rdar://problem/56772045>
+
+ Reviewed by Alex Christensen.
+
+ Keep the underlying body even if a stream is created.
+ This allows to fetch the request even if request.body is accessed.
+
+ Test: http/wpt/fetch/fetch-request-with-stream-body.html
+
+ * Modules/beacon/NavigatorBeacon.cpp:
+ * Modules/fetch/FetchBody.cpp:
+ * Modules/fetch/FetchBody.h:
+ * Modules/fetch/FetchBodyOwner.h:
+
2022-01-05 Alan Bujtas <[email protected]>
Text-decoration color not changing back after input blur with outline removed
Modified: trunk/Source/WebCore/Modules/beacon/NavigatorBeacon.cpp (287674 => 287675)
--- trunk/Source/WebCore/Modules/beacon/NavigatorBeacon.cpp 2022-01-06 05:51:41 UTC (rev 287674)
+++ trunk/Source/WebCore/Modules/beacon/NavigatorBeacon.cpp 2022-01-06 09:29:55 UTC (rev 287675)
@@ -139,7 +139,7 @@
if (result.hasException())
return result.releaseException();
auto fetchBody = result.releaseReturnValue();
- if (fetchBody.hasReadableStream())
+ if (fetchBody.isReadableStream())
return Exception { TypeError, "Beacons cannot send ReadableStream body"_s };
request.setHTTPBody(fetchBody.bodyAsFormData());
Modified: trunk/Source/WebCore/Modules/fetch/FetchBody.cpp (287674 => 287675)
--- trunk/Source/WebCore/Modules/fetch/FetchBody.cpp 2022-01-06 05:51:41 UTC (rev 287674)
+++ trunk/Source/WebCore/Modules/fetch/FetchBody.cpp 2022-01-06 09:29:55 UTC (rev 287675)
@@ -177,24 +177,19 @@
void FetchBody::consumeAsStream(FetchBodyOwner& owner, FetchBodySource& source)
{
bool closeStream = false;
- if (isArrayBuffer()) {
+ if (isArrayBuffer())
closeStream = source.enqueue(ArrayBuffer::tryCreate(arrayBufferBody().data(), arrayBufferBody().byteLength()));
- m_data = nullptr;
- } else if (isArrayBufferView()) {
+ else if (isArrayBufferView())
closeStream = source.enqueue(ArrayBuffer::tryCreate(arrayBufferViewBody().baseAddress(), arrayBufferViewBody().byteLength()));
- m_data = nullptr;
- } else if (isText()) {
+ else if (isText()) {
auto data = "" PAL::UnencodableHandling::Entities);
closeStream = source.enqueue(ArrayBuffer::tryCreate(data.data(), data.size()));
- m_data = nullptr;
} else if (isURLSearchParams()) {
auto data = "" PAL::UnencodableHandling::Entities);
closeStream = source.enqueue(ArrayBuffer::tryCreate(data.data(), data.size()));
- m_data = nullptr;
- } else if (isBlob()) {
+ } else if (isBlob())
owner.loadBlob(blobBody(), nullptr);
- m_data = nullptr;
- } else if (isFormData())
+ else if (isFormData())
m_consumer.consumeFormDataAsStream(formDataBody(), source, owner.scriptExecutionContext());
else if (m_consumer.hasData())
closeStream = source.enqueue(m_consumer.takeAsArrayBuffer());
@@ -318,8 +313,7 @@
clone.m_data = textBody();
else if (isURLSearchParams())
clone.m_data = urlSearchParamsBody();
-
- if (m_readableStream) {
+ else if (m_readableStream) {
auto clones = m_readableStream->tee();
if (clones) {
m_readableStream = WTFMove(clones->first);
Modified: trunk/Source/WebCore/Modules/fetch/FetchBody.h (287674 => 287675)
--- trunk/Source/WebCore/Modules/fetch/FetchBody.h 2022-01-06 05:51:41 UTC (rev 287674)
+++ trunk/Source/WebCore/Modules/fetch/FetchBody.h 2022-01-06 09:29:55 UTC (rev 287675)
@@ -86,6 +86,7 @@
bool isBlob() const { return std::holds_alternative<Ref<const Blob>>(m_data); }
bool isFormData() const { return std::holds_alternative<Ref<FormData>>(m_data); }
+ bool isReadableStream() const { return std::holds_alternative<Ref<ReadableStream>>(m_data); }
private:
explicit FetchBody(Ref<const Blob>&& data) : m_data(WTFMove(data)) { }
@@ -94,8 +95,8 @@
explicit FetchBody(Ref<FormData>&& data) : m_data(WTFMove(data)) { }
explicit FetchBody(String&& data) : m_data(WTFMove(data)) { }
explicit FetchBody(Ref<const URLSearchParams>&& data) : m_data(WTFMove(data)) { }
+ explicit FetchBody(Ref<ReadableStream>&& stream) : m_data(stream) { m_readableStream = WTFMove(stream); }
explicit FetchBody(FetchBodyConsumer&& consumer) : m_consumer(WTFMove(consumer)) { }
- explicit FetchBody(Ref<ReadableStream>&& stream) : m_readableStream(WTFMove(stream)) { }
void consume(FetchBodyOwner&, Ref<DeferredPromise>&&);
@@ -119,7 +120,7 @@
const String& textBody() const { return std::get<String>(m_data); }
const URLSearchParams& urlSearchParamsBody() const { return std::get<Ref<const URLSearchParams>>(m_data).get(); }
- using Data = "" Ref<const Blob>, Ref<FormData>, Ref<const ArrayBuffer>, Ref<const ArrayBufferView>, Ref<const URLSearchParams>, String>;
+ using Data = "" Ref<const Blob>, Ref<FormData>, Ref<const ArrayBuffer>, Ref<const ArrayBufferView>, Ref<const URLSearchParams>, String, Ref<ReadableStream>>;
Data m_data { nullptr };
FetchBodyConsumer m_consumer { FetchBodyConsumer::Type::None };
Modified: trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.h (287674 => 287675)
--- trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.h 2022-01-06 05:51:41 UTC (rev 287674)
+++ trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.h 2022-01-06 09:29:55 UTC (rev 287675)
@@ -60,6 +60,7 @@
ExceptionOr<RefPtr<ReadableStream>> readableStream(JSC::JSGlobalObject&);
bool hasReadableStreamBody() const { return m_body && m_body->hasReadableStream(); }
+ bool isReadableStreamBody() const { return m_body && m_body->isReadableStream(); }
virtual void consumeBodyAsStream();
virtual void feedStream() { }
Modified: trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp (287674 => 287675)
--- trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp 2022-01-06 05:51:41 UTC (rev 287674)
+++ trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp 2022-01-06 09:29:55 UTC (rev 287675)
@@ -243,7 +243,7 @@
return;
}
- if (request.hasReadableStreamBody()) {
+ if (request.isReadableStreamBody()) {
responseCallback(Exception { NotSupportedError, "ReadableStream uploading is not supported"_s });
return;
}