RELEASE_ASSERT(registration) hit in SWServer::installContextData(const ServiceWorkerC...
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 22 Jan 2018 21:27:18 +0000 (21:27 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 22 Jan 2018 21:27:18 +0000 (21:27 +0000)
https://bugs.webkit.org/show_bug.cgi?id=181941
<rdar://problem/36744892>

Reviewed by Youenn Fablet.

Make sure we clear SWServer::m_pendingContextDatas & SWServer::m_pendingJobs as needed
when clearing Website data. Otherwise, we will hit assertion when those gets processed
after the connection to the SW process has been established (not to mentioned we failed
to clear some in-memory data even though the user asked us to).

* workers/service/server/SWServer.cpp:
(WebCore::SWServer::clearAll):
(WebCore::SWServer::clear):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@227353 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/workers/service/server/SWServer.cpp

index a113e38..66b591a 100644 (file)
@@ -1,3 +1,20 @@
+2018-01-22  Chris Dumez  <cdumez@apple.com>
+
+        RELEASE_ASSERT(registration) hit in SWServer::installContextData(const ServiceWorkerContextData&)
+        https://bugs.webkit.org/show_bug.cgi?id=181941
+        <rdar://problem/36744892>
+
+        Reviewed by Youenn Fablet.
+
+        Make sure we clear SWServer::m_pendingContextDatas & SWServer::m_pendingJobs as needed
+        when clearing Website data. Otherwise, we will hit assertion when those gets processed
+        after the connection to the SW process has been established (not to mentioned we failed
+        to clear some in-memory data even though the user asked us to).
+
+        * workers/service/server/SWServer.cpp:
+        (WebCore::SWServer::clearAll):
+        (WebCore::SWServer::clear):
+
 2018-01-22  Ryosuke Niwa  <rniwa@webkit.org>
 
         Blob conversion and sanitization doesn't work with Microsoft Word for Mac 2011
index 632c7ae..86ab2fb 100644 (file)
@@ -186,6 +186,8 @@ void SWServer::clearAll(WTF::CompletionHandler<void()>&& completionHandler)
     while (!m_registrations.isEmpty())
         m_registrations.begin()->value->clear();
     ASSERT(m_registrationsByID.isEmpty());
+    m_pendingContextDatas.clear();
+    m_pendingJobs.clear();
     m_originStore->clearAll();
     m_registrationStore.clearAll(WTFMove(completionHandler));
 }
@@ -202,6 +204,14 @@ void SWServer::clear(const SecurityOrigin& origin, WTF::CompletionHandler<void()
             registrationsToRemove.append(keyAndValue.value.get());
     }
 
+    m_pendingContextDatas.removeAllMatching([&](auto& contextData) {
+        return contextData.registration.key.relatesToOrigin(origin);
+    });
+
+    m_pendingJobs.removeAllMatching([&](auto& job) {
+        return job.registrationKey().relatesToOrigin(origin);
+    });
+
     // Calling SWServerRegistration::clear() takes care of updating m_registrations, m_originStore and m_registrationStore.
     for (auto* registration : registrationsToRemove)
         registration->clear();