Title: [240358] trunk
Revision
240358
Author
sihui_...@apple.com
Date
2019-01-23 13:39:19 -0800 (Wed, 23 Jan 2019)

Log Message

Clean up IndexedDB files between tests
https://bugs.webkit.org/show_bug.cgi?id=192796
<rdar://problem/46824999>

Reviewed by Geoffrey Garen.

Source/WebCore:

We should clean up the IndexedDB files between tests to make sure each IDB test is independent of others.

* Modules/indexeddb/server/UniqueIDBDatabase.cpp:
(WebCore::IDBServer::UniqueIDBDatabase::didDeleteBackingStore):
(WebCore::IDBServer::UniqueIDBDatabase::transactionCompleted):

Source/WebKit:

* UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
(WKWebsiteDataStoreRemoveAllIndexedDatabases):
* UIProcess/API/C/WKWebsiteDataStoreRef.h:

Tools:

* DumpRenderTree/mac/DumpRenderTree.mm:
(runTest):
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::resetStateToConsistentValues):
(WTR::RemoveAllIndexedDatabasesCallbackContext::RemoveAllIndexedDatabasesCallbackContext):
(WTR::RemoveAllIndexedDatabasesCallback):
(WTR::TestController::ClearIndexedDatabases):
* WebKitTestRunner/TestController.h:
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (240357 => 240358)


--- trunk/Source/WebCore/ChangeLog	2019-01-23 21:37:30 UTC (rev 240357)
+++ trunk/Source/WebCore/ChangeLog	2019-01-23 21:39:19 UTC (rev 240358)
@@ -1,3 +1,17 @@
+2019-01-23  Sihui Liu  <sihui_...@apple.com>
+
+        Clean up IndexedDB files between tests
+        https://bugs.webkit.org/show_bug.cgi?id=192796
+        <rdar://problem/46824999>
+
+        Reviewed by Geoffrey Garen.
+
+        We should clean up the IndexedDB files between tests to make sure each IDB test is independent of others.
+
+        * Modules/indexeddb/server/UniqueIDBDatabase.cpp:
+        (WebCore::IDBServer::UniqueIDBDatabase::didDeleteBackingStore):
+        (WebCore::IDBServer::UniqueIDBDatabase::transactionCompleted):
+
 2019-01-23  Oriol Brufau  <obru...@igalia.com>
 
         Add CSS Logical spec to features.json

Modified: trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp (240357 => 240358)


--- trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp	2019-01-23 21:37:30 UTC (rev 240357)
+++ trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp	2019-01-23 21:39:19 UTC (rev 240358)
@@ -337,6 +337,10 @@
     }
 
     m_deleteBackingStoreInProgress = false;
+
+    if (m_hardClosedForUserDelete)
+        return;
+
     invokeOperationAndTransactionTimer();
 }
 
@@ -634,6 +638,9 @@
     ASSERT(m_isOpeningBackingStore);
     m_isOpeningBackingStore = false;
 
+    if (m_hardClosedForUserDelete)
+        return;
+
     handleDatabaseOperations();
 }
 
@@ -1708,7 +1715,7 @@
     for (auto objectStore : transaction->objectStoreIdentifiers()) {
         if (!transaction->isReadOnly()) {
             m_objectStoreWriteTransactions.remove(objectStore);
-            ASSERT(m_objectStoreTransactionCounts.count(objectStore) == 1);
+            ASSERT(m_objectStoreTransactionCounts.count(objectStore) == 1 || m_hardClosedForUserDelete);
         }
         m_objectStoreTransactionCounts.remove(objectStore);
     }

Modified: trunk/Source/WebKit/ChangeLog (240357 => 240358)


--- trunk/Source/WebKit/ChangeLog	2019-01-23 21:37:30 UTC (rev 240357)
+++ trunk/Source/WebKit/ChangeLog	2019-01-23 21:39:19 UTC (rev 240358)
@@ -1,3 +1,15 @@
+2019-01-23  Sihui Liu  <sihui_...@apple.com>
+
+        Clean up IndexedDB files between tests
+        https://bugs.webkit.org/show_bug.cgi?id=192796
+        <rdar://problem/46824999>
+
+        Reviewed by Geoffrey Garen.
+
+        * UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
+        (WKWebsiteDataStoreRemoveAllIndexedDatabases):
+        * UIProcess/API/C/WKWebsiteDataStoreRef.h:
+
 2019-01-23  Wenson Hsieh  <wenson_hs...@apple.com>
 
         [iOS] fast/events/touch/ios/hover-when-style-change-is-async.html times out

Modified: trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp (240357 => 240358)


--- trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp	2019-01-23 21:37:30 UTC (rev 240357)
+++ trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp	2019-01-23 21:39:19 UTC (rev 240358)
@@ -448,10 +448,13 @@
     });
 }
 
-void WKWebsiteDataStoreRemoveAllIndexedDatabases(WKWebsiteDataStoreRef dataStoreRef)
+void WKWebsiteDataStoreRemoveAllIndexedDatabases(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreRemoveAllIndexedDatabasesCallback callback)
 {
     OptionSet<WebKit::WebsiteDataType> dataTypes = WebKit::WebsiteDataType::IndexedDBDatabases;
-    WebKit::toImpl(dataStoreRef)->websiteDataStore().removeData(dataTypes, -WallTime::infinity(), [] { });
+    WebKit::toImpl(dataStoreRef)->websiteDataStore().removeData(dataTypes, -WallTime::infinity(), [context, callback] {
+    if (callback)
+        callback(context);
+    });
 }
 
 void WKWebsiteDataStoreRemoveAllServiceWorkerRegistrations(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreRemoveAllServiceWorkerRegistrationsCallback callback)

Modified: trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.h (240357 => 240358)


--- trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.h	2019-01-23 21:37:30 UTC (rev 240357)
+++ trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.h	2019-01-23 21:39:19 UTC (rev 240358)
@@ -103,7 +103,8 @@
 typedef void (*WKWebsiteDataStoreRemoveAllServiceWorkerRegistrationsCallback)(void* functionContext);
 WK_EXPORT void WKWebsiteDataStoreRemoveAllServiceWorkerRegistrations(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreRemoveAllServiceWorkerRegistrationsCallback callback);
 
-WK_EXPORT void WKWebsiteDataStoreRemoveAllIndexedDatabases(WKWebsiteDataStoreRef dataStoreRef);
+typedef void (*WKWebsiteDataStoreRemoveAllIndexedDatabasesCallback)(void* functionContext);
+WK_EXPORT void WKWebsiteDataStoreRemoveAllIndexedDatabases(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreRemoveAllIndexedDatabasesCallback callback);
 
 typedef void (*WKWebsiteDataStoreGetFetchCacheOriginsFunction)(WKArrayRef, void*);
 WK_EXPORT void WKWebsiteDataStoreGetFetchCacheOrigins(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreGetFetchCacheOriginsFunction function);

Modified: trunk/Tools/ChangeLog (240357 => 240358)


--- trunk/Tools/ChangeLog	2019-01-23 21:37:30 UTC (rev 240357)
+++ trunk/Tools/ChangeLog	2019-01-23 21:39:19 UTC (rev 240358)
@@ -1,3 +1,22 @@
+2019-01-23  Sihui Liu  <sihui_...@apple.com>
+
+        Clean up IndexedDB files between tests
+        https://bugs.webkit.org/show_bug.cgi?id=192796
+        <rdar://problem/46824999>
+
+        Reviewed by Geoffrey Garen.
+
+        * DumpRenderTree/mac/DumpRenderTree.mm:
+        (runTest):
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::resetStateToConsistentValues):
+        (WTR::RemoveAllIndexedDatabasesCallbackContext::RemoveAllIndexedDatabasesCallbackContext):
+        (WTR::RemoveAllIndexedDatabasesCallback):
+        (WTR::TestController::ClearIndexedDatabases):
+        * WebKitTestRunner/TestController.h:
+        * WebKitTestRunner/TestInvocation.cpp:
+        (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
+
 2019-01-23  Aakash Jain  <aakash_j...@apple.com>
 
         [ews-app] Rename ews model Builds to Build

Modified: trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm (240357 => 240358)


--- trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm	2019-01-23 21:37:30 UTC (rev 240357)
+++ trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm	2019-01-23 21:39:19 UTC (rev 240358)
@@ -2013,6 +2013,9 @@
     gTestRunner->setIconDatabaseEnabled(false);
     gTestRunner->clearAllApplicationCaches();
 
+    gTestRunner->clearAllDatabases();
+    gTestRunner->setIDBPerOriginQuota(50 * MB);
+
     if (disallowedURLs)
         CFSetRemoveAllValues(disallowedURLs);
     if (shouldLogFrameLoadDelegates(pathOrURL.c_str()))

Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (240357 => 240358)


--- trunk/Tools/WebKitTestRunner/TestController.cpp	2019-01-23 21:37:30 UTC (rev 240357)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp	2019-01-23 21:39:19 UTC (rev 240358)
@@ -868,6 +868,9 @@
 
     WKContextClearCachedCredentials(TestController::singleton().context());
 
+    ClearIndexedDatabases();
+    setIDBPerOriginQuota(50 * MB);
+
     clearServiceWorkerRegistrations();
     clearDOMCaches();
 
@@ -2766,6 +2769,31 @@
     WKContextSetIDBPerOriginQuota(platformContext(), quota);
 }
 
+struct RemoveAllIndexedDatabasesCallbackContext {
+    explicit RemoveAllIndexedDatabasesCallbackContext(TestController& controller)
+        : testController(controller)
+    {
+    }
+
+    TestController& testController;
+    bool done { false };
+};
+
+static void RemoveAllIndexedDatabasesCallback(void* userData)
+{
+    auto* context = static_cast<RemoveAllIndexedDatabasesCallbackContext*>(userData);
+    context->done = true;
+    context->testController.notifyDone();
+}
+
+void TestController::ClearIndexedDatabases()
+{
+    auto websiteDataStore = WKContextGetWebsiteDataStore(platformContext());
+    RemoveAllIndexedDatabasesCallbackContext context(*this);
+    WKWebsiteDataStoreRemoveAllIndexedDatabases(websiteDataStore, &context, RemoveAllIndexedDatabasesCallback);
+    runUntil(context.done, noTimeout);
+}
+
 struct FetchCacheOriginsCallbackContext {
     FetchCacheOriginsCallbackContext(TestController& controller, WKStringRef origin)
         : testController(controller)

Modified: trunk/Tools/WebKitTestRunner/TestController.h (240357 => 240358)


--- trunk/Tools/WebKitTestRunner/TestController.h	2019-01-23 21:37:30 UTC (rev 240357)
+++ trunk/Tools/WebKitTestRunner/TestController.h	2019-01-23 21:39:19 UTC (rev 240358)
@@ -242,6 +242,8 @@
 
     void removeAllSessionCredentials();
 
+    void ClearIndexedDatabases();
+
     void clearServiceWorkerRegistrations();
 
     void clearDOMCache(WKStringRef origin);

Modified: trunk/Tools/WebKitTestRunner/TestInvocation.cpp (240357 => 240358)


--- trunk/Tools/WebKitTestRunner/TestInvocation.cpp	2019-01-23 21:37:30 UTC (rev 240357)
+++ trunk/Tools/WebKitTestRunner/TestInvocation.cpp	2019-01-23 21:39:19 UTC (rev 240358)
@@ -911,7 +911,7 @@
     }
     
     if (WKStringIsEqualToUTF8CString(messageName, "DeleteAllIndexedDatabases")) {
-        WKWebsiteDataStoreRemoveAllIndexedDatabases(WKContextGetWebsiteDataStore(TestController::singleton().context()));
+        WKWebsiteDataStoreRemoveAllIndexedDatabases(WKContextGetWebsiteDataStore(TestController::singleton().context()), nullptr, { });
         return nullptr;
     }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to