Diff
Modified: branches/safari-605-branch/LayoutTests/ChangeLog (228211 => 228212)
--- branches/safari-605-branch/LayoutTests/ChangeLog 2018-02-07 02:45:12 UTC (rev 228211)
+++ branches/safari-605-branch/LayoutTests/ChangeLog 2018-02-07 02:45:16 UTC (rev 228212)
@@ -1,5 +1,18 @@
2018-02-06 Jason Marcell <[email protected]>
+ Cherry-pick r228199. rdar://problem/37294597
+
+ 2018-02-06 Youenn Fablet <[email protected]>
+
+ imported/w3c/web-platform-tests/service-workers/service-worker/fetch-event-respond-with-response-body-with-invalid-chunk.https.html is flaky
+ https://bugs.webkit.org/show_bug.cgi?id=182541
+
+ Reviewed by Chris Dumez.
+
+ * TestExpectations:
+
+2018-02-06 Jason Marcell <[email protected]>
+
Cherry-pick r228198. rdar://problem/37294605
2018-02-06 Chris Dumez <[email protected]>
Modified: branches/safari-605-branch/LayoutTests/TestExpectations (228211 => 228212)
--- branches/safari-605-branch/LayoutTests/TestExpectations 2018-02-07 02:45:12 UTC (rev 228211)
+++ branches/safari-605-branch/LayoutTests/TestExpectations 2018-02-07 02:45:16 UTC (rev 228212)
@@ -181,7 +181,6 @@
imported/w3c/web-platform-tests/service-workers/service-worker/about-blank-replacement.https.html [ Pass Failure ]
imported/w3c/web-platform-tests/service-workers/service-worker/fetch-canvas-tainting-cache.https.html [ DumpJSConsoleLogInStdErr Pass Failure ]
webkit.org/b/179248 imported/w3c/web-platform-tests/service-workers/service-worker/fetch-event-within-sw.https.html [ Pass Failure ]
-imported/w3c/web-platform-tests/service-workers/service-worker/fetch-event-respond-with-response-body-with-invalid-chunk.https.html [ Pass Failure ]
imported/w3c/web-platform-tests/service-workers/service-worker/multiple-update.https.html [ Pass Failure ]
imported/w3c/web-platform-tests/service-workers/service-worker/performance-timeline.https.html [ Pass Failure ]
imported/w3c/web-platform-tests/service-workers/service-worker/registration-service-worker-attributes.https.html [ Pass Failure ]
Modified: branches/safari-605-branch/Source/WebCore/ChangeLog (228211 => 228212)
--- branches/safari-605-branch/Source/WebCore/ChangeLog 2018-02-07 02:45:12 UTC (rev 228211)
+++ branches/safari-605-branch/Source/WebCore/ChangeLog 2018-02-07 02:45:16 UTC (rev 228212)
@@ -1,5 +1,34 @@
2018-02-06 Jason Marcell <[email protected]>
+ Cherry-pick r228199. rdar://problem/37294597
+
+ 2018-02-06 Youenn Fablet <[email protected]>
+
+ imported/w3c/web-platform-tests/service-workers/service-worker/fetch-event-respond-with-response-body-with-invalid-chunk.https.html is flaky
+ https://bugs.webkit.org/show_bug.cgi?id=182541
+
+ Reviewed by Chris Dumez.
+
+ Covered by test being no longer flaky.
+ In case of loading error when getting the response body, we were only reporting
+ the error if there was a callback set or a ReadableStream already created.
+ Otherwise, we were just stopping loading and if creating a ReadableStream, we were just returning an empty body.
+
+ FetchBodyOwner now stores a loading error.
+ In case a readable stream is created, it will error it if there is a loading error.
+ If there is not and the loading failed later on, the stream will be errored using the current code path.
+
+ * Modules/cache/DOMCache.cpp:
+ (WebCore::DOMCache::put):
+ * Modules/fetch/FetchResponse.cpp:
+ (WebCore::FetchResponse::clone):
+ (WebCore::FetchResponse::BodyLoader::didFail):
+ * Modules/fetch/FetchResponse.h:
+ * workers/service/context/ServiceWorkerFetch.cpp:
+ (WebCore::ServiceWorkerFetch::processResponse):
+
+2018-02-06 Jason Marcell <[email protected]>
+
Cherry-pick r228188. rdar://problem/37293107
2018-02-06 Youenn Fablet <[email protected]>
Modified: branches/safari-605-branch/Source/WebCore/Modules/cache/DOMCache.cpp (228211 => 228212)
--- branches/safari-605-branch/Source/WebCore/Modules/cache/DOMCache.cpp 2018-02-07 02:45:12 UTC (rev 228211)
+++ branches/safari-605-branch/Source/WebCore/Modules/cache/DOMCache.cpp 2018-02-07 02:45:16 UTC (rev 228212)
@@ -320,6 +320,11 @@
}
auto request = requestOrException.releaseReturnValue();
+ if (response->loadingError()) {
+ promise.reject(Exception { TypeError, String { response->loadingError()->localizedDescription() } });
+ return;
+ }
+
if (hasResponseVaryStarHeaderValue(response.get())) {
promise.reject(Exception { TypeError, ASCIILiteral("Response has a '*' Vary header value") });
return;
Modified: branches/safari-605-branch/Source/WebCore/Modules/fetch/FetchBodyOwner.cpp (228211 => 228212)
--- branches/safari-605-branch/Source/WebCore/Modules/fetch/FetchBodyOwner.cpp 2018-02-07 02:45:12 UTC (rev 228211)
+++ branches/safari-605-branch/Source/WebCore/Modules/fetch/FetchBodyOwner.cpp 2018-02-07 02:45:16 UTC (rev 228212)
@@ -312,6 +312,12 @@
{
ASSERT(m_readableStreamSource);
+ if (m_loadingError) {
+ auto errorMessage = m_loadingError->localizedDescription();
+ m_readableStreamSource->error(errorMessage.isEmpty() ? ASCIILiteral("Loading failed") : errorMessage);
+ return;
+ }
+
body().consumeAsStream(*this, *m_readableStreamSource);
if (!m_readableStreamSource->isPulling())
m_readableStreamSource = nullptr;
Modified: branches/safari-605-branch/Source/WebCore/Modules/fetch/FetchBodyOwner.h (228211 => 228212)
--- branches/safari-605-branch/Source/WebCore/Modules/fetch/FetchBodyOwner.h 2018-02-07 02:45:12 UTC (rev 228211)
+++ branches/safari-605-branch/Source/WebCore/Modules/fetch/FetchBodyOwner.h 2018-02-07 02:45:16 UTC (rev 228212)
@@ -34,6 +34,7 @@
#include "FetchHeaders.h"
#include "FetchLoader.h"
#include "FetchLoaderClient.h"
+#include "ResourceError.h"
namespace WebCore {
@@ -114,6 +115,7 @@
RefPtr<FetchBodySource> m_readableStreamSource;
#endif
Ref<FetchHeaders> m_headers;
+ std::optional<ResourceError> m_loadingError;
private:
std::optional<BlobLoader> m_blobLoader;
Modified: branches/safari-605-branch/Source/WebCore/Modules/fetch/FetchResponse.cpp (228211 => 228212)
--- branches/safari-605-branch/Source/WebCore/Modules/fetch/FetchResponse.cpp 2018-02-07 02:45:12 UTC (rev 228211)
+++ branches/safari-605-branch/Source/WebCore/Modules/fetch/FetchResponse.cpp 2018-02-07 02:45:16 UTC (rev 228212)
@@ -176,6 +176,7 @@
m_internalResponse.setHTTPHeaderFields(HTTPHeaderMap { headers().internalHeaders() });
auto clone = FetchResponse::create(context, std::nullopt, headers().guard(), ResourceResponse { m_internalResponse });
+ clone->m_loadingError = m_loadingError;
clone->cloneBody(*this);
clone->m_opaqueLoadIdentifier = m_opaqueLoadIdentifier;
clone->m_bodySizeWithPadding = m_bodySizeWithPadding;
@@ -236,6 +237,9 @@
void FetchResponse::BodyLoader::didFail(const ResourceError& error)
{
ASSERT(m_response.hasPendingActivity());
+
+ m_response.m_loadingError = error;
+
if (auto responseCallback = WTFMove(m_responseCallback))
responseCallback(Exception { TypeError, String(error.localizedDescription()) });
Modified: branches/safari-605-branch/Source/WebCore/Modules/fetch/FetchResponse.h (228211 => 228212)
--- branches/safari-605-branch/Source/WebCore/Modules/fetch/FetchResponse.h 2018-02-07 02:45:12 UTC (rev 228211)
+++ branches/safari-605-branch/Source/WebCore/Modules/fetch/FetchResponse.h 2018-02-07 02:45:16 UTC (rev 228212)
@@ -105,6 +105,8 @@
void initializeOpaqueLoadIdentifierForTesting() { m_opaqueLoadIdentifier = 1; }
+ const std::optional<ResourceError>& loadingError() const { return m_loadingError; }
+
private:
FetchResponse(ScriptExecutionContext&, std::optional<FetchBody>&&, Ref<FetchHeaders>&&, ResourceResponse&&);
Modified: branches/safari-605-branch/Source/WebCore/workers/service/context/ServiceWorkerFetch.cpp (228211 => 228212)
--- branches/safari-605-branch/Source/WebCore/workers/service/context/ServiceWorkerFetch.cpp 2018-02-07 02:45:12 UTC (rev 228211)
+++ branches/safari-605-branch/Source/WebCore/workers/service/context/ServiceWorkerFetch.cpp 2018-02-07 02:45:16 UTC (rev 228212)
@@ -53,6 +53,11 @@
client->didReceiveResponse(response->resourceResponse());
+ if (response->loadingError()) {
+ client->didFail();
+ return;
+ }
+
if (response->isBodyReceivedByChunk()) {
response->consumeBodyReceivedByChunk([client = WTFMove(client)] (auto&& result) mutable {
if (result.hasException()) {