Diff
Modified: trunk/LayoutTests/ChangeLog (251585 => 251586)
--- trunk/LayoutTests/ChangeLog 2019-10-25 08:14:07 UTC (rev 251585)
+++ trunk/LayoutTests/ChangeLog 2019-10-25 08:14:19 UTC (rev 251586)
@@ -1,3 +1,18 @@
+2019-10-25 Chris Dumez <cdu...@apple.com>
+
+ DatabaseContext should not prevent entering the back/forward cache
+ https://bugs.webkit.org/show_bug.cgi?id=203103
+
+ Reviewed by Geoffrey Garen.
+
+ * fast/history/page-cache-webdatabase-pending-transaction-expected.txt:
+ * fast/history/page-cache-webdatabase-pending-transaction.html:
+ Update existing test to reflect behavior change.
+
+ * platform/gtk/TestExpectations:
+ * platform/mac/TestExpectations:
+ Unmark test as flaky.
+
2019-10-24 Alex Christensen <achristen...@webkit.org>
Add more information to SRI failure console messages
Modified: trunk/LayoutTests/fast/history/page-cache-webdatabase-pending-transaction-expected.txt (251585 => 251586)
--- trunk/LayoutTests/fast/history/page-cache-webdatabase-pending-transaction-expected.txt 2019-10-25 08:14:07 UTC (rev 251585)
+++ trunk/LayoutTests/fast/history/page-cache-webdatabase-pending-transaction-expected.txt 2019-10-25 08:14:19 UTC (rev 251586)
@@ -1,10 +1,14 @@
-Tests that a page with an open WebDatabase that has pending transactions does not go into the page cache.
+CONSOLE MESSAGE: line 55: Web SQL is deprecated. Please use IndexedDB instead.
+Tests that a page with an open WebDatabase that has pending transactions is able to go into the back/forward cache.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
pageshow - not from cache
-PASS Page was not restored from page cache
+pagehide - entering cache
+pageshow - from cache
+PASS Page did enter and was restored from the back/forward cache
+PASS All transactions succeeded
PASS successfullyParsed is true
TEST COMPLETE
Modified: trunk/LayoutTests/fast/history/page-cache-webdatabase-pending-transaction.html (251585 => 251586)
--- trunk/LayoutTests/fast/history/page-cache-webdatabase-pending-transaction.html 2019-10-25 08:14:07 UTC (rev 251585)
+++ trunk/LayoutTests/fast/history/page-cache-webdatabase-pending-transaction.html 2019-10-25 08:14:19 UTC (rev 251586)
@@ -2,58 +2,76 @@
<!DOCTYPE html>
<html>
<body>
-<script src=""
+<script src=""
<script>
-description('Tests that a page with an open WebDatabase that has pending transactions does not go into the page cache.');
-window.jsTestIsAsync = true;
+description('Tests that a page with an open WebDatabase that has pending transactions is able to go into the back/forward cache.');
+jsTestIsAsync = true;
+let restoredFromCache = false;
+let pendingTransactionCount = 0;
if (window.testRunner)
testRunner.clearAllDatabases();
+function checkTestComplete()
+{
+ if (!pendingTransactionCount && restoredFromCache) {
+ testPassed("All transactions succeeded");
+ finishJSTest();
+ }
+}
+
window.addEventListener("pageshow", function(event) {
debug("pageshow - " + (event.persisted ? "" : "not ") + "from cache");
- if (!window.sessionStorage.page_cache_open_webdatabase_test_started)
- return;
- delete window.sessionStorage.page_cache_open_webdatabase_test_started;
-
- if (event.persisted)
- testFailed("Page did enter and was restored from the page cache");
- else
- testPassed("Page was not restored from page cache");
- finishJSTest();
+ if (event.persisted) {
+ testPassed("Page did enter and was restored from the back/forward cache");
+ restoredFromCache = true;
+ checkTestComplete();
+ }
}, false);
window.addEventListener("pagehide", function(event) {
debug("pagehide - " + (event.persisted ? "" : "not ") + "entering cache");
- if (event.persisted) {
- testFailed("Page entered the page cache.");
+ if (!event.persisted) {
+ testFailed("Page failed to enter the back/forward cache.");
finishJSTest();
}
}, false);
+function handleTransactionSuccess()
+{
+ pendingTransactionCount--;
+ checkTestComplete();
+}
+
+function handleTransactionError()
+{
+ testFailed("Transaction failed");
+ finishJSTest();
+}
+
window.addEventListener('load', function() {
- // Open the database.
- db = openDatabase("PageCacheTest", "", "Page Cache Test", 32768);
+ setTimeout(() => {
+ db = openDatabase("PageCacheTest", "", "Back Forward Cache Test", 32768);
- db.transaction(function(tx) {
- // Force a back navigation back to this page.
- window.sessionStorage.page_cache_open_webdatabase_test_started = true;
- window.location.href = ""
+ db.transaction(function(tx) {
+ window.location.href = ""
- tx.executeSql('CREATE TABLE IF NOT EXISTS LOGS (id unique, log)');
- });
+ pendingTransactionCount++;
+ tx.executeSql('CREATE TABLE IF NOT EXISTS LOGS (id unique, log)', [], handleTransactionSuccess, handleTransactionError);
+ });
- db.transaction(function(tx) {
- tx.executeSql('CREATE TABLE IF NOT EXISTS LOGS2 (id unique, log)');
- });
+ db.transaction(function(tx) {
+ pendingTransactionCount++;
+ tx.executeSql('CREATE TABLE IF NOT EXISTS LOGS2 (id unique, log)', [], handleTransactionSuccess, handleTransactionError);
+ });
- db.transaction(function(tx) {
- tx.executeSql('CREATE TABLE IF NOT EXISTS LOGS3 (id unique, log)');
- });
+ db.transaction(function(tx) {
+ pendingTransactionCount++;
+ tx.executeSql('CREATE TABLE IF NOT EXISTS LOGS3 (id unique, log)', [], handleTransactionSuccess, handleTransactionError);
+ });
+ }, 0);
}, false);
-
</script>
-<script src=""
</body>
</html>
Modified: trunk/LayoutTests/platform/gtk/TestExpectations (251585 => 251586)
--- trunk/LayoutTests/platform/gtk/TestExpectations 2019-10-25 08:14:07 UTC (rev 251585)
+++ trunk/LayoutTests/platform/gtk/TestExpectations 2019-10-25 08:14:19 UTC (rev 251586)
@@ -1660,7 +1660,6 @@
webkit.org/b/144864 fast/events/clear-drag-state.html [ Failure Pass ]
webkit.org/b/145051 media/video-rtl.html [ ImageOnlyFailure Pass ]
-webkit.org/b/145052 fast/history/page-cache-webdatabase-pending-transaction.html [ Failure Pass ]
webkit.org/b/145167 transforms/2d/perspective-not-fixed-container.html [ ImageOnlyFailure Pass ]
Modified: trunk/LayoutTests/platform/mac/TestExpectations (251585 => 251586)
--- trunk/LayoutTests/platform/mac/TestExpectations 2019-10-25 08:14:07 UTC (rev 251585)
+++ trunk/LayoutTests/platform/mac/TestExpectations 2019-10-25 08:14:19 UTC (rev 251586)
@@ -1198,8 +1198,6 @@
# rdar://problem/27141291
[ Sierra+ ] editing/selection/triple-click-in-pre.html [ Failure ]
-webkit.org/b/159379 fast/history/page-cache-webdatabase-pending-transaction.html [ Pass Failure ]
-
# rdar://problem/31243824
webkit.org/b/158747 media/restore-from-page-cache.html [ Pass Failure Crash ]
Modified: trunk/Source/WebCore/ChangeLog (251585 => 251586)
--- trunk/Source/WebCore/ChangeLog 2019-10-25 08:14:07 UTC (rev 251585)
+++ trunk/Source/WebCore/ChangeLog 2019-10-25 08:14:19 UTC (rev 251586)
@@ -1,3 +1,26 @@
+2019-10-25 Chris Dumez <cdu...@apple.com>
+
+ DatabaseContext should not prevent entering the back/forward cache
+ https://bugs.webkit.org/show_bug.cgi?id=203103
+
+ Reviewed by Geoffrey Garen.
+
+ Let pages with active webdatabase transactions into the back/forward cache. We make sure
+ to queue tasks that run script to the Window event loop, so that they get delayed when
+ the document is suspended.
+
+ No new tests, updated existing test.
+
+ * Modules/webdatabase/Database.cpp:
+ (WebCore::Database::runTransaction):
+ * Modules/webdatabase/DatabaseContext.cpp:
+ (WebCore::DatabaseContext::shouldPreventEnteringBackForwardCache_DEPRECATED const): Deleted.
+ * Modules/webdatabase/DatabaseContext.h:
+ * Modules/webdatabase/DatabaseManager.cpp:
+ (WebCore::DatabaseManager::openDatabase):
+ * Modules/webdatabase/SQLTransaction.cpp:
+ (WebCore::SQLTransaction::performPendingCallback):
+
2019-10-24 Mark Lam <mark....@apple.com>
Move JSC::Register inline methods into RegisterInlines.h.
Modified: trunk/Source/WebCore/Modules/webdatabase/Database.cpp (251585 => 251586)
--- trunk/Source/WebCore/Modules/webdatabase/Database.cpp 2019-10-25 08:14:07 UTC (rev 251585)
+++ trunk/Source/WebCore/Modules/webdatabase/Database.cpp 2019-10-25 08:14:19 UTC (rev 251586)
@@ -52,6 +52,7 @@
#include "ScriptExecutionContext.h"
#include "SecurityOrigin.h"
#include "VoidCallback.h"
+#include "WindowEventLoop.h"
#include <wtf/NeverDestroyed.h>
#include <wtf/RefPtr.h>
#include <wtf/StdLibExtras.h>
@@ -684,10 +685,11 @@
void Database::runTransaction(RefPtr<SQLTransactionCallback>&& callback, RefPtr<SQLTransactionErrorCallback>&& errorCallback, RefPtr<VoidCallback>&& successCallback, RefPtr<SQLTransactionWrapper>&& wrapper, bool readOnly)
{
+ ASSERT(isMainThread());
LockHolder locker(m_transactionInProgressMutex);
if (!m_isTransactionQueueEnabled) {
if (errorCallback) {
- callOnMainThread([errorCallback = makeRef(*errorCallback)]() {
+ m_document->eventLoop().queueTask(TaskSource::Networking, m_document, [errorCallback = makeRef(*errorCallback)]() {
errorCallback->handleEvent(SQLError::create(SQLError::UNKNOWN_ERR, "database has been closed"));
});
}
Modified: trunk/Source/WebCore/Modules/webdatabase/DatabaseContext.cpp (251585 => 251586)
--- trunk/Source/WebCore/Modules/webdatabase/DatabaseContext.cpp 2019-10-25 08:14:07 UTC (rev 251585)
+++ trunk/Source/WebCore/Modules/webdatabase/DatabaseContext.cpp 2019-10-25 08:14:19 UTC (rev 251586)
@@ -130,15 +130,6 @@
stopDatabases();
}
-// FIXME: This should never prevent entering the back/forward cache.
-bool DatabaseContext::shouldPreventEnteringBackForwardCache_DEPRECATED() const
-{
- if (!hasOpenDatabases() || !m_databaseThread)
- return false;
-
- return m_databaseThread->hasPendingDatabaseActivity();
-}
-
DatabaseThread* DatabaseContext::databaseThread()
{
if (!m_databaseThread && !m_hasOpenDatabases) {
Modified: trunk/Source/WebCore/Modules/webdatabase/DatabaseContext.h (251585 => 251586)
--- trunk/Source/WebCore/Modules/webdatabase/DatabaseContext.h 2019-10-25 08:14:07 UTC (rev 251585)
+++ trunk/Source/WebCore/Modules/webdatabase/DatabaseContext.h 2019-10-25 08:14:19 UTC (rev 251586)
@@ -73,7 +73,6 @@
void contextDestroyed() override;
void stop() override;
- bool shouldPreventEnteringBackForwardCache_DEPRECATED() const override;
const char* activeDOMObjectName() const override { return "DatabaseContext"; }
RefPtr<DatabaseThread> m_databaseThread;
Modified: trunk/Source/WebCore/Modules/webdatabase/DatabaseManager.cpp (251585 => 251586)
--- trunk/Source/WebCore/Modules/webdatabase/DatabaseManager.cpp 2019-10-25 08:14:07 UTC (rev 251585)
+++ trunk/Source/WebCore/Modules/webdatabase/DatabaseManager.cpp 2019-10-25 08:14:19 UTC (rev 251586)
@@ -38,6 +38,7 @@
#include "ScriptController.h"
#include "SecurityOrigin.h"
#include "SecurityOriginData.h"
+#include "WindowEventLoop.h"
#include <wtf/NeverDestroyed.h>
namespace WebCore {
@@ -192,6 +193,7 @@
ExceptionOr<Ref<Database>> DatabaseManager::openDatabase(Document& document, const String& name, const String& expectedVersion, const String& displayName, unsigned estimatedSize, RefPtr<DatabaseCallback>&& creationCallback)
{
+ ASSERT(isMainThread());
ScriptController::initializeThreading();
bool setVersionInNewDatabase = !creationCallback;
@@ -208,7 +210,7 @@
if (database->isNew() && creationCallback.get()) {
LOG(StorageAPI, "Scheduling DatabaseCreationCallbackTask for database %p\n", database.get());
database->setHasPendingCreationEvent(true);
- database->m_document->postTask([creationCallback, database] (ScriptExecutionContext&) {
+ database->m_document->eventLoop().queueTask(TaskSource::Networking, database->m_document, [creationCallback, database]() {
creationCallback->handleEvent(*database);
database->setHasPendingCreationEvent(false);
});
Modified: trunk/Source/WebCore/Modules/webdatabase/SQLTransaction.cpp (251585 => 251586)
--- trunk/Source/WebCore/Modules/webdatabase/SQLTransaction.cpp 2019-10-25 08:14:07 UTC (rev 251585)
+++ trunk/Source/WebCore/Modules/webdatabase/SQLTransaction.cpp 2019-10-25 08:14:19 UTC (rev 251586)
@@ -47,6 +47,7 @@
#include "SQLTransactionErrorCallback.h"
#include "SQLiteTransaction.h"
#include "VoidCallback.h"
+#include "WindowEventLoop.h"
#include <wtf/Optional.h>
#include <wtf/StdLibExtras.h>
#include <wtf/Vector.h>
@@ -109,18 +110,21 @@
void SQLTransaction::performPendingCallback()
{
- LOG(StorageAPI, "Callback %s\n", debugStepName(m_nextStep));
+ ASSERT(isMainThread());
+ m_database->document().eventLoop().queueTask(TaskSource::Networking, m_database->document(), [this, protectedThis = makeRef(*this)]() mutable {
+ LOG(StorageAPI, "Callback %s\n", debugStepName(m_nextStep));
- ASSERT(m_nextStep == &SQLTransaction::deliverTransactionCallback
- || m_nextStep == &SQLTransaction::deliverTransactionErrorCallback
- || m_nextStep == &SQLTransaction::deliverStatementCallback
- || m_nextStep == &SQLTransaction::deliverQuotaIncreaseCallback
- || m_nextStep == &SQLTransaction::deliverSuccessCallback);
+ ASSERT(m_nextStep == &SQLTransaction::deliverTransactionCallback
+ || m_nextStep == &SQLTransaction::deliverTransactionErrorCallback
+ || m_nextStep == &SQLTransaction::deliverStatementCallback
+ || m_nextStep == &SQLTransaction::deliverQuotaIncreaseCallback
+ || m_nextStep == &SQLTransaction::deliverSuccessCallback);
- checkAndHandleClosedDatabase();
+ checkAndHandleClosedDatabase();
- if (m_nextStep)
- (this->*m_nextStep)();
+ if (m_nextStep)
+ (this->*m_nextStep)();
+ });
}
void SQLTransaction::notifyDatabaseThreadIsShuttingDown()