Title: [244515] trunk
Revision
244515
Author
you...@apple.com
Date
2019-04-22 15:12:03 -0700 (Mon, 22 Apr 2019)

Log 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:

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (244514 => 244515)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2019-04-22 22:11:14 UTC (rev 244514)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2019-04-22 22:12:03 UTC (rev 244515)
@@ -1,3 +1,14 @@
+2019-04-22  Youenn Fablet  <you...@apple.com>
+
+        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.
+
+        * 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:
+
 2019-04-19  Antoine Quint  <grao...@apple.com>
 
         [Pointer Events WPT] Provide iOS testdriver

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/cache-storage/serviceworker/cache-abort.https-expected.txt (244514 => 244515)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/cache-storage/serviceworker/cache-abort.https-expected.txt	2019-04-22 22:11:14 UTC (rev 244514)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/cache-storage/serviceworker/cache-abort.https-expected.txt	2019-04-22 22:12:03 UTC (rev 244515)
@@ -2,11 +2,11 @@
 PASS Cache Storage: Abort 
 PASS put() on an already-aborted request should reject with AbortError 
 PASS put() synchronously followed by abort should reject with AbortError 
-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
+PASS put() followed by abort after headers received should reject with AbortError 
 PASS add() on an already-aborted request should reject with AbortError 
 PASS add() synchronously followed by abort should reject with AbortError 
-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
+PASS add() followed by abort after headers received should reject with AbortError 
 PASS addAll() on an already-aborted request should reject with AbortError 
 PASS addAll() synchronously followed by abort should reject with AbortError 
-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
+PASS addAll() followed by abort after headers received should reject with AbortError 
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/cache-storage/window/cache-abort.https-expected.txt (244514 => 244515)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/cache-storage/window/cache-abort.https-expected.txt	2019-04-22 22:11:14 UTC (rev 244514)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/cache-storage/window/cache-abort.https-expected.txt	2019-04-22 22:12:03 UTC (rev 244515)
@@ -1,11 +1,11 @@
 
 PASS put() on an already-aborted request should reject with AbortError 
 PASS put() synchronously followed by abort should reject with AbortError 
-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
+PASS put() followed by abort after headers received should reject with AbortError 
 PASS add() on an already-aborted request should reject with AbortError 
 PASS add() synchronously followed by abort should reject with AbortError 
-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
+PASS add() followed by abort after headers received should reject with AbortError 
 PASS addAll() on an already-aborted request should reject with AbortError 
 PASS addAll() synchronously followed by abort should reject with AbortError 
-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
+PASS addAll() followed by abort after headers received should reject with AbortError 
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/cache-storage/worker/cache-abort.https-expected.txt (244514 => 244515)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/cache-storage/worker/cache-abort.https-expected.txt	2019-04-22 22:11:14 UTC (rev 244514)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/cache-storage/worker/cache-abort.https-expected.txt	2019-04-22 22:12:03 UTC (rev 244515)
@@ -1,11 +1,11 @@
 
 PASS put() on an already-aborted request should reject with AbortError 
 PASS put() synchronously followed by abort should reject with AbortError 
-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
+PASS put() followed by abort after headers received should reject with AbortError 
 PASS add() on an already-aborted request should reject with AbortError 
 PASS add() synchronously followed by abort should reject with AbortError 
-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
+PASS add() followed by abort after headers received should reject with AbortError 
 PASS addAll() on an already-aborted request should reject with AbortError 
 PASS addAll() synchronously followed by abort should reject with AbortError 
-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
+PASS addAll() followed by abort after headers received should reject with AbortError 
 

Modified: trunk/Source/WebCore/ChangeLog (244514 => 244515)


--- trunk/Source/WebCore/ChangeLog	2019-04-22 22:11:14 UTC (rev 244514)
+++ trunk/Source/WebCore/ChangeLog	2019-04-22 22:12:03 UTC (rev 244515)
@@ -1,5 +1,24 @@
 2019-04-22  Youenn Fablet  <you...@apple.com>
 
+        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.
+
+        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:
+
+2019-04-22  Youenn Fablet  <you...@apple.com>
+
         Update libwebrtc logging when WebCore WebRTC logging is updated
         https://bugs.webkit.org/show_bug.cgi?id=197166
 

Modified: trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp (244514 => 244515)


--- trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp	2019-04-22 22:11:14 UTC (rev 244514)
+++ trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp	2019-04-22 22:12:03 UTC (rev 244515)
@@ -201,6 +201,9 @@
         if (m_bodyLoader) {
             if (auto callback = m_bodyLoader->takeNotificationCallback())
                 callback(Exception { AbortError, "Fetch is aborted"_s });
+
+            if (auto callback = m_bodyLoader->takeConsumeDataCallback())
+                callback(Exception { AbortError, "Fetch is aborted"_s });
         }
 
         if (m_readableStreamSource) {
@@ -211,10 +214,8 @@
         if (m_body)
             m_body->loadingFailed(*loadingException());
 
-        if (m_bodyLoader) {
-            m_bodyLoader->stop();
-            m_bodyLoader = WTF::nullopt;
-        }
+        if (auto bodyLoader = WTFMove(m_bodyLoader))
+            bodyLoader->stop();
     });
 }
 
@@ -304,7 +305,7 @@
 #endif
 
     // Check whether didFail is called as part of FetchLoader::start.
-    if (m_loader->isStarted()) {
+    if (m_loader && m_loader->isStarted()) {
         Ref<FetchResponse> protector(m_response);
         m_response.m_bodyLoader = WTF::nullopt;
     }
@@ -313,13 +314,12 @@
 FetchResponse::BodyLoader::BodyLoader(FetchResponse& response, NotificationCallback&& responseCallback)
     : m_response(response)
     , m_responseCallback(WTFMove(responseCallback))
+    , m_pendingActivity(m_response.makePendingActivity(m_response))
 {
-    m_response.setPendingActivity(m_response);
 }
 
 FetchResponse::BodyLoader::~BodyLoader()
 {
-    m_response.unsetPendingActivity(m_response);
 }
 
 static uint64_t nextOpaqueLoadIdentifier { 0 };
@@ -521,10 +521,8 @@
 {
     RefPtr<FetchResponse> protectedThis(this);
     FetchBodyOwner::stop();
-    if (m_bodyLoader) {
-        m_bodyLoader->stop();
-        m_bodyLoader = WTF::nullopt;
-    }
+    if (auto bodyLoader = WTFMove(m_bodyLoader))
+        bodyLoader->stop();
 }
 
 const char* FetchResponse::activeDOMObjectName() const

Modified: trunk/Source/WebCore/Modules/fetch/FetchResponse.h (244514 => 244515)


--- trunk/Source/WebCore/Modules/fetch/FetchResponse.h	2019-04-22 22:11:14 UTC (rev 244514)
+++ trunk/Source/WebCore/Modules/fetch/FetchResponse.h	2019-04-22 22:12:03 UTC (rev 244515)
@@ -129,6 +129,7 @@
     class BodyLoader final : public FetchLoaderClient {
     public:
         BodyLoader(FetchResponse&, NotificationCallback&&);
+        BodyLoader(BodyLoader&&) = default;
         ~BodyLoader();
 
         bool start(ScriptExecutionContext&, const FetchRequest&);
@@ -140,6 +141,7 @@
         RefPtr<SharedBuffer> startStreaming();
 #endif
         NotificationCallback takeNotificationCallback() { return WTFMove(m_responseCallback); }
+        ConsumeDataByChunkCallback takeConsumeDataCallback() { return WTFMove(m_consumeDataCallback); }
 
     private:
         // FetchLoaderClient API
@@ -152,6 +154,7 @@
         NotificationCallback m_responseCallback;
         ConsumeDataByChunkCallback m_consumeDataCallback;
         std::unique_ptr<FetchLoader> m_loader;
+        Ref<PendingActivity<FetchResponse>> m_pendingActivity;
     };
 
     mutable Optional<ResourceResponse> m_filteredResponse;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to