Changeset 228381 in webkit


Ignore:
Timestamp:
Feb 12, 2018 10:32:32 AM (6 years ago)
Author:
jmarcell@apple.com
Message:

Cherry-pick r228326. rdar://problem/37460483

Location:
branches/safari-605-branch
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-605-branch/LayoutTests/imported/w3c/ChangeLog

    r228233 r228381  
     12018-02-12  Jason Marcell  <jmarcell@apple.com>
     2
     3        Cherry-pick r228326. rdar://problem/37460483
     4
     5    2018-02-09  Youenn Fablet  <youenn@apple.com>
     6
     7            Add support for cache storage of blob response
     8            https://bugs.webkit.org/show_bug.cgi?id=182637
     9
     10            Reviewed by Brady Eidson.
     11
     12            * web-platform-tests/service-workers/cache-storage/script-tests/cache-put.js:
     13            (cache_test.async):
     14            * web-platform-tests/service-workers/cache-storage/serviceworker/cache-put.https-expected.txt:
     15            * web-platform-tests/service-workers/cache-storage/window/cache-put.https-expected.txt:
     16            * web-platform-tests/service-workers/cache-storage/worker/cache-put.https-expected.txt:
     17            * web-platform-tests/service-workers/cache-storage/window/cache-put.https.html:
     18
    1192018-02-07  Jason Marcell  <jmarcell@apple.com>
    220
  • branches/safari-605-branch/LayoutTests/imported/w3c/web-platform-tests/service-workers/cache-storage/script-tests/cache-put.js

    r220223 r228381  
    336336  }, 'Cache.put should store Response.redirect() correctly');
    337337
     338cache_test(async (cache) => {
     339    var request = new Request(test_url);
     340    var response = new Response(new Blob([test_body]));
     341    await cache.put(request, response);
     342    var cachedResponse = await cache.match(request);
     343    assert_equals(await cachedResponse.text(), test_body);
     344  }, 'Cache.put called with simple Request and blob Response');
     345
    338346done();
  • branches/safari-605-branch/LayoutTests/imported/w3c/web-platform-tests/service-workers/cache-storage/serviceworker/cache-put.https-expected.txt

    r224250 r228381  
    2424PASS Cache.put with an embedded VARY:* Response
    2525PASS Cache.put should store Response.redirect() correctly
     26PASS Cache.put called with simple Request and blob Response
    2627
  • branches/safari-605-branch/LayoutTests/imported/w3c/web-platform-tests/service-workers/cache-storage/window/cache-put.https-expected.txt

    r221024 r228381  
    2323PASS Cache.put with an embedded VARY:* Response
    2424PASS Cache.put should store Response.redirect() correctly
     25PASS Cache.put called with simple Request and blob Response
     26FAIL Cache.put called with simple Request and form data Response promise_test: Unhandled rejection with value: object "NotSupportedError: Not implemented"
    2527
  • branches/safari-605-branch/LayoutTests/imported/w3c/web-platform-tests/service-workers/cache-storage/window/cache-put.https.html

    r220223 r228381  
    77<script src="../resources/test-helpers.js"></script>
    88<script src="../script-tests/cache-put.js"></script>
     9<script>
     10cache_test(async (cache) => {
     11    var formData = new FormData();
     12    formData.append("name", "value");
     13
     14    var request = new Request(test_url);
     15    var response = new Response(formData);
     16    await cache.put(request, response);
     17    var cachedResponse = await cache.match(request);
     18    var cachedResponseText = await cachedResponse.text();
     19    assert_true(cachedResponseText.indexOf("name=\"name\"\r\n\r\nvalue") !== -1);
     20  }, 'Cache.put called with simple Request and form data Response');
     21</script>
  • branches/safari-605-branch/LayoutTests/imported/w3c/web-platform-tests/service-workers/cache-storage/worker/cache-put.https-expected.txt

    r221704 r228381  
    2323PASS Cache.put with an embedded VARY:* Response
    2424PASS Cache.put should store Response.redirect() correctly
     25PASS Cache.put called with simple Request and blob Response
    2526
  • branches/safari-605-branch/Source/WebCore/ChangeLog

    r228372 r228381  
     12018-02-12  Jason Marcell  <jmarcell@apple.com>
     2
     3        Cherry-pick r228326. rdar://problem/37460483
     4
     5    2018-02-09  Youenn Fablet  <youenn@apple.com>
     6
     7            Add support for cache storage of blob response
     8            https://bugs.webkit.org/show_bug.cgi?id=182637
     9
     10            Reviewed by Brady Eidson.
     11
     12            Covered by updated WPT test.
     13            When putting a blob response in cache, create a readable stream to easily get the body.
     14            Make clear that caching form data is not supported.
     15
     16            * Modules/cache/DOMCache.cpp:
     17            (WebCore::DOMCache::put):
     18            * Modules/fetch/FetchBody.h:
     19            (WebCore::FetchBody::isBlob const):
     20            (WebCore::FetchBody::isFormData const):
     21            * Modules/fetch/FetchResponse.h:
     22
    1232018-02-12  Dean Jackson  <dino@apple.com>
    224
  • branches/safari-605-branch/Source/WebCore/Modules/cache/DOMCache.cpp

    r228212 r228381  
    341341    }
    342342
     343    if (response->isBlobFormData()) {
     344        promise.reject(Exception { NotSupportedError, ASCIILiteral("Not implemented") });
     345        return;
     346    }
     347
     348    // FIXME: for efficiency, we should load blobs directly instead of going through the readableStream path.
     349    if (response->isBlobBody())
     350        response->readableStream(*scriptExecutionContext()->execState());
     351
    343352    if (response->isBodyReceivedByChunk()) {
    344353        response->consumeBodyReceivedByChunk([promise = WTFMove(promise), request = WTFMove(request), response = WTFMove(response), data = SharedBuffer::create(), pendingActivity = makePendingActivity(*this), this](auto&& result) mutable {
  • branches/safari-605-branch/Source/WebCore/Modules/fetch/FetchBody.h

    r227023 r228381  
    8686    }
    8787
     88    bool isBlob() const { return WTF::holds_alternative<Ref<const Blob>>(m_data); }
     89    bool isFormData() const { return WTF::holds_alternative<Ref<FormData>>(m_data); }
     90
    8891private:
    8992    explicit FetchBody(Ref<const Blob>&& data) : m_data(WTFMove(data)) { }
     
    103106    void consumeBlob(FetchBodyOwner&, Ref<DeferredPromise>&&);
    104107
    105     bool isBlob() const { return WTF::holds_alternative<Ref<const Blob>>(m_data); }
    106     bool isFormData() const { return WTF::holds_alternative<Ref<FormData>>(m_data); }
    107108    bool isArrayBuffer() const { return WTF::holds_alternative<Ref<const ArrayBuffer>>(m_data); }
    108109    bool isArrayBufferView() const { return WTF::holds_alternative<Ref<const ArrayBufferView>>(m_data); }
  • branches/safari-605-branch/Source/WebCore/Modules/fetch/FetchResponse.h

    r228212 r228381  
    9494    bool isLoading() const { return !!m_bodyLoader; }
    9595    bool isBodyReceivedByChunk() const { return isLoading() || hasReadableStreamBody(); }
     96    bool isBlobBody() const { return !isBodyNull() && body().isBlob(); }
     97    bool isBlobFormData() const { return !isBodyNull() && body().isFormData(); }
    9698
    9799    using ConsumeDataByChunkCallback = WTF::Function<void(ExceptionOr<ReadableStreamChunk*>&&)>;
Note: See TracChangeset for help on using the changeset viewer.