Diff
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (280045 => 280046)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2021-07-19 20:49:56 UTC (rev 280045)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2021-07-19 21:33:16 UTC (rev 280046)
@@ -1,5 +1,19 @@
2021-07-19 Chris Dumez <[email protected]>
+ FetchResponse.formData() should not reject promise if the body is null and the MIME Type is "application/x-www-form-urlencoded"
+ https://bugs.webkit.org/show_bug.cgi?id=228085
+
+ Reviewed by Alex Christensen.
+
+ Rebaseline WPT tests now that more checks are passing.
+
+ * web-platform-tests/fetch/api/request/request-consume-empty.any-expected.txt:
+ * web-platform-tests/fetch/api/request/request-consume-empty.any.worker-expected.txt:
+ * web-platform-tests/fetch/api/response/response-consume-empty.any-expected.txt:
+ * web-platform-tests/fetch/api/response/response-consume-empty.any.worker-expected.txt:
+
+2021-07-19 Chris Dumez <[email protected]>
+
Unreviewed, land test baselines for cross-origin-opener-policy tests
https://bugs.webkit.org/show_bug.cgi?id=228080
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-consume-empty.any-expected.txt (280045 => 280046)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-consume-empty.any-expected.txt 2021-07-19 20:49:56 UTC (rev 280045)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-consume-empty.any-expected.txt 2021-07-19 21:33:16 UTC (rev 280046)
@@ -4,7 +4,7 @@
PASS Consume request's body as arrayBuffer
PASS Consume request's body as json (error case)
PASS Consume request's body as formData with correct multipart type (error case)
-FAIL Consume request's body as formData with correct urlencoded type promise_test: Unhandled rejection with value: object "TypeError: Type error"
+PASS Consume request's body as formData with correct urlencoded type
PASS Consume request's body as formData without correct type (error case)
PASS Consume empty blob request body as arrayBuffer
PASS Consume empty text request body as arrayBuffer
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-consume-empty.any.worker-expected.txt (280045 => 280046)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-consume-empty.any.worker-expected.txt 2021-07-19 20:49:56 UTC (rev 280045)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-consume-empty.any.worker-expected.txt 2021-07-19 21:33:16 UTC (rev 280046)
@@ -4,7 +4,7 @@
PASS Consume request's body as arrayBuffer
PASS Consume request's body as json (error case)
PASS Consume request's body as formData with correct multipart type (error case)
-FAIL Consume request's body as formData with correct urlencoded type promise_test: Unhandled rejection with value: object "TypeError: Type error"
+PASS Consume request's body as formData with correct urlencoded type
PASS Consume request's body as formData without correct type (error case)
PASS Consume empty blob request body as arrayBuffer
PASS Consume empty text request body as arrayBuffer
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume-empty.any-expected.txt (280045 => 280046)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume-empty.any-expected.txt 2021-07-19 20:49:56 UTC (rev 280045)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume-empty.any-expected.txt 2021-07-19 21:33:16 UTC (rev 280046)
@@ -4,7 +4,7 @@
PASS Consume response's body as arrayBuffer
PASS Consume response's body as json (error case)
PASS Consume response's body as formData with correct multipart type (error case)
-FAIL Consume response's body as formData with correct urlencoded type promise_test: Unhandled rejection with value: object "TypeError: Type error"
+PASS Consume response's body as formData with correct urlencoded type
PASS Consume response's body as formData without correct type (error case)
PASS Consume empty blob response body as arrayBuffer
PASS Consume empty text response body as arrayBuffer
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume-empty.any.worker-expected.txt (280045 => 280046)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume-empty.any.worker-expected.txt 2021-07-19 20:49:56 UTC (rev 280045)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume-empty.any.worker-expected.txt 2021-07-19 21:33:16 UTC (rev 280046)
@@ -4,7 +4,7 @@
PASS Consume response's body as arrayBuffer
PASS Consume response's body as json (error case)
PASS Consume response's body as formData with correct multipart type (error case)
-FAIL Consume response's body as formData with correct urlencoded type promise_test: Unhandled rejection with value: object "TypeError: Type error"
+PASS Consume response's body as formData with correct urlencoded type
PASS Consume response's body as formData without correct type (error case)
PASS Consume empty blob response body as arrayBuffer
PASS Consume empty text response body as arrayBuffer
Modified: trunk/Source/WebCore/ChangeLog (280045 => 280046)
--- trunk/Source/WebCore/ChangeLog 2021-07-19 20:49:56 UTC (rev 280045)
+++ trunk/Source/WebCore/ChangeLog 2021-07-19 21:33:16 UTC (rev 280046)
@@ -1,3 +1,26 @@
+2021-07-19 Chris Dumez <[email protected]>
+
+ FetchResponse.formData() should not reject promise if the body is null and the MIME Type is "application/x-www-form-urlencoded"
+ https://bugs.webkit.org/show_bug.cgi?id=228085
+
+ Reviewed by Alex Christensen.
+
+ FetchResponse.formData() should not reject promise if the body is null and the MIME Type is "application/x-www-form-urlencoded":
+ - https://fetch.spec.whatwg.org/#concept-body-consume-body
+ - https://fetch.spec.whatwg.org/#concept-body-package-data
+
+ As per the specification, we should package an empty byte sequence in this case and resolve the promise with that.
+
+ No new tests, rebaselined existing tests.
+
+ * Modules/fetch/FetchBodyConsumer.cpp:
+ (WebCore::FetchBodyConsumer::packageFormData):
+ (WebCore::resolveWithTypeAndData):
+ (WebCore::packageFormData): Deleted.
+ * Modules/fetch/FetchBodyConsumer.h:
+ * Modules/fetch/FetchBodyOwner.cpp:
+ (WebCore::FetchBodyOwner::formData):
+
2021-07-19 Ziran Sun <[email protected]>
[css-grid] Images as grid items should use the overridingLogicalHeight when defined to compute the logical width
Modified: trunk/Source/WebCore/Modules/fetch/FetchBodyConsumer.cpp (280045 => 280046)
--- trunk/Source/WebCore/Modules/fetch/FetchBodyConsumer.cpp 2021-07-19 20:49:56 UTC (rev 280045)
+++ trunk/Source/WebCore/Modules/fetch/FetchBodyConsumer.cpp 2021-07-19 21:33:16 UTC (rev 280046)
@@ -124,7 +124,7 @@
}
// https://fetch.spec.whatwg.org/#concept-body-package-data
-static RefPtr<DOMFormData> packageFormData(ScriptExecutionContext* context, const String& contentType, const uint8_t* data, size_t length)
+RefPtr<DOMFormData> FetchBodyConsumer::packageFormData(ScriptExecutionContext* context, const String& contentType, const uint8_t* data, size_t length)
{
auto parseMultipartPart = [context] (const uint8_t* part, size_t partLength, DOMFormData& form) -> bool {
const uint8_t* headerEnd = static_cast<const uint8_t*>(memmem(part, partLength, "\r\n\r\n", 4));
@@ -229,7 +229,7 @@
promise->resolve<IDLDOMString>(TextResourceDecoder::textFromUTF8(data, length));
return;
case FetchBodyConsumer::Type::FormData:
- if (auto formData = packageFormData(context, contentType, data, length))
+ if (auto formData = FetchBodyConsumer::packageFormData(context, contentType, data, length))
promise->resolve<IDLInterface<DOMFormData>>(*formData);
else
promise->reject(TypeError);
Modified: trunk/Source/WebCore/Modules/fetch/FetchBodyConsumer.h (280045 => 280046)
--- trunk/Source/WebCore/Modules/fetch/FetchBodyConsumer.h 2021-07-19 20:49:56 UTC (rev 280045)
+++ trunk/Source/WebCore/Modules/fetch/FetchBodyConsumer.h 2021-07-19 21:33:16 UTC (rev 280046)
@@ -37,6 +37,7 @@
namespace WebCore {
class Blob;
+class DOMFormData;
class FetchBodySource;
class ReadableStream;
@@ -73,6 +74,8 @@
void setAsLoading() { m_isLoading = true; }
+ static RefPtr<DOMFormData> packageFormData(ScriptExecutionContext*, const String& contentType, const uint8_t* data, size_t length);
+
private:
Ref<Blob> takeAsBlob(ScriptExecutionContext*);
void resetConsumePromise();
Modified: trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.cpp (280045 => 280046)
--- trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.cpp 2021-07-19 20:49:56 UTC (rev 280045)
+++ trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.cpp 2021-07-19 21:33:16 UTC (rev 280046)
@@ -34,6 +34,7 @@
#include "FetchLoader.h"
#include "HTTPParsers.h"
#include "JSBlob.h"
+#include "JSDOMFormData.h"
#include "ResourceError.h"
#include "ResourceResponse.h"
#include "WindowEventLoop.h"
@@ -185,14 +186,24 @@
return;
}
+ if (isDisturbedOrLocked()) {
+ promise->reject(Exception { TypeError, "Body is disturbed or locked"_s });
+ return;
+ }
+
if (isBodyNullOrOpaque()) {
+ if (isBodyNull()) {
+ // If the content-type is 'application/x-www-form-urlencoded', a body is not required and we should package an empty byte sequence as per the specification.
+ if (auto formData = FetchBodyConsumer::packageFormData(promise->scriptExecutionContext(), m_contentType, nullptr, 0)) {
+ promise->resolve<IDLInterface<DOMFormData>>(*formData);
+ return;
+ }
+ }
+
promise->reject(TypeError);
return;
}
- if (isDisturbedOrLocked()) {
- promise->reject(Exception { TypeError, "Body is disturbed or locked"_s });
- return;
- }
+
m_isDisturbed = true;
m_body->formData(*this, WTFMove(promise));
}