Diff
Modified: branches/safari-605-branch/LayoutTests/imported/w3c/ChangeLog (228380 => 228381)
--- branches/safari-605-branch/LayoutTests/imported/w3c/ChangeLog 2018-02-12 18:32:28 UTC (rev 228380)
+++ branches/safari-605-branch/LayoutTests/imported/w3c/ChangeLog 2018-02-12 18:32:32 UTC (rev 228381)
@@ -1,3 +1,21 @@
+2018-02-12 Jason Marcell <jmarc...@apple.com>
+
+ Cherry-pick r228326. rdar://problem/37460483
+
+ 2018-02-09 Youenn Fablet <you...@apple.com>
+
+ Add support for cache storage of blob response
+ https://bugs.webkit.org/show_bug.cgi?id=182637
+
+ Reviewed by Brady Eidson.
+
+ * web-platform-tests/service-workers/cache-storage/script-tests/cache-put.js:
+ (cache_test.async):
+ * web-platform-tests/service-workers/cache-storage/serviceworker/cache-put.https-expected.txt:
+ * web-platform-tests/service-workers/cache-storage/window/cache-put.https-expected.txt:
+ * web-platform-tests/service-workers/cache-storage/worker/cache-put.https-expected.txt:
+ * web-platform-tests/service-workers/cache-storage/window/cache-put.https.html:
+
2018-02-07 Jason Marcell <jmarc...@apple.com>
Cherry-pick r228230. rdar://problem/37319241
Modified: branches/safari-605-branch/LayoutTests/imported/w3c/web-platform-tests/service-workers/cache-storage/script-tests/cache-put.js (228380 => 228381)
--- branches/safari-605-branch/LayoutTests/imported/w3c/web-platform-tests/service-workers/cache-storage/script-tests/cache-put.js 2018-02-12 18:32:28 UTC (rev 228380)
+++ branches/safari-605-branch/LayoutTests/imported/w3c/web-platform-tests/service-workers/cache-storage/script-tests/cache-put.js 2018-02-12 18:32:32 UTC (rev 228381)
@@ -335,4 +335,12 @@
});
}, 'Cache.put should store Response.redirect() correctly');
+cache_test(async (cache) => {
+ var request = new Request(test_url);
+ var response = new Response(new Blob([test_body]));
+ await cache.put(request, response);
+ var cachedResponse = await cache.match(request);
+ assert_equals(await cachedResponse.text(), test_body);
+ }, 'Cache.put called with simple Request and blob Response');
+
done();
Modified: branches/safari-605-branch/LayoutTests/imported/w3c/web-platform-tests/service-workers/cache-storage/serviceworker/cache-put.https-expected.txt (228380 => 228381)
--- branches/safari-605-branch/LayoutTests/imported/w3c/web-platform-tests/service-workers/cache-storage/serviceworker/cache-put.https-expected.txt 2018-02-12 18:32:28 UTC (rev 228380)
+++ branches/safari-605-branch/LayoutTests/imported/w3c/web-platform-tests/service-workers/cache-storage/serviceworker/cache-put.https-expected.txt 2018-02-12 18:32:32 UTC (rev 228381)
@@ -23,4 +23,5 @@
PASS Cache.put with a VARY:* Response
PASS Cache.put with an embedded VARY:* Response
PASS Cache.put should store Response.redirect() correctly
+PASS Cache.put called with simple Request and blob Response
Modified: branches/safari-605-branch/LayoutTests/imported/w3c/web-platform-tests/service-workers/cache-storage/window/cache-put.https-expected.txt (228380 => 228381)
--- branches/safari-605-branch/LayoutTests/imported/w3c/web-platform-tests/service-workers/cache-storage/window/cache-put.https-expected.txt 2018-02-12 18:32:28 UTC (rev 228380)
+++ branches/safari-605-branch/LayoutTests/imported/w3c/web-platform-tests/service-workers/cache-storage/window/cache-put.https-expected.txt 2018-02-12 18:32:32 UTC (rev 228381)
@@ -22,4 +22,6 @@
PASS Cache.put with a VARY:* Response
PASS Cache.put with an embedded VARY:* Response
PASS Cache.put should store Response.redirect() correctly
+PASS Cache.put called with simple Request and blob Response
+FAIL Cache.put called with simple Request and form data Response promise_test: Unhandled rejection with value: object "NotSupportedError: Not implemented"
Modified: branches/safari-605-branch/LayoutTests/imported/w3c/web-platform-tests/service-workers/cache-storage/window/cache-put.https.html (228380 => 228381)
--- branches/safari-605-branch/LayoutTests/imported/w3c/web-platform-tests/service-workers/cache-storage/window/cache-put.https.html 2018-02-12 18:32:28 UTC (rev 228380)
+++ branches/safari-605-branch/LayoutTests/imported/w3c/web-platform-tests/service-workers/cache-storage/window/cache-put.https.html 2018-02-12 18:32:32 UTC (rev 228381)
@@ -6,3 +6,16 @@
<script src=""
<script src=""
<script src=""
+<script>
+cache_test(async (cache) => {
+ var formData = new FormData();
+ formData.append("name", "value");
+
+ var request = new Request(test_url);
+ var response = new Response(formData);
+ await cache.put(request, response);
+ var cachedResponse = await cache.match(request);
+ var cachedResponseText = await cachedResponse.text();
+ assert_true(cachedResponseText.indexOf("name=\"name\"\r\n\r\nvalue") !== -1);
+ }, 'Cache.put called with simple Request and form data Response');
+</script>
Modified: branches/safari-605-branch/LayoutTests/imported/w3c/web-platform-tests/service-workers/cache-storage/worker/cache-put.https-expected.txt (228380 => 228381)
--- branches/safari-605-branch/LayoutTests/imported/w3c/web-platform-tests/service-workers/cache-storage/worker/cache-put.https-expected.txt 2018-02-12 18:32:28 UTC (rev 228380)
+++ branches/safari-605-branch/LayoutTests/imported/w3c/web-platform-tests/service-workers/cache-storage/worker/cache-put.https-expected.txt 2018-02-12 18:32:32 UTC (rev 228381)
@@ -22,4 +22,5 @@
PASS Cache.put with a VARY:* Response
PASS Cache.put with an embedded VARY:* Response
PASS Cache.put should store Response.redirect() correctly
+PASS Cache.put called with simple Request and blob Response
Modified: branches/safari-605-branch/Source/WebCore/ChangeLog (228380 => 228381)
--- branches/safari-605-branch/Source/WebCore/ChangeLog 2018-02-12 18:32:28 UTC (rev 228380)
+++ branches/safari-605-branch/Source/WebCore/ChangeLog 2018-02-12 18:32:32 UTC (rev 228381)
@@ -1,3 +1,25 @@
+2018-02-12 Jason Marcell <jmarc...@apple.com>
+
+ Cherry-pick r228326. rdar://problem/37460483
+
+ 2018-02-09 Youenn Fablet <you...@apple.com>
+
+ Add support for cache storage of blob response
+ https://bugs.webkit.org/show_bug.cgi?id=182637
+
+ Reviewed by Brady Eidson.
+
+ Covered by updated WPT test.
+ When putting a blob response in cache, create a readable stream to easily get the body.
+ Make clear that caching form data is not supported.
+
+ * Modules/cache/DOMCache.cpp:
+ (WebCore::DOMCache::put):
+ * Modules/fetch/FetchBody.h:
+ (WebCore::FetchBody::isBlob const):
+ (WebCore::FetchBody::isFormData const):
+ * Modules/fetch/FetchResponse.h:
+
2018-02-12 Dean Jackson <d...@apple.com>
Cherry-pick r228349. rdar://problem/37411410
Modified: branches/safari-605-branch/Source/WebCore/Modules/cache/DOMCache.cpp (228380 => 228381)
--- branches/safari-605-branch/Source/WebCore/Modules/cache/DOMCache.cpp 2018-02-12 18:32:28 UTC (rev 228380)
+++ branches/safari-605-branch/Source/WebCore/Modules/cache/DOMCache.cpp 2018-02-12 18:32:32 UTC (rev 228381)
@@ -340,6 +340,15 @@
return;
}
+ if (response->isBlobFormData()) {
+ promise.reject(Exception { NotSupportedError, ASCIILiteral("Not implemented") });
+ return;
+ }
+
+ // FIXME: for efficiency, we should load blobs directly instead of going through the readableStream path.
+ if (response->isBlobBody())
+ response->readableStream(*scriptExecutionContext()->execState());
+
if (response->isBodyReceivedByChunk()) {
response->consumeBodyReceivedByChunk([promise = WTFMove(promise), request = WTFMove(request), response = WTFMove(response), data = "" pendingActivity = makePendingActivity(*this), this](auto&& result) mutable {
Modified: branches/safari-605-branch/Source/WebCore/Modules/fetch/FetchBody.h (228380 => 228381)
--- branches/safari-605-branch/Source/WebCore/Modules/fetch/FetchBody.h 2018-02-12 18:32:28 UTC (rev 228380)
+++ branches/safari-605-branch/Source/WebCore/Modules/fetch/FetchBody.h 2018-02-12 18:32:32 UTC (rev 228381)
@@ -85,6 +85,9 @@
m_readableStream = WTFMove(stream);
}
+ bool isBlob() const { return WTF::holds_alternative<Ref<const Blob>>(m_data); }
+ bool isFormData() const { return WTF::holds_alternative<Ref<FormData>>(m_data); }
+
private:
explicit FetchBody(Ref<const Blob>&& data) : m_data(WTFMove(data)) { }
explicit FetchBody(Ref<const ArrayBuffer>&& data) : m_data(WTFMove(data)) { }
@@ -102,8 +105,6 @@
void consumeText(Ref<DeferredPromise>&&, const String&);
void consumeBlob(FetchBodyOwner&, Ref<DeferredPromise>&&);
- bool isBlob() const { return WTF::holds_alternative<Ref<const Blob>>(m_data); }
- bool isFormData() const { return WTF::holds_alternative<Ref<FormData>>(m_data); }
bool isArrayBuffer() const { return WTF::holds_alternative<Ref<const ArrayBuffer>>(m_data); }
bool isArrayBufferView() const { return WTF::holds_alternative<Ref<const ArrayBufferView>>(m_data); }
bool isURLSearchParams() const { return WTF::holds_alternative<Ref<const URLSearchParams>>(m_data); }
Modified: branches/safari-605-branch/Source/WebCore/Modules/fetch/FetchResponse.h (228380 => 228381)
--- branches/safari-605-branch/Source/WebCore/Modules/fetch/FetchResponse.h 2018-02-12 18:32:28 UTC (rev 228380)
+++ branches/safari-605-branch/Source/WebCore/Modules/fetch/FetchResponse.h 2018-02-12 18:32:32 UTC (rev 228381)
@@ -93,6 +93,8 @@
bool isLoading() const { return !!m_bodyLoader; }
bool isBodyReceivedByChunk() const { return isLoading() || hasReadableStreamBody(); }
+ bool isBlobBody() const { return !isBodyNull() && body().isBlob(); }
+ bool isBlobFormData() const { return !isBodyNull() && body().isFormData(); }
using ConsumeDataByChunkCallback = WTF::Function<void(ExceptionOr<ReadableStreamChunk*>&&)>;
void consumeBodyReceivedByChunk(ConsumeDataByChunkCallback&&);