Changeset 250965 in webkit
- Timestamp:
- Oct 10, 2019 7:24:07 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r250963 r250965 1 2019-10-10 Chris Dumez <cdumez@apple.com> 2 3 DOMCacheStorage should not prevent pages from entering the back/forward cache 4 https://bugs.webkit.org/show_bug.cgi?id=202608 5 6 Reviewed by Youenn Fablet. 7 8 Add layout test coverage. 9 10 * http/tests/navigation/page-cache-domcachestorage-pending-promise-expected.txt: Added. 11 * http/tests/navigation/page-cache-domcachestorage-pending-promise.html: Added. 12 1 13 2019-10-10 Miguel Gomez <magomez@igalia.com> 2 14 -
trunk/LayoutTests/platform/ios-wk1/TestExpectations
r250944 r250965 13 13 http/tests/cache-storage [ Skip ] 14 14 http/tests/navigation/page-cache-domcache-pending-promise.html [ Skip ] 15 http/tests/navigation/page-cache-domcachestorage-pending-promise.html [ Skip ] 15 16 imported/w3c/web-platform-tests/fetch/api/request/destination [ Skip ] 16 17 imported/w3c/web-platform-tests/fetch/cross-origin-resource-policy [ Skip ] -
trunk/LayoutTests/platform/mac-wk1/TestExpectations
r250944 r250965 273 273 http/tests/cache-storage [ Skip ] 274 274 http/tests/navigation/page-cache-domcache-pending-promise.html [ Skip ] 275 http/tests/navigation/page-cache-domcachestorage-pending-promise.html [ Skip ] 275 276 http/tests/cookies/same-site/fetch-in-cross-origin-service-worker.html [ Skip ] 276 277 http/tests/cookies/same-site/fetch-in-same-origin-service-worker.html [ Skip ] -
trunk/LayoutTests/platform/win/TestExpectations
r250936 r250965 3801 3801 http/tests/cache-storage [ Skip ] 3802 3802 http/tests/navigation/page-cache-domcache-pending-promise.html [ Skip ] 3803 http/tests/navigation/page-cache-domcachestorage-pending-promise.html [ Skip ] 3803 3804 http/tests/inspector/network/resource-response-service-worker.html [ Skip ] 3804 3805 http/tests/workers/service [ Skip ] -
trunk/Source/WebCore/ChangeLog
r250958 r250965 1 2019-10-10 Chris Dumez <cdumez@apple.com> 2 3 DOMCacheStorage should not prevent pages from entering the back/forward cache 4 https://bugs.webkit.org/show_bug.cgi?id=202608 5 6 Reviewed by Youenn Fablet. 7 8 Make DOMCacheStorage fully suspendable by queueing all its asynchronous promise resolutions 9 to a SuspendableTaskQueue. This makes sure that no promises are resolved while suspended 10 in the page cache. 11 12 Test: http/tests/navigation/page-cache-domcachestorage-pending-promise.html 13 14 * Modules/cache/DOMCacheStorage.cpp: 15 (WebCore::DOMCacheStorage::DOMCacheStorage): 16 (WebCore::DOMCacheStorage::doSequentialMatch): 17 (WebCore::DOMCacheStorage::match): 18 (WebCore::DOMCacheStorage::has): 19 (WebCore::DOMCacheStorage::open): 20 (WebCore::DOMCacheStorage::doOpen): 21 (WebCore::DOMCacheStorage::remove): 22 (WebCore::DOMCacheStorage::doRemove): 23 (WebCore::DOMCacheStorage::keys): 24 (WebCore::DOMCacheStorage::canSuspendForDocumentSuspension const): 25 * Modules/cache/DOMCacheStorage.h: 26 1 27 2019-10-10 youenn fablet <youenn@apple.com> 2 28 -
trunk/Source/WebCore/Modules/cache/DOMCacheStorage.cpp
r250786 r250965 32 32 #include "JSFetchResponse.h" 33 33 #include "ScriptExecutionContext.h" 34 34 #include "SuspendableTaskQueue.h" 35 35 36 36 namespace WebCore { … … 40 40 : ActiveDOMObject(&context) 41 41 , m_connection(WTFMove(connection)) 42 , m_taskQueue(SuspendableTaskQueue::create(&context)) 42 43 { 43 44 suspendIfNeeded(); 44 45 } 46 47 DOMCacheStorage::~DOMCacheStorage() = default; 45 48 46 49 Optional<ClientOrigin> DOMCacheStorage::origin() const … … 87 90 { 88 91 startSequentialMatch(WTF::map(m_caches, copyCache), WTFMove(info), WTFMove(options), [this, pendingActivity = makePendingActivity(*this), promise = WTFMove(promise)](auto&& result) mutable { 89 if (m_isStopped)90 return;91 if (result.hasException()) {92 promise->reject(result.releaseException());93 return;94 }95 if (!result.returnValue()) {96 promise->resolve();97 return;98 }99 promise->resolve<IDLInterface<FetchResponse>>(*result.returnValue());92 m_taskQueue->enqueueTask([promise = WTFMove(promise), result = WTFMove(result)]() mutable { 93 if (result.hasException()) { 94 promise->reject(result.releaseException()); 95 return; 96 } 97 if (!result.returnValue()) { 98 promise->resolve(); 99 return; 100 } 101 promise->resolve<IDLInterface<FetchResponse>>(*result.returnValue()); 102 }); 100 103 }); 101 104 } … … 105 108 retrieveCaches([this, info = WTFMove(info), options = WTFMove(options), promise = WTFMove(promise)](Optional<Exception>&& exception) mutable { 106 109 if (exception) { 107 promise->reject(WTFMove(exception.value())); 110 m_taskQueue->enqueueTask([promise = WTFMove(promise), exception = WTFMove(exception.value())]() mutable { 111 promise->reject(WTFMove(exception)); 112 }); 108 113 return; 109 114 } … … 115 120 return; 116 121 } 117 promise->resolve(); 122 m_taskQueue->enqueueTask([promise = WTFMove(promise)]() mutable { 123 promise->resolve(); 124 }); 118 125 return; 119 126 } … … 126 133 { 127 134 retrieveCaches([this, name, promise = WTFMove(promise)](Optional<Exception>&& exception) mutable { 128 if (exception) { 129 promise.reject(WTFMove(exception.value())); 130 return; 131 } 132 promise.resolve(m_caches.findMatching([&](auto& item) { return item->name() == name; }) != notFound); 135 m_taskQueue->enqueueTask([this, name, promise = WTFMove(promise), exception = WTFMove(exception)]() mutable { 136 if (exception) { 137 promise.reject(WTFMove(exception.value())); 138 return; 139 } 140 promise.resolve(m_caches.findMatching([&](auto& item) { return item->name() == name; }) != notFound); 141 }); 133 142 }); 134 143 } … … 181 190 retrieveCaches([this, name, promise = WTFMove(promise)](Optional<Exception>&& exception) mutable { 182 191 if (exception) { 183 promise.reject(WTFMove(exception.value())); 192 m_taskQueue->enqueueTask([promise = WTFMove(promise), exception = WTFMove(exception.value())]() mutable { 193 promise.reject(WTFMove(exception)); 194 }); 184 195 return; 185 196 } … … 192 203 auto position = m_caches.findMatching([&](auto& item) { return item->name() == name; }); 193 204 if (position != notFound) { 194 auto& cache = m_caches[position]; 195 promise.resolve(DOMCache::create(*scriptExecutionContext(), String { cache->name() }, cache->identifier(), m_connection.copyRef())); 205 m_taskQueue->enqueueTask([this, promise = WTFMove(promise), cache = m_caches[position].copyRef()]() mutable { 206 promise.resolve(DOMCache::create(*scriptExecutionContext(), String { cache->name() }, cache->identifier(), m_connection.copyRef())); 207 }); 196 208 return; 197 209 } 198 210 199 211 m_connection->open(*origin(), name, [this, name, promise = WTFMove(promise), pendingActivity = makePendingActivity(*this)](const CacheIdentifierOrError& result) mutable { 200 if (!m_isStopped) { 201 if (!result.has_value()) 202 promise.reject(DOMCacheEngine::convertToExceptionAndLog(scriptExecutionContext(), result.error())); 203 else { 204 if (result.value().hadStorageError) 205 logConsolePersistencyError(scriptExecutionContext(), name); 206 207 auto cache = DOMCache::create(*scriptExecutionContext(), String { name }, result.value().identifier, m_connection.copyRef()); 212 if (!result.has_value()) { 213 m_taskQueue->enqueueTask([this, promise = WTFMove(promise), error = result.error()]() mutable { 214 promise.reject(DOMCacheEngine::convertToExceptionAndLog(scriptExecutionContext(), error)); 215 }); 216 } else { 217 if (result.value().hadStorageError) 218 logConsolePersistencyError(scriptExecutionContext(), name); 219 220 m_taskQueue->enqueueTask([this, name, promise = WTFMove(promise), identifier = result.value().identifier]() mutable { 221 auto cache = DOMCache::create(*scriptExecutionContext(), String { name }, identifier, m_connection.copyRef()); 208 222 promise.resolve(cache); 209 223 m_caches.append(WTFMove(cache)); 210 } 224 }); 211 225 } 212 226 }); … … 217 231 retrieveCaches([this, name, promise = WTFMove(promise)](Optional<Exception>&& exception) mutable { 218 232 if (exception) { 219 promise.reject(WTFMove(exception.value())); 233 m_taskQueue->enqueueTask([promise = WTFMove(promise), exception = WTFMove(exception.value())]() mutable { 234 promise.reject(WTFMove(exception)); 235 }); 220 236 return; 221 237 } … … 228 244 auto position = m_caches.findMatching([&](auto& item) { return item->name() == name; }); 229 245 if (position == notFound) { 230 promise.resolve(false); 246 m_taskQueue->enqueueTask([promise = WTFMove(promise)]() mutable { 247 promise.resolve(false); 248 }); 231 249 return; 232 250 } 233 251 234 252 m_connection->remove(m_caches[position]->identifier(), [this, name, promise = WTFMove(promise), pendingActivity = makePendingActivity(*this)](const CacheIdentifierOrError& result) mutable { 235 if (!m_isStopped){253 m_taskQueue->enqueueTask([this, name, promise = WTFMove(promise), result]() mutable { 236 254 if (!result.has_value()) 237 255 promise.reject(DOMCacheEngine::convertToExceptionAndLog(scriptExecutionContext(), result.error())); … … 241 259 promise.resolve(!!result.value().identifier); 242 260 } 243 } 261 }); 244 262 }); 245 263 } … … 248 266 { 249 267 retrieveCaches([this, promise = WTFMove(promise)](Optional<Exception>&& exception) mutable { 250 if (exception) { 251 promise.reject(WTFMove(exception.value())); 252 return; 253 } 254 255 promise.resolve(WTF::map(m_caches, [] (const auto& cache) { 256 return cache->name(); 257 })); 268 m_taskQueue->enqueueTask([this, promise = WTFMove(promise), exception = WTFMove(exception)]() mutable { 269 if (exception) { 270 promise.reject(WTFMove(exception.value())); 271 return; 272 } 273 274 promise.resolve(WTF::map(m_caches, [] (const auto& cache) { 275 return cache->name(); 276 })); 277 }); 258 278 }); 259 279 } … … 271 291 bool DOMCacheStorage::canSuspendForDocumentSuspension() const 272 292 { 273 return !hasPendingActivity();293 return true; 274 294 } 275 295 -
trunk/Source/WebCore/Modules/cache/DOMCacheStorage.h
r243818 r250965 33 33 namespace WebCore { 34 34 35 class SuspendableTaskQueue; 36 35 37 class DOMCacheStorage : public RefCounted<DOMCacheStorage>, public ActiveDOMObject { 36 38 public: 37 39 static Ref<DOMCacheStorage> create(ScriptExecutionContext& context, Ref<CacheStorageConnection>&& connection) { return adoptRef(*new DOMCacheStorage(context, WTFMove(connection))); } 40 ~DOMCacheStorage(); 38 41 39 42 using KeysPromise = DOMPromiseDeferred<IDLSequence<IDLDOMString>>; … … 63 66 uint64_t m_updateCounter { 0 }; 64 67 Ref<CacheStorageConnection> m_connection; 68 UniqueRef<SuspendableTaskQueue> m_taskQueue; 65 69 bool m_isStopped { false }; 66 70 };
Note: See TracChangeset
for help on using the changeset viewer.