Title: [227245] trunk
Revision
227245
Author
[email protected]
Date
2018-01-19 15:26:13 -0800 (Fri, 19 Jan 2018)

Log Message

Cache storage errors like Quota should trigger console messages
https://bugs.webkit.org/show_bug.cgi?id=181879
<rdar://problem/36669048>

Patch by Youenn Fablet <[email protected]> on 2018-01-19
Reviewed by Chris Dumez.

Source/WebCore:

Covered by rebased test.

* Modules/cache/DOMCache.cpp:
(WebCore::DOMCache::retrieveRecords):
(WebCore::DOMCache::batchDeleteOperation):
(WebCore::DOMCache::batchPutOperation):
* Modules/cache/DOMCacheEngine.cpp:
(WebCore::DOMCacheEngine::errorToException):
(WebCore::DOMCacheEngine::logErrorAndConvertToException):
* Modules/cache/DOMCacheEngine.h:
* Modules/cache/DOMCacheStorage.cpp:
(WebCore::DOMCacheStorage::retrieveCaches):
(WebCore::DOMCacheStorage::doOpen):
(WebCore::DOMCacheStorage::doRemove):

LayoutTests:

* http/wpt/cache-storage/cache-quota.any-expected.txt:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (227244 => 227245)


--- trunk/LayoutTests/ChangeLog	2018-01-19 23:18:44 UTC (rev 227244)
+++ trunk/LayoutTests/ChangeLog	2018-01-19 23:26:13 UTC (rev 227245)
@@ -1,3 +1,13 @@
+2018-01-19  Youenn Fablet  <[email protected]>
+
+        Cache storage errors like Quota should trigger console messages
+        https://bugs.webkit.org/show_bug.cgi?id=181879
+        <rdar://problem/36669048>
+
+        Reviewed by Chris Dumez.
+
+        * http/wpt/cache-storage/cache-quota.any-expected.txt:
+
 2018-01-19  Dean Jackson  <[email protected]>
 
         REGRESSION (r221092): Swipe actions are hard to perform in FastMail app

Modified: trunk/LayoutTests/http/wpt/cache-storage/cache-quota.any-expected.txt (227244 => 227245)


--- trunk/LayoutTests/http/wpt/cache-storage/cache-quota.any-expected.txt	2018-01-19 23:18:44 UTC (rev 227244)
+++ trunk/LayoutTests/http/wpt/cache-storage/cache-quota.any-expected.txt	2018-01-19 23:26:13 UTC (rev 227245)
@@ -1,3 +1,5 @@
+CONSOLE MESSAGE: Cache API operation failed: Quota exceeded
+CONSOLE MESSAGE: Cache API operation failed: Quota exceeded
 
 PASS Testing synthetic response body size padding 
 PASS Testing non opaque response body size padding 

Modified: trunk/Source/WebCore/ChangeLog (227244 => 227245)


--- trunk/Source/WebCore/ChangeLog	2018-01-19 23:18:44 UTC (rev 227244)
+++ trunk/Source/WebCore/ChangeLog	2018-01-19 23:26:13 UTC (rev 227245)
@@ -1,5 +1,28 @@
 2018-01-19  Youenn Fablet  <[email protected]>
 
+        Cache storage errors like Quota should trigger console messages
+        https://bugs.webkit.org/show_bug.cgi?id=181879
+        <rdar://problem/36669048>
+
+        Reviewed by Chris Dumez.
+
+        Covered by rebased test.
+
+        * Modules/cache/DOMCache.cpp:
+        (WebCore::DOMCache::retrieveRecords):
+        (WebCore::DOMCache::batchDeleteOperation):
+        (WebCore::DOMCache::batchPutOperation):
+        * Modules/cache/DOMCacheEngine.cpp:
+        (WebCore::DOMCacheEngine::errorToException):
+        (WebCore::DOMCacheEngine::logErrorAndConvertToException):
+        * Modules/cache/DOMCacheEngine.h:
+        * Modules/cache/DOMCacheStorage.cpp:
+        (WebCore::DOMCacheStorage::retrieveCaches):
+        (WebCore::DOMCacheStorage::doOpen):
+        (WebCore::DOMCacheStorage::doRemove):
+
+2018-01-19  Youenn Fablet  <[email protected]>
+
         Do not go to the storage process when registering a service worker client if there is no service worker registered
         https://bugs.webkit.org/show_bug.cgi?id=181740
         <rdar://problem/36650400>

Modified: trunk/Source/WebCore/Modules/cache/DOMCache.cpp (227244 => 227245)


--- trunk/Source/WebCore/Modules/cache/DOMCache.cpp	2018-01-19 23:18:44 UTC (rev 227244)
+++ trunk/Source/WebCore/Modules/cache/DOMCache.cpp	2018-01-19 23:26:13 UTC (rev 227245)
@@ -421,7 +421,7 @@
     m_connection->retrieveRecords(m_identifier, retrieveURL, [this, callback = WTFMove(callback)](RecordsOrError&& result) {
         if (!m_isStopped) {
             if (!result.has_value()) {
-                callback(DOMCacheEngine::errorToException(result.error()));
+                callback(DOMCacheEngine::convertToExceptionAndLog(scriptExecutionContext(), result.error()));
                 return;
             }
 
@@ -470,7 +470,7 @@
     m_connection->batchDeleteOperation(m_identifier, request.internalRequest(), WTFMove(options), [this, callback = WTFMove(callback)](RecordIdentifiersOrError&& result) {
         if (!m_isStopped) {
             if (!result.has_value())
-                callback(DOMCacheEngine::errorToException(result.error()));
+                callback(DOMCacheEngine::convertToExceptionAndLog(scriptExecutionContext(), result.error()));
             else
                 callback(!result.value().isEmpty());
         }
@@ -513,7 +513,7 @@
     m_connection->batchPutOperation(m_identifier, WTFMove(records), [this, callback = WTFMove(callback)](RecordIdentifiersOrError&& result) {
         if (!m_isStopped) {
             if (!result.has_value())
-                callback(DOMCacheEngine::errorToException(result.error()));
+                callback(DOMCacheEngine::convertToExceptionAndLog(scriptExecutionContext(), result.error()));
             else
                 callback({ });
         }

Modified: trunk/Source/WebCore/Modules/cache/DOMCacheEngine.cpp (227244 => 227245)


--- trunk/Source/WebCore/Modules/cache/DOMCacheEngine.cpp	2018-01-19 23:18:44 UTC (rev 227244)
+++ trunk/Source/WebCore/Modules/cache/DOMCacheEngine.cpp	2018-01-19 23:26:13 UTC (rev 227245)
@@ -35,7 +35,7 @@
 
 namespace DOMCacheEngine {
 
-Exception errorToException(Error error)
+static inline Exception errorToException(Error error)
 {
     switch (error) {
     case Error::NotImplemented:
@@ -51,6 +51,14 @@
     }
 }
 
+Exception convertToExceptionAndLog(ScriptExecutionContext* context, Error error)
+{
+    auto exception = errorToException(error);
+    if (context)
+        context->addConsoleMessage(MessageSource::JS, MessageLevel::Error, makeString("Cache API operation failed: ", exception.message()));
+    return exception;
+}
+
 static inline bool matchURLs(const ResourceRequest& request, const URL& cachedURL, const CacheQueryOptions& options)
 {
     ASSERT(options.ignoreMethod || request.httpMethod() == "GET");

Modified: trunk/Source/WebCore/Modules/cache/DOMCacheEngine.h (227244 => 227245)


--- trunk/Source/WebCore/Modules/cache/DOMCacheEngine.h	2018-01-19 23:18:44 UTC (rev 227244)
+++ trunk/Source/WebCore/Modules/cache/DOMCacheEngine.h	2018-01-19 23:26:13 UTC (rev 227245)
@@ -30,6 +30,7 @@
 #include "FetchOptions.h"
 #include "ResourceRequest.h"
 #include "ResourceResponse.h"
+#include "ScriptExecutionContext.h"
 #include "SharedBuffer.h"
 
 namespace WebCore {
@@ -46,7 +47,7 @@
     Internal
 };
 
-WEBCORE_EXPORT Exception errorToException(Error);
+Exception convertToExceptionAndLog(ScriptExecutionContext*, Error);
 
 WEBCORE_EXPORT bool queryCacheMatch(const ResourceRequest& request, const ResourceRequest& cachedRequest, const ResourceResponse&, const CacheQueryOptions&);
 WEBCORE_EXPORT bool queryCacheMatch(const ResourceRequest& request, const URL& url, bool hasVaryStar, const HashMap<String, String>& varyHeaders, const CacheQueryOptions&);

Modified: trunk/Source/WebCore/Modules/cache/DOMCacheStorage.cpp (227244 => 227245)


--- trunk/Source/WebCore/Modules/cache/DOMCacheStorage.cpp	2018-01-19 23:18:44 UTC (rev 227244)
+++ trunk/Source/WebCore/Modules/cache/DOMCacheStorage.cpp	2018-01-19 23:26:13 UTC (rev 227245)
@@ -145,7 +145,7 @@
     m_connection->retrieveCaches(*origin, m_updateCounter, [this, callback = WTFMove(callback), pendingActivity = makePendingActivity(*this)](CacheInfosOrError&& result) mutable {
         if (!m_isStopped) {
             if (!result.has_value()) {
-                callback(DOMCacheEngine::errorToException(result.error()));
+                callback(DOMCacheEngine::convertToExceptionAndLog(scriptExecutionContext(), result.error()));
                 return;
             }
 
@@ -194,7 +194,7 @@
     m_connection->open(*origin(), name, [this, name, promise = WTFMove(promise), pendingActivity = makePendingActivity(*this)](const CacheIdentifierOrError& result) mutable {
         if (!m_isStopped) {
             if (!result.has_value())
-                promise.reject(DOMCacheEngine::errorToException(result.error()));
+                promise.reject(DOMCacheEngine::convertToExceptionAndLog(scriptExecutionContext(), result.error()));
             else {
                 if (result.value().hadStorageError)
                     logConsolePersistencyError(scriptExecutionContext(), name);
@@ -229,7 +229,7 @@
     m_connection->remove(m_caches[position]->identifier(), [this, name, promise = WTFMove(promise), pendingActivity = makePendingActivity(*this)](const CacheIdentifierOrError& result) mutable {
         if (!m_isStopped) {
             if (!result.has_value())
-                promise.reject(DOMCacheEngine::errorToException(result.error()));
+                promise.reject(DOMCacheEngine::convertToExceptionAndLog(scriptExecutionContext(), result.error()));
             else {
                 if (result.value().hadStorageError)
                     logConsolePersistencyError(scriptExecutionContext(), name);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to