Changeset 244515 in webkit


Ignore:
Timestamp:
Apr 22, 2019 3:12:03 PM (5 years ago)
Author:
youenn@apple.com
Message:

Cache API should return Abort error in case of putting an aborted fetch
https://bugs.webkit.org/show_bug.cgi?id=196757

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

  • web-platform-tests/service-workers/cache-storage/serviceworker/cache-abort.https-expected.txt:
  • web-platform-tests/service-workers/cache-storage/window/cache-abort.https-expected.txt:
  • web-platform-tests/service-workers/cache-storage/worker/cache-abort.https-expected.txt:

Source/WebCore:

In case of an aborted fetch, call consume callback with an AbortError.
Update the code that handles load cancelling as the loader callback is called.
Covered by rebased tests.

  • Modules/fetch/FetchResponse.cpp:

(WebCore::FetchResponse::addAbortSteps):
(WebCore::FetchResponse::BodyLoader::didFail):
(WebCore::FetchResponse::BodyLoader::BodyLoader):
(WebCore::FetchResponse::BodyLoader::~BodyLoader):
(WebCore::FetchResponse::stop):

  • Modules/fetch/FetchResponse.h:
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r244460 r244515  
     12019-04-22  Youenn Fablet  <youenn@apple.com>
     2
     3        Cache API should return Abort error in case of putting an aborted fetch
     4        https://bugs.webkit.org/show_bug.cgi?id=196757
     5
     6        Reviewed by Darin Adler.
     7
     8        * web-platform-tests/service-workers/cache-storage/serviceworker/cache-abort.https-expected.txt:
     9        * web-platform-tests/service-workers/cache-storage/window/cache-abort.https-expected.txt:
     10        * web-platform-tests/service-workers/cache-storage/worker/cache-abort.https-expected.txt:
     11
    1122019-04-19  Antoine Quint  <graouts@apple.com>
    213
  • trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/cache-storage/serviceworker/cache-abort.https-expected.txt

    r244094 r244515  
    33PASS put() on an already-aborted request should reject with AbortError
    44PASS put() synchronously followed by abort should reject with AbortError
    5 FAIL put() followed by abort after headers received should reject with AbortError assert_throws: put should reject function "function () { throw e }" threw object "TypeError: Type error" that is not a DOMException AbortError: property "code" is equal to undefined, expected 20
     5PASS put() followed by abort after headers received should reject with AbortError
    66PASS add() on an already-aborted request should reject with AbortError
    77PASS add() synchronously followed by abort should reject with AbortError
    8 FAIL add() followed by abort after headers received should reject with AbortError assert_throws: add should reject function "function () { throw e }" threw object "TypeError: Type error" that is not a DOMException AbortError: property "code" is equal to undefined, expected 20
     8PASS add() followed by abort after headers received should reject with AbortError
    99PASS addAll() on an already-aborted request should reject with AbortError
    1010PASS addAll() synchronously followed by abort should reject with AbortError
    11 FAIL addAll() followed by abort after headers received should reject with AbortError assert_throws: addAll should reject function "function () { throw e }" threw object "TypeError: Type error" that is not a DOMException AbortError: property "code" is equal to undefined, expected 20
     11PASS addAll() followed by abort after headers received should reject with AbortError
    1212
  • trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/cache-storage/window/cache-abort.https-expected.txt

    r244094 r244515  
    22PASS put() on an already-aborted request should reject with AbortError
    33PASS put() synchronously followed by abort should reject with AbortError
    4 FAIL put() followed by abort after headers received should reject with AbortError assert_throws: put should reject function "function () { throw e }" threw object "TypeError: Load cancelled" that is not a DOMException AbortError: property "code" is equal to undefined, expected 20
     4PASS put() followed by abort after headers received should reject with AbortError
    55PASS add() on an already-aborted request should reject with AbortError
    66PASS add() synchronously followed by abort should reject with AbortError
    7 FAIL add() followed by abort after headers received should reject with AbortError assert_throws: add should reject function "function () { throw e }" threw object "TypeError: Load cancelled" that is not a DOMException AbortError: property "code" is equal to undefined, expected 20
     7PASS add() followed by abort after headers received should reject with AbortError
    88PASS addAll() on an already-aborted request should reject with AbortError
    99PASS addAll() synchronously followed by abort should reject with AbortError
    10 FAIL addAll() followed by abort after headers received should reject with AbortError assert_throws: addAll should reject function "function () { throw e }" threw object "TypeError: Load cancelled" that is not a DOMException AbortError: property "code" is equal to undefined, expected 20
     10PASS addAll() followed by abort after headers received should reject with AbortError
    1111
  • trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/cache-storage/worker/cache-abort.https-expected.txt

    r244094 r244515  
    22PASS put() on an already-aborted request should reject with AbortError
    33PASS put() synchronously followed by abort should reject with AbortError
    4 FAIL put() followed by abort after headers received should reject with AbortError assert_throws: put should reject function "function () { throw e }" threw object "TypeError: Type error" that is not a DOMException AbortError: property "code" is equal to undefined, expected 20
     4PASS put() followed by abort after headers received should reject with AbortError
    55PASS add() on an already-aborted request should reject with AbortError
    66PASS add() synchronously followed by abort should reject with AbortError
    7 FAIL add() followed by abort after headers received should reject with AbortError assert_throws: add should reject function "function () { throw e }" threw object "TypeError: Type error" that is not a DOMException AbortError: property "code" is equal to undefined, expected 20
     7PASS add() followed by abort after headers received should reject with AbortError
    88PASS addAll() on an already-aborted request should reject with AbortError
    99PASS addAll() synchronously followed by abort should reject with AbortError
    10 FAIL addAll() followed by abort after headers received should reject with AbortError assert_throws: addAll should reject function "function () { throw e }" threw object "TypeError: Type error" that is not a DOMException AbortError: property "code" is equal to undefined, expected 20
     10PASS addAll() followed by abort after headers received should reject with AbortError
    1111
  • trunk/Source/WebCore/ChangeLog

    r244511 r244515  
     12019-04-22  Youenn Fablet  <youenn@apple.com>
     2
     3        Cache API should return Abort error in case of putting an aborted fetch
     4        https://bugs.webkit.org/show_bug.cgi?id=196757
     5
     6        Reviewed by Darin Adler.
     7
     8        In case of an aborted fetch, call consume callback with an AbortError.
     9        Update the code that handles load cancelling as the loader callback is called.
     10        Covered by rebased tests.
     11
     12        * Modules/fetch/FetchResponse.cpp:
     13        (WebCore::FetchResponse::addAbortSteps):
     14        (WebCore::FetchResponse::BodyLoader::didFail):
     15        (WebCore::FetchResponse::BodyLoader::BodyLoader):
     16        (WebCore::FetchResponse::BodyLoader::~BodyLoader):
     17        (WebCore::FetchResponse::stop):
     18        * Modules/fetch/FetchResponse.h:
     19
    1202019-04-22  Youenn Fablet  <youenn@apple.com>
    221
  • trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp

    r243163 r244515  
    202202            if (auto callback = m_bodyLoader->takeNotificationCallback())
    203203                callback(Exception { AbortError, "Fetch is aborted"_s });
     204
     205            if (auto callback = m_bodyLoader->takeConsumeDataCallback())
     206                callback(Exception { AbortError, "Fetch is aborted"_s });
    204207        }
    205208
     
    212215            m_body->loadingFailed(*loadingException());
    213216
    214         if (m_bodyLoader) {
    215             m_bodyLoader->stop();
    216             m_bodyLoader = WTF::nullopt;
    217         }
     217        if (auto bodyLoader = WTFMove(m_bodyLoader))
     218            bodyLoader->stop();
    218219    });
    219220}
     
    305306
    306307    // Check whether didFail is called as part of FetchLoader::start.
    307     if (m_loader->isStarted()) {
     308    if (m_loader && m_loader->isStarted()) {
    308309        Ref<FetchResponse> protector(m_response);
    309310        m_response.m_bodyLoader = WTF::nullopt;
     
    314315    : m_response(response)
    315316    , m_responseCallback(WTFMove(responseCallback))
    316 {
    317     m_response.setPendingActivity(m_response);
     317    , m_pendingActivity(m_response.makePendingActivity(m_response))
     318{
    318319}
    319320
    320321FetchResponse::BodyLoader::~BodyLoader()
    321322{
    322     m_response.unsetPendingActivity(m_response);
    323323}
    324324
     
    522522    RefPtr<FetchResponse> protectedThis(this);
    523523    FetchBodyOwner::stop();
    524     if (m_bodyLoader) {
    525         m_bodyLoader->stop();
    526         m_bodyLoader = WTF::nullopt;
    527     }
     524    if (auto bodyLoader = WTFMove(m_bodyLoader))
     525        bodyLoader->stop();
    528526}
    529527
  • trunk/Source/WebCore/Modules/fetch/FetchResponse.h

    r239644 r244515  
    130130    public:
    131131        BodyLoader(FetchResponse&, NotificationCallback&&);
     132        BodyLoader(BodyLoader&&) = default;
    132133        ~BodyLoader();
    133134
     
    141142#endif
    142143        NotificationCallback takeNotificationCallback() { return WTFMove(m_responseCallback); }
     144        ConsumeDataByChunkCallback takeConsumeDataCallback() { return WTFMove(m_consumeDataCallback); }
    143145
    144146    private:
     
    153155        ConsumeDataByChunkCallback m_consumeDataCallback;
    154156        std::unique_ptr<FetchLoader> m_loader;
     157        Ref<PendingActivity<FetchResponse>> m_pendingActivity;
    155158    };
    156159
Note: See TracChangeset for help on using the changeset viewer.