Changeset 252064 in webkit
- Timestamp:
- Nov 5, 2019 11:15:18 AM (4 years ago)
- Location:
- trunk
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r252062 r252064 1 2019-11-05 Chris Dumez <cdumez@apple.com> 2 3 DatabaseContext should not prevent entering the back/forward cache 4 https://bugs.webkit.org/show_bug.cgi?id=203103 5 <rdar://problem/56592193> 6 7 Reviewed by Geoffrey Garen. 8 9 * fast/history/page-cache-webdatabase-pending-transaction-expected.txt: 10 * fast/history/page-cache-webdatabase-pending-transaction.html: 11 Update existing test to reflect behavior change. 12 13 * platform/gtk/TestExpectations: 14 * platform/mac/TestExpectations: 15 Unmark test as flaky. 16 1 17 2019-11-05 Wenson Hsieh <wenson_hsieh@apple.com> 2 18 -
trunk/LayoutTests/fast/history/page-cache-webdatabase-pending-transaction-expected.txt
r251592 r252064 1 Tests that a page with an open WebDatabase that has pending transactions does not go into the page cache. 1 CONSOLE MESSAGE: line 54: Web SQL is deprecated. Please use IndexedDB instead. 2 Tests that a page with an open WebDatabase that has pending transactions is able to go into the back/forward cache. 2 3 3 4 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". … … 5 6 6 7 pageshow - not from cache 7 PASS Page was not restored from page cache 8 pagehide - entering cache 9 pageshow - from cache 10 PASS Page did enter and was restored from the back/forward cache 11 PASS All done 8 12 PASS successfullyParsed is true 9 13 -
trunk/LayoutTests/fast/history/page-cache-webdatabase-pending-transaction.html
r251592 r252064 3 3 <html> 4 4 <body> 5 <script src="../../resources/js-test -pre.js"></script>5 <script src="../../resources/js-test.js"></script> 6 6 <script> 7 description('Tests that a page with an open WebDatabase that has pending transactions does not go into the page cache.'); 8 window.jsTestIsAsync = true; 7 description('Tests that a page with an open WebDatabase that has pending transactions is able to go into the back/forward cache.'); 8 jsTestIsAsync = true; 9 let restoredFromCache = false; 10 let pendingTransactionCount = 0; 9 11 10 12 if (window.testRunner) 11 13 testRunner.clearAllDatabases(); 12 14 15 function checkTestComplete() 16 { 17 if (!pendingTransactionCount && restoredFromCache) { 18 testPassed("All done"); 19 finishJSTest(); 20 } 21 } 22 13 23 window.addEventListener("pageshow", function(event) { 14 24 debug("pageshow - " + (event.persisted ? "" : "not ") + "from cache"); 15 if (!window.sessionStorage.page_cache_open_webdatabase_test_started)16 return;17 25 18 delete window.sessionStorage.page_cache_open_webdatabase_test_started; 19 20 if (event.persisted) 21 testFailed("Page did enter and was restored from the page cache"); 22 else 23 testPassed("Page was not restored from page cache"); 24 finishJSTest(); 26 if (event.persisted) { 27 testPassed("Page did enter and was restored from the back/forward cache"); 28 restoredFromCache = true; 29 checkTestComplete(); 30 } 25 31 }, false); 26 32 27 33 window.addEventListener("pagehide", function(event) { 28 34 debug("pagehide - " + (event.persisted ? "" : "not ") + "entering cache"); 29 if ( event.persisted) {30 testFailed("Page entered the pagecache.");35 if (!event.persisted) { 36 testFailed("Page failed to enter the back/forward cache."); 31 37 finishJSTest(); 32 38 } 33 39 }, false); 34 40 41 function handleTransactionComplete() 42 { 43 if (!pendingTransactionCount) { 44 testFailed("Too many completion handlers"); 45 finishJSTest(); 46 } 47 48 pendingTransactionCount--; 49 checkTestComplete(); 50 } 51 35 52 window.addEventListener('load', function() { 36 // Open the database.37 db = openDatabase("PageCacheTest", "", "PageCache Test", 32768);53 setTimeout(() => { 54 db = openDatabase("PageCacheTest", "", "Back Forward Cache Test", 32768); 38 55 39 db.transaction(function(tx) { 40 // Force a back navigation back to this page. 41 window.sessionStorage.page_cache_open_webdatabase_test_started = true; 42 window.location.href = "resources/page-cache-helper.html"; 56 pendingTransactionCount++; 57 db.transaction(function(tx) { 58 window.location.href = "resources/page-cache-helper.html"; 43 59 44 tx.executeSql('CREATE TABLE IF NOT EXISTS LOGS (id unique, log)');45 });60 tx.executeSql('CREATE TABLE IF NOT EXISTS LOGS (id unique, log)'); 61 }, handleTransactionComplete, handleTransactionComplete); 46 62 47 db.transaction(function(tx) { 48 tx.executeSql('CREATE TABLE IF NOT EXISTS LOGS2 (id unique, log)'); 49 }); 63 pendingTransactionCount++; 64 db.transaction(function(tx) { 65 tx.executeSql('CREATE TABLE IF NOT EXISTS LOGS2 (id unique, log)'); 66 }, handleTransactionComplete, handleTransactionComplete); 50 67 51 db.transaction(function(tx) { 52 tx.executeSql('CREATE TABLE IF NOT EXISTS LOGS3 (id unique, log)'); 53 }); 68 pendingTransactionCount++; 69 db.transaction(function(tx) { 70 tx.executeSql('CREATE TABLE IF NOT EXISTS LOGS3 (id unique, log)'); 71 }, handleTransactionComplete, handleTransactionComplete); 72 }, 0); 54 73 }, false); 55 56 74 </script> 57 <script src="../../resources/js-test-post.js"></script>58 75 </body> 59 76 </html> -
trunk/LayoutTests/platform/gtk/TestExpectations
r252027 r252064 1660 1660 1661 1661 webkit.org/b/145051 media/video-rtl.html [ ImageOnlyFailure Pass ] 1662 webkit.org/b/145052 fast/history/page-cache-webdatabase-pending-transaction.html [ Failure Pass ]1663 1662 1664 1663 webkit.org/b/145167 transforms/2d/perspective-not-fixed-container.html [ ImageOnlyFailure Pass ] -
trunk/LayoutTests/platform/mac/TestExpectations
r251950 r252064 1199 1199 [ Sierra+ ] editing/selection/triple-click-in-pre.html [ Failure ] 1200 1200 1201 webkit.org/b/159379 fast/history/page-cache-webdatabase-pending-transaction.html [ Pass Failure ]1202 1203 1201 # rdar://problem/31243824 1204 1202 webkit.org/b/158747 media/restore-from-page-cache.html [ Pass Failure Crash ] -
trunk/Source/WebCore/ChangeLog
r252060 r252064 1 2019-11-05 Chris Dumez <cdumez@apple.com> 2 3 DatabaseContext should not prevent entering the back/forward cache 4 https://bugs.webkit.org/show_bug.cgi?id=203103 5 <rdar://problem/56592193> 6 7 Reviewed by Geoffrey Garen. 8 9 Let pages with active webdatabase transactions into the back/forward cache. We make sure 10 to queue tasks that run script to the Window event loop, so that they get delayed when 11 the document is suspended. 12 13 This patch also makes sure that the transaction's error callback gets called if the database 14 gets closed while the transaction is going on. We previously did not happen and it was causing 15 issues because databases get closed on navigation. 16 17 No new tests, updated existing test. 18 19 * Modules/webdatabase/Database.cpp: 20 (WebCore::Database::runTransaction): 21 * Modules/webdatabase/DatabaseContext.cpp: 22 (WebCore::DatabaseContext::shouldPreventEnteringBackForwardCache_DEPRECATED const): Deleted. 23 * Modules/webdatabase/DatabaseContext.h: 24 * Modules/webdatabase/DatabaseManager.cpp: 25 (WebCore::DatabaseManager::openDatabase): 26 * Modules/webdatabase/SQLTransaction.cpp: 27 (WebCore::SQLTransaction::performPendingCallback): 28 (WebCore::SQLTransaction::notifyDatabaseThreadIsShuttingDown): 29 (WebCore::SQLTransaction::callErrorCallbackDueToInterruption): 30 (WebCore::SQLTransaction::checkAndHandleClosedDatabase): 31 (WebCore::SQLTransaction::deliverTransactionErrorCallback): 32 (WebCore::SQLTransaction::deliverSuccessCallback): 33 (WebCore::SQLTransaction::computeNextStateAndCleanupIfNeeded): 34 * Modules/webdatabase/SQLTransaction.h: 35 1 36 2019-11-05 Sihui Liu <sihui_liu@apple.com> 2 37 -
trunk/Source/WebCore/Modules/webdatabase/Database.cpp
r251592 r252064 53 53 #include "SecurityOrigin.h" 54 54 #include "VoidCallback.h" 55 #include "WindowEventLoop.h" 55 56 #include <wtf/NeverDestroyed.h> 56 57 #include <wtf/RefPtr.h> … … 685 686 void Database::runTransaction(RefPtr<SQLTransactionCallback>&& callback, RefPtr<SQLTransactionErrorCallback>&& errorCallback, RefPtr<VoidCallback>&& successCallback, RefPtr<SQLTransactionWrapper>&& wrapper, bool readOnly) 686 687 { 688 ASSERT(isMainThread()); 687 689 LockHolder locker(m_transactionInProgressMutex); 688 690 if (!m_isTransactionQueueEnabled) { 689 691 if (errorCallback) { 690 callOnMainThread([errorCallback = makeRef(*errorCallback)]() {692 m_document->eventLoop().queueTask(TaskSource::Networking, m_document, [errorCallback = makeRef(*errorCallback)]() { 691 693 errorCallback->handleEvent(SQLError::create(SQLError::UNKNOWN_ERR, "database has been closed")); 692 694 }); -
trunk/Source/WebCore/Modules/webdatabase/DatabaseContext.cpp
r251592 r252064 131 131 } 132 132 133 // FIXME: This should never prevent entering the back/forward cache.134 bool DatabaseContext::shouldPreventEnteringBackForwardCache_DEPRECATED() const135 {136 if (!hasOpenDatabases() || !m_databaseThread)137 return false;138 139 return m_databaseThread->hasPendingDatabaseActivity();140 }141 142 133 DatabaseThread* DatabaseContext::databaseThread() 143 134 { -
trunk/Source/WebCore/Modules/webdatabase/DatabaseContext.h
r251592 r252064 74 74 void contextDestroyed() override; 75 75 void stop() override; 76 bool shouldPreventEnteringBackForwardCache_DEPRECATED() const override;77 76 const char* activeDOMObjectName() const override { return "DatabaseContext"; } 78 77 -
trunk/Source/WebCore/Modules/webdatabase/DatabaseManager.cpp
r251592 r252064 39 39 #include "SecurityOrigin.h" 40 40 #include "SecurityOriginData.h" 41 #include "WindowEventLoop.h" 41 42 #include <wtf/NeverDestroyed.h> 42 43 … … 193 194 ExceptionOr<Ref<Database>> DatabaseManager::openDatabase(Document& document, const String& name, const String& expectedVersion, const String& displayName, unsigned estimatedSize, RefPtr<DatabaseCallback>&& creationCallback) 194 195 { 196 ASSERT(isMainThread()); 195 197 ScriptController::initializeThreading(); 196 198 … … 209 211 LOG(StorageAPI, "Scheduling DatabaseCreationCallbackTask for database %p\n", database.get()); 210 212 database->setHasPendingCreationEvent(true); 211 database->m_document-> postTask([creationCallback, database] (ScriptExecutionContext&) {213 database->m_document->eventLoop().queueTask(TaskSource::Networking, database->m_document, [creationCallback, database]() { 212 214 creationCallback->handleEvent(*database); 213 215 database->setHasPendingCreationEvent(false); -
trunk/Source/WebCore/Modules/webdatabase/SQLTransaction.cpp
r251592 r252064 48 48 #include "SQLiteTransaction.h" 49 49 #include "VoidCallback.h" 50 #include "WindowEventLoop.h" 50 51 #include <wtf/Optional.h> 51 52 #include <wtf/StdLibExtras.h> … … 110 111 void SQLTransaction::performPendingCallback() 111 112 { 113 ASSERT(isMainThread()); 112 114 LOG(StorageAPI, "Callback %s\n", debugStepName(m_nextStep)); 113 115 … … 126 128 void SQLTransaction::notifyDatabaseThreadIsShuttingDown() 127 129 { 130 callOnMainThread([this, protectedThis = makeRef(*this)]() mutable { 131 callErrorCallbackDueToInterruption(); 132 }); 133 128 134 m_backend.notifyDatabaseThreadIsShuttingDown(); 135 } 136 137 void SQLTransaction::callErrorCallbackDueToInterruption() 138 { 139 ASSERT(isMainThread()); 140 auto errorCallback = m_errorCallbackWrapper.unwrap(); 141 if (!errorCallback) 142 return; 143 144 m_database->document().eventLoop().queueTask(TaskSource::Networking, m_database->document(), [errorCallback = WTFMove(errorCallback)]() mutable { 145 errorCallback->handleEvent(SQLError::create(SQLError::DATABASE_ERR, "the database was closed")); 146 }); 129 147 } 130 148 … … 181 199 m_nextStep = nullptr; 182 200 201 callErrorCallbackDueToInterruption(); 202 183 203 // Release the unneeded callbacks, to break reference cycles. 184 204 m_callbackWrapper.clear(); … … 395 415 // error to have occurred in this transaction. 396 416 RefPtr<SQLTransactionErrorCallback> errorCallback = m_errorCallbackWrapper.unwrap(); 397 if (errorCallback) 398 errorCallback->handleEvent(*m_transactionError); 417 if (errorCallback) { 418 m_database->document().eventLoop().queueTask(TaskSource::Networking, m_database->document(), [errorCallback = WTFMove(errorCallback), transactionError = m_transactionError]() mutable { 419 errorCallback->handleEvent(*transactionError); 420 }); 421 } 399 422 400 423 clearCallbackWrappers(); … … 443 466 // Spec 4.3.2.8: Deliver success callback. 444 467 RefPtr<VoidCallback> successCallback = m_successCallbackWrapper.unwrap(); 445 if (successCallback) 446 successCallback->handleEvent(); 468 if (successCallback) { 469 m_database->document().eventLoop().queueTask(TaskSource::Networking, m_database->document(), [successCallback = WTFMove(successCallback)]() mutable { 470 successCallback->handleEvent(); 471 }); 472 } 447 473 448 474 clearCallbackWrappers(); … … 476 502 LOG(StorageAPI, "Callback %s\n", nameForSQLTransactionState(m_nextState)); 477 503 return; 478 } 504 } else 505 callErrorCallbackDueToInterruption(); 479 506 480 507 clearCallbackWrappers(); -
trunk/Source/WebCore/Modules/webdatabase/SQLTransaction.h
r242776 r252064 106 106 NO_RETURN_DUE_TO_ASSERT void unreachableState(); 107 107 108 void callErrorCallbackDueToInterruption(); 109 108 110 void getNextStatement(); 109 111 bool runCurrentStatement();
Note: See TracChangeset
for help on using the changeset viewer.