Changeset 240358 in webkit


Ignore:
Timestamp:
Jan 23, 2019 1:39:19 PM (5 years ago)
Author:
sihui_liu@apple.com
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):

Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r240354 r240358  
     12019-01-23  Sihui Liu  <sihui_liu@apple.com>
     2
     3        Clean up IndexedDB files between tests
     4        https://bugs.webkit.org/show_bug.cgi?id=192796
     5        <rdar://problem/46824999>
     6
     7        Reviewed by Geoffrey Garen.
     8
     9        We should clean up the IndexedDB files between tests to make sure each IDB test is independent of others.
     10
     11        * Modules/indexeddb/server/UniqueIDBDatabase.cpp:
     12        (WebCore::IDBServer::UniqueIDBDatabase::didDeleteBackingStore):
     13        (WebCore::IDBServer::UniqueIDBDatabase::transactionCompleted):
     14
    1152019-01-23  Oriol Brufau  <obrufau@igalia.com>
    216
  • trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp

    r240090 r240358  
    338338
    339339    m_deleteBackingStoreInProgress = false;
     340
     341    if (m_hardClosedForUserDelete)
     342        return;
     343
    340344    invokeOperationAndTransactionTimer();
    341345}
     
    634638    ASSERT(m_isOpeningBackingStore);
    635639    m_isOpeningBackingStore = false;
     640
     641    if (m_hardClosedForUserDelete)
     642        return;
    636643
    637644    handleDatabaseOperations();
     
    17091716        if (!transaction->isReadOnly()) {
    17101717            m_objectStoreWriteTransactions.remove(objectStore);
    1711             ASSERT(m_objectStoreTransactionCounts.count(objectStore) == 1);
     1718            ASSERT(m_objectStoreTransactionCounts.count(objectStore) == 1 || m_hardClosedForUserDelete);
    17121719        }
    17131720        m_objectStoreTransactionCounts.remove(objectStore);
  • trunk/Source/WebKit/ChangeLog

    r240352 r240358  
     12019-01-23  Sihui Liu  <sihui_liu@apple.com>
     2
     3        Clean up IndexedDB files between tests
     4        https://bugs.webkit.org/show_bug.cgi?id=192796
     5        <rdar://problem/46824999>
     6
     7        Reviewed by Geoffrey Garen.
     8
     9        * UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
     10        (WKWebsiteDataStoreRemoveAllIndexedDatabases):
     11        * UIProcess/API/C/WKWebsiteDataStoreRef.h:
     12
    1132019-01-23  Wenson Hsieh  <wenson_hsieh@apple.com>
    214
  • trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp

    r240243 r240358  
    449449}
    450450
    451 void WKWebsiteDataStoreRemoveAllIndexedDatabases(WKWebsiteDataStoreRef dataStoreRef)
     451void WKWebsiteDataStoreRemoveAllIndexedDatabases(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreRemoveAllIndexedDatabasesCallback callback)
    452452{
    453453    OptionSet<WebKit::WebsiteDataType> dataTypes = WebKit::WebsiteDataType::IndexedDBDatabases;
    454     WebKit::toImpl(dataStoreRef)->websiteDataStore().removeData(dataTypes, -WallTime::infinity(), [] { });
     454    WebKit::toImpl(dataStoreRef)->websiteDataStore().removeData(dataTypes, -WallTime::infinity(), [context, callback] {
     455    if (callback)
     456        callback(context);
     457    });
    455458}
    456459
  • trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.h

    r239380 r240358  
    104104WK_EXPORT void WKWebsiteDataStoreRemoveAllServiceWorkerRegistrations(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreRemoveAllServiceWorkerRegistrationsCallback callback);
    105105
    106 WK_EXPORT void WKWebsiteDataStoreRemoveAllIndexedDatabases(WKWebsiteDataStoreRef dataStoreRef);
     106typedef void (*WKWebsiteDataStoreRemoveAllIndexedDatabasesCallback)(void* functionContext);
     107WK_EXPORT void WKWebsiteDataStoreRemoveAllIndexedDatabases(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreRemoveAllIndexedDatabasesCallback callback);
    107108
    108109typedef void (*WKWebsiteDataStoreGetFetchCacheOriginsFunction)(WKArrayRef, void*);
  • trunk/Tools/ChangeLog

    r240357 r240358  
     12019-01-23  Sihui Liu  <sihui_liu@apple.com>
     2
     3        Clean up IndexedDB files between tests
     4        https://bugs.webkit.org/show_bug.cgi?id=192796
     5        <rdar://problem/46824999>
     6
     7        Reviewed by Geoffrey Garen.
     8
     9        * DumpRenderTree/mac/DumpRenderTree.mm:
     10        (runTest):
     11        * WebKitTestRunner/TestController.cpp:
     12        (WTR::TestController::resetStateToConsistentValues):
     13        (WTR::RemoveAllIndexedDatabasesCallbackContext::RemoveAllIndexedDatabasesCallbackContext):
     14        (WTR::RemoveAllIndexedDatabasesCallback):
     15        (WTR::TestController::ClearIndexedDatabases):
     16        * WebKitTestRunner/TestController.h:
     17        * WebKitTestRunner/TestInvocation.cpp:
     18        (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
     19
    1202019-01-23  Aakash Jain  <aakash_jain@apple.com>
    221
  • trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm

    r240251 r240358  
    20142014    gTestRunner->clearAllApplicationCaches();
    20152015
     2016    gTestRunner->clearAllDatabases();
     2017    gTestRunner->setIDBPerOriginQuota(50 * MB);
     2018
    20162019    if (disallowedURLs)
    20172020        CFSetRemoveAllValues(disallowedURLs);
  • trunk/Tools/WebKitTestRunner/TestController.cpp

    r240156 r240358  
    869869    WKContextClearCachedCredentials(TestController::singleton().context());
    870870
     871    ClearIndexedDatabases();
     872    setIDBPerOriginQuota(50 * MB);
     873
    871874    clearServiceWorkerRegistrations();
    872875    clearDOMCaches();
     
    27672770}
    27682771
     2772struct RemoveAllIndexedDatabasesCallbackContext {
     2773    explicit RemoveAllIndexedDatabasesCallbackContext(TestController& controller)
     2774        : testController(controller)
     2775    {
     2776    }
     2777
     2778    TestController& testController;
     2779    bool done { false };
     2780};
     2781
     2782static void RemoveAllIndexedDatabasesCallback(void* userData)
     2783{
     2784    auto* context = static_cast<RemoveAllIndexedDatabasesCallbackContext*>(userData);
     2785    context->done = true;
     2786    context->testController.notifyDone();
     2787}
     2788
     2789void TestController::ClearIndexedDatabases()
     2790{
     2791    auto websiteDataStore = WKContextGetWebsiteDataStore(platformContext());
     2792    RemoveAllIndexedDatabasesCallbackContext context(*this);
     2793    WKWebsiteDataStoreRemoveAllIndexedDatabases(websiteDataStore, &context, RemoveAllIndexedDatabasesCallback);
     2794    runUntil(context.done, noTimeout);
     2795}
     2796
    27692797struct FetchCacheOriginsCallbackContext {
    27702798    FetchCacheOriginsCallbackContext(TestController& controller, WKStringRef origin)
  • trunk/Tools/WebKitTestRunner/TestController.h

    r240156 r240358  
    243243    void removeAllSessionCredentials();
    244244
     245    void ClearIndexedDatabases();
     246
    245247    void clearServiceWorkerRegistrations();
    246248
  • trunk/Tools/WebKitTestRunner/TestInvocation.cpp

    r240156 r240358  
    912912   
    913913    if (WKStringIsEqualToUTF8CString(messageName, "DeleteAllIndexedDatabases")) {
    914         WKWebsiteDataStoreRemoveAllIndexedDatabases(WKContextGetWebsiteDataStore(TestController::singleton().context()));
     914        WKWebsiteDataStoreRemoveAllIndexedDatabases(WKContextGetWebsiteDataStore(TestController::singleton().context()), nullptr, { });
    915915        return nullptr;
    916916    }
Note: See TracChangeset for help on using the changeset viewer.