Diff
Modified: trunk/LayoutTests/ChangeLog (251785 => 251786)
--- trunk/LayoutTests/ChangeLog 2019-10-30 18:29:56 UTC (rev 251785)
+++ trunk/LayoutTests/ChangeLog 2019-10-30 18:32:59 UTC (rev 251786)
@@ -1,3 +1,16 @@
+2019-10-30 Chris Dumez <[email protected]>
+
+ REGRESSION (r238252): HTTP POST is losing application/x-www-form-urlencoded body if there's a redirect to different host
+ https://bugs.webkit.org/show_bug.cgi?id=201950
+ <rdar://problem/55577782>
+
+ Reviewed by Alex Christensen.
+
+ Add layout test coverage.
+
+ * http/tests/misc/form-submit-file-cross-site-redirect-expected.txt: Added.
+ * http/tests/misc/form-submit-file-cross-site-redirect.html: Added.
+
2019-10-30 Antti Koivisto <[email protected]>
::before/::after elements not filling their grid cell when container has display: contents
Added: trunk/LayoutTests/http/tests/misc/form-submit-file-cross-site-redirect-expected.txt (0 => 251786)
--- trunk/LayoutTests/http/tests/misc/form-submit-file-cross-site-redirect-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/misc/form-submit-file-cross-site-redirect-expected.txt 2019-10-30 18:32:59 UTC (rev 251786)
@@ -0,0 +1,7 @@
+OPEN FILE PANEL
+This tests verifies the test file included in the multipart form data:
+
+PASS: File is present
+PASS: File upload was successful
+PASS: File size is greater than 0
+
Added: trunk/LayoutTests/http/tests/misc/form-submit-file-cross-site-redirect.html (0 => 251786)
--- trunk/LayoutTests/http/tests/misc/form-submit-file-cross-site-redirect.html (rev 0)
+++ trunk/LayoutTests/http/tests/misc/form-submit-file-cross-site-redirect.html 2019-10-30 18:32:59 UTC (rev 251786)
@@ -0,0 +1,41 @@
+<html>
+<head>
+<script src=""
+<script src=""
+<script>
+
+const tempFileContent = "TEST";
+const tempFileName = "test.tmp";
+
+function onChange()
+{
+ document.forms[0].submit();
+}
+
+function test()
+{
+ let tempFilePath = createTempFile(tempFileName, tempFileContent);
+
+ let input = document.getElementsByTagName("input")[0];
+ input._onchange_ = onChange;
+
+ if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+ testRunner.setOpenPanelFiles([tempFilePath]);
+
+ var centerX = input.offsetLeft + input.offsetWidth / 2;
+ var centerY = input.offsetTop + input.offsetHeight / 2;
+ UIHelper.activateAt(centerX, centerY);
+ }
+}
+
+window._onload_ = test;
+</script>
+</head>
+<body>
+<form enctype="multipart/form-data" method="POST" action=""
+<input name="data" type="file"></input>
+</form>
+</body>
+</html>
Modified: trunk/LayoutTests/platform/win/TestExpectations (251785 => 251786)
--- trunk/LayoutTests/platform/win/TestExpectations 2019-10-30 18:29:56 UTC (rev 251785)
+++ trunk/LayoutTests/platform/win/TestExpectations 2019-10-30 18:32:59 UTC (rev 251786)
@@ -213,6 +213,7 @@
http/tests/fileapi [ Skip ]
fast/forms/file/recover-file-input-in-unposted-form.html [ Skip ]
http/tests/misc/form-submit-file-cross-site.html [ Skip ]
+http/tests/misc/form-submit-file-cross-site-redirect.html [ Skip ]
http/tests/xmlhttprequest/post-blob-content-type-async.html [ Skip ]
http/tests/xmlhttprequest/post-blob-content-type-sync.html [ Skip ]
webkit.org/b/29287 http/tests/local/fileapi/ [ Skip ]
Modified: trunk/Source/WebKit/ChangeLog (251785 => 251786)
--- trunk/Source/WebKit/ChangeLog 2019-10-30 18:29:56 UTC (rev 251785)
+++ trunk/Source/WebKit/ChangeLog 2019-10-30 18:32:59 UTC (rev 251786)
@@ -1,3 +1,30 @@
+2019-10-30 Chris Dumez <[email protected]>
+
+ REGRESSION (r238252): HTTP POST is losing application/x-www-form-urlencoded body if there's a redirect to different host
+ https://bugs.webkit.org/show_bug.cgi?id=201950
+ <rdar://problem/55577782>
+
+ Reviewed by Alex Christensen.
+
+ The resource request body was getting lost on cross-site redirects. This was caused by the fact that a cross-site
+ redirect would cause a process-swap and the request to start again from a new process. This would work fine if
+ the request does not have a body. However, we have an optimization in place which avoids encoding the request body
+ whenever it is sent over IPC. Because the WebResourceLoader::WillSendRequest IPC would not encode the request body,
+ any decision to process swap as a result of this IPC (i.e. redirect) would cause the new request in the new process
+ to be missing its body. To address the issue, we now make sure to pass the request body in the WillSendRequest IPC
+ and reconsile the request with its body on the recipient side.
+
+ Test: http/tests/misc/form-submit-file-cross-site-redirect.html
+
+ * NetworkProcess/NetworkResourceLoader.cpp:
+ (WebKit::NetworkResourceLoader::continueWillSendRedirectedRequest):
+ * NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.cpp:
+ (WebKit::ServiceWorkerFetchTask::didReceiveRedirectResponse):
+ * WebProcess/Network/WebResourceLoader.cpp:
+ (WebKit::WebResourceLoader::willSendRequest):
+ * WebProcess/Network/WebResourceLoader.h:
+ * WebProcess/Network/WebResourceLoader.messages.in:
+
2019-10-30 Jer Noble <[email protected]>
Enable Remote Playback API by default
Modified: trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp (251785 => 251786)
--- trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp 2019-10-30 18:29:56 UTC (rev 251785)
+++ trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp 2019-10-30 18:32:59 UTC (rev 251786)
@@ -723,7 +723,9 @@
if (adClickConversion && (networkSession = m_connection->networkProcess().networkSession(sessionID())))
networkSession->handleAdClickAttributionConversion(WTFMove(*adClickConversion), request.url(), redirectRequest);
- send(Messages::WebResourceLoader::WillSendRequest(redirectRequest, sanitizeResponseIfPossible(WTFMove(redirectResponse), ResourceResponse::SanitizationType::Redirection)));
+ // We send the request body separately because the ResourceRequest body normally does not get encoded when sent over IPC, as an optimization.
+ // However, we really need the body here because a redirect cross-site may cause a process-swap and the request to start again in a new WebContent process.
+ send(Messages::WebResourceLoader::WillSendRequest(redirectRequest, IPC::FormDataReference { redirectRequest.httpBody() }, sanitizeResponseIfPossible(WTFMove(redirectResponse), ResourceResponse::SanitizationType::Redirection)));
}
void NetworkResourceLoader::didFinishWithRedirectResponse(WebCore::ResourceRequest&& request, WebCore::ResourceRequest&& redirectRequest, ResourceResponse&& redirectResponse)
Modified: trunk/Source/WebKit/NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.cpp (251785 => 251786)
--- trunk/Source/WebKit/NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.cpp 2019-10-30 18:29:56 UTC (rev 251785)
+++ trunk/Source/WebKit/NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.cpp 2019-10-30 18:32:59 UTC (rev 251786)
@@ -111,7 +111,7 @@
response.setSource(ResourceResponse::Source::ServiceWorker);
auto newRequest = m_currentRequest.redirectedRequest(response, m_loader.parameters().shouldClearReferrerOnHTTPSToHTTPRedirect);
- sendToClient(Messages::WebResourceLoader::WillSendRequest { newRequest, response });
+ sendToClient(Messages::WebResourceLoader::WillSendRequest { newRequest, IPC::FormDataReference { newRequest.httpBody() }, response });
}
void ServiceWorkerFetchTask::didReceiveResponse(ResourceResponse&& response, bool needsContinueDidReceiveResponseMessage)
Modified: trunk/Source/WebKit/WebProcess/Network/WebResourceLoader.cpp (251785 => 251786)
--- trunk/Source/WebKit/WebProcess/Network/WebResourceLoader.cpp 2019-10-30 18:29:56 UTC (rev 251785)
+++ trunk/Source/WebKit/WebProcess/Network/WebResourceLoader.cpp 2019-10-30 18:32:59 UTC (rev 251786)
@@ -27,6 +27,7 @@
#include "WebResourceLoader.h"
#include "DataReference.h"
+#include "FormDataReference.h"
#include "Logging.h"
#include "NetworkProcessConnection.h"
#include "NetworkResourceLoaderMessages.h"
@@ -92,10 +93,13 @@
m_coreLoader = nullptr;
}
-void WebResourceLoader::willSendRequest(ResourceRequest&& proposedRequest, ResourceResponse&& redirectResponse)
+void WebResourceLoader::willSendRequest(ResourceRequest&& proposedRequest, IPC::FormDataReference&& proposedRequestBody, ResourceResponse&& redirectResponse)
{
Ref<WebResourceLoader> protectedThis(*this);
+ // Make the request whole again as we do not normally encode the request's body when sending it over IPC, for performance reasons.
+ proposedRequest.setHTTPBody(proposedRequestBody.takeData());
+
LOG(Network, "(WebProcess) WebResourceLoader::willSendRequest to '%s'", proposedRequest.url().string().latin1().data());
RELEASE_LOG_IF_ALLOWED("willSendRequest: (webPageID=%" PRIu64 ", frameID=%" PRIu64 ", resourceID=%" PRIu64 ")", m_trackingParameters.pageID.toUInt64(), m_trackingParameters.frameID.toUInt64(), m_trackingParameters.resourceID);
Modified: trunk/Source/WebKit/WebProcess/Network/WebResourceLoader.h (251785 => 251786)
--- trunk/Source/WebKit/WebProcess/Network/WebResourceLoader.h 2019-10-30 18:29:56 UTC (rev 251785)
+++ trunk/Source/WebKit/WebProcess/Network/WebResourceLoader.h 2019-10-30 18:32:59 UTC (rev 251786)
@@ -37,6 +37,7 @@
namespace IPC {
class DataReference;
+class FormDataReference;
}
namespace WebCore {
@@ -79,7 +80,7 @@
IPC::Connection* messageSenderConnection() const override;
uint64_t messageSenderDestinationID() const override;
- void willSendRequest(WebCore::ResourceRequest&&, WebCore::ResourceResponse&&);
+ void willSendRequest(WebCore::ResourceRequest&&, IPC::FormDataReference&& requestBody, WebCore::ResourceResponse&&);
void didSendData(uint64_t bytesSent, uint64_t totalBytesToBeSent);
void didReceiveResponse(const WebCore::ResourceResponse&, bool needsContinueDidReceiveResponseMessage);
void didReceiveData(const IPC::DataReference&, int64_t encodedDataLength);
Modified: trunk/Source/WebKit/WebProcess/Network/WebResourceLoader.messages.in (251785 => 251786)
--- trunk/Source/WebKit/WebProcess/Network/WebResourceLoader.messages.in 2019-10-30 18:29:56 UTC (rev 251785)
+++ trunk/Source/WebKit/WebProcess/Network/WebResourceLoader.messages.in 2019-10-30 18:32:59 UTC (rev 251786)
@@ -21,7 +21,7 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
messages -> WebResourceLoader LegacyReceiver {
- WillSendRequest(WebCore::ResourceRequest request, WebCore::ResourceResponse redirectResponse)
+ WillSendRequest(WebCore::ResourceRequest request, IPC::FormDataReference requestBody, WebCore::ResourceResponse redirectResponse)
DidSendData(uint64_t bytesSent, uint64_t totalBytesToBeSent)
DidReceiveResponse(WebCore::ResourceResponse response, bool needsContinueDidReceiveResponseMessage)
DidReceiveData(IPC::SharedBufferDataReference data, int64_t encodedDataLength)