Diff
Modified: trunk/Source/WebCore/ChangeLog (202808 => 202809)
--- trunk/Source/WebCore/ChangeLog 2016-07-04 11:44:11 UTC (rev 202808)
+++ trunk/Source/WebCore/ChangeLog 2016-07-04 15:30:50 UTC (rev 202809)
@@ -1,3 +1,29 @@
+2016-07-04 Brady Eidson <[email protected]>
+
+ WebProcesses don't handle DatabaseProcess going away uncleanly..
+ https://bugs.webkit.org/show_bug.cgi?id=159371
+
+ Reviewed by Alex Christensen.
+
+ Covered by new API test.
+
+ * Modules/indexeddb/IDBDatabase.cpp:
+ (WebCore::IDBDatabase::didCloseFromServer):
+ (WebCore::IDBDatabase::connectionToServerLost):
+ * Modules/indexeddb/IDBDatabase.h:
+
+ * Modules/indexeddb/client/IDBConnectionProxy.cpp:
+ (WebCore::IDBClient::IDBConnectionProxy::connectionToServerLost): Notify all IDBDatabase
+ connections, as well as all pending IDBOpenDBRequests, with the error about the
+ server connection dropping.
+ * Modules/indexeddb/client/IDBConnectionProxy.h:
+
+ * Modules/indexeddb/client/IDBConnectionToServer.cpp:
+ (WebCore::IDBClient::IDBConnectionToServer::connectionToServerLost):
+ * Modules/indexeddb/client/IDBConnectionToServer.h:
+
+ * Modules/indexeddb/shared/IDBError.h:
+
2016-07-04 Philippe Normand <[email protected]>
Release build with logging enabled fails
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp (202808 => 202809)
--- trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp 2016-07-04 11:44:11 UTC (rev 202808)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp 2016-07-04 15:30:50 UTC (rev 202809)
@@ -257,6 +257,15 @@
{
LOG(IndexedDB, "IDBDatabase::didCloseFromServer - %" PRIu64, m_databaseConnectionIdentifier);
+ connectionToServerLost(error);
+
+ m_connectionProxy->confirmDidCloseFromServer(*this);
+}
+
+void IDBDatabase::connectionToServerLost(const IDBError& error)
+{
+ LOG(IndexedDB, "IDBDatabase::connectionToServerLost - %" PRIu64, m_databaseConnectionIdentifier);
+
ASSERT(currentThread() == originThreadID());
m_closePending = true;
@@ -268,8 +277,6 @@
Ref<Event> event = Event::create(eventNames().errorEvent, true, false);
event->setTarget(this);
scriptExecutionContext()->eventQueue().enqueueEvent(WTFMove(event));
-
- m_connectionProxy->confirmDidCloseFromServer(*this);
}
void IDBDatabase::maybeCloseInServer()
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.h (202808 => 202809)
--- trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.h 2016-07-04 11:44:11 UTC (rev 202808)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.h 2016-07-04 15:30:50 UTC (rev 202809)
@@ -88,6 +88,7 @@
void fireVersionChangeEvent(const IDBResourceIdentifier& requestIdentifier, uint64_t requestedVersion);
void didCloseFromServer(const IDBError&);
+ void connectionToServerLost(const IDBError&);
IDBClient::IDBConnectionProxy& connectionProxy() { return m_connectionProxy.get(); }
Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionProxy.cpp (202808 => 202809)
--- trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionProxy.cpp 2016-07-04 11:44:11 UTC (rev 202808)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionProxy.cpp 2016-07-04 15:30:50 UTC (rev 202809)
@@ -386,6 +386,48 @@
callConnectionOnMainThread(&IDBConnectionToServer::confirmDidCloseFromServer, database.databaseConnectionIdentifier());
}
+void IDBConnectionProxy::connectionToServerLost(const IDBError& error)
+{
+ Vector<uint64_t> databaseConnectionIdentifiers;
+ {
+ Locker<Lock> locker(m_databaseConnectionMapLock);
+ copyKeysToVector(m_databaseConnectionMap, databaseConnectionIdentifiers);
+ }
+
+ for (auto connectionIdentifier : databaseConnectionIdentifiers) {
+ RefPtr<IDBDatabase> database;
+ {
+ Locker<Lock> locker(m_databaseConnectionMapLock);
+ database = m_databaseConnectionMap.get(connectionIdentifier);
+ }
+
+ if (!database)
+ continue;
+
+ database->performCallbackOnOriginThread(*database, &IDBDatabase::connectionToServerLost, error);
+ }
+
+ Vector<IDBResourceIdentifier> openDBRequestIdentifiers;
+ {
+ Locker<Lock> locker(m_openDBRequestMapLock);
+ copyKeysToVector(m_openDBRequestMap, openDBRequestIdentifiers);
+ }
+
+ for (auto& requestIdentifier : openDBRequestIdentifiers) {
+ RefPtr<IDBOpenDBRequest> request;
+ {
+ Locker<Lock> locker(m_openDBRequestMapLock);
+ request = m_openDBRequestMap.get(requestIdentifier);
+ }
+
+ if (!request)
+ continue;
+
+ auto result = IDBResultData::error(requestIdentifier, error);
+ request->performCallbackOnOriginThread(*request, &IDBOpenDBRequest::requestCompleted, result);
+ }
+}
+
void IDBConnectionProxy::scheduleMainThreadTasks()
{
Locker<Lock> locker(m_mainThreadTaskLock);
Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionProxy.h (202808 => 202809)
--- trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionProxy.h 2016-07-04 11:44:11 UTC (rev 202808)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionProxy.h 2016-07-04 15:30:50 UTC (rev 202809)
@@ -97,6 +97,8 @@
void didCloseFromServer(uint64_t databaseConnectionIdentifier, const IDBError&);
void confirmDidCloseFromServer(IDBDatabase&);
+ void connectionToServerLost(const IDBError&);
+
void abortOpenAndUpgradeNeeded(uint64_t databaseConnectionIdentifier, const IDBResourceIdentifier& transactionIdentifier);
void completeOperation(const IDBResultData&);
Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.cpp (202808 => 202809)
--- trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.cpp 2016-07-04 11:44:11 UTC (rev 202808)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.cpp 2016-07-04 15:30:50 UTC (rev 202809)
@@ -332,6 +332,14 @@
m_delegate->confirmDidCloseFromServer(databaseConnectionIdentifier);
}
+void IDBConnectionToServer::connectionToServerLost(const IDBError& error)
+{
+ LOG(IndexedDB, "IDBConnectionToServer::connectionToServerLost");
+ ASSERT(isMainThread());
+
+ m_proxy->connectionToServerLost(error);
+}
+
void IDBConnectionToServer::notifyOpenDBRequestBlocked(const IDBResourceIdentifier& requestIdentifier, uint64_t oldVersion, uint64_t newVersion)
{
LOG(IndexedDB, "IDBConnectionToServer::didStartTransaction");
Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.h (202808 => 202809)
--- trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.h 2016-07-04 11:44:11 UTC (rev 202808)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.h 2016-07-04 15:30:50 UTC (rev 202809)
@@ -110,6 +110,8 @@
WEBCORE_EXPORT void didCloseFromServer(uint64_t databaseConnectionIdentifier, const IDBError&);
void confirmDidCloseFromServer(uint64_t databaseConnectionIdentifier);
+ WEBCORE_EXPORT void connectionToServerLost(const IDBError&);
+
WEBCORE_EXPORT void notifyOpenDBRequestBlocked(const IDBResourceIdentifier& requestIdentifier, uint64_t oldVersion, uint64_t newVersion);
void openDBRequestCancelled(const IDBRequestData&);
Modified: trunk/Source/WebCore/Modules/indexeddb/shared/IDBError.h (202808 => 202809)
--- trunk/Source/WebCore/Modules/indexeddb/shared/IDBError.h 2016-07-04 11:44:11 UTC (rev 202808)
+++ trunk/Source/WebCore/Modules/indexeddb/shared/IDBError.h 2016-07-04 15:30:50 UTC (rev 202809)
@@ -37,7 +37,7 @@
public:
IDBError() { }
IDBError(ExceptionCode);
- IDBError(ExceptionCode, const String& message);
+ WEBCORE_EXPORT IDBError(ExceptionCode, const String& message);
static IDBError userDeleteError()
{
Modified: trunk/Source/WebKit2/ChangeLog (202808 => 202809)
--- trunk/Source/WebKit2/ChangeLog 2016-07-04 11:44:11 UTC (rev 202808)
+++ trunk/Source/WebKit2/ChangeLog 2016-07-04 15:30:50 UTC (rev 202809)
@@ -1,3 +1,22 @@
+2016-07-04 Brady Eidson <[email protected]>
+
+ WebProcesses don't handle DatabaseProcess going away uncleanly..
+ https://bugs.webkit.org/show_bug.cgi?id=159371
+
+ Reviewed by Alex Christensen.
+
+ * UIProcess/WebProcessPool.cpp:
+ (WebKit::WebProcessPool::terminateDatabaseProcess): Deleted.
+
+ * WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.cpp:
+ (WebKit::WebIDBConnectionToServer::connectionToServerLost):
+ * WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.h:
+
+ * WebProcess/Databases/WebToDatabaseProcessConnection.cpp:
+ (WebKit::WebToDatabaseProcessConnection::didReceiveMessage):
+ (WebKit::WebToDatabaseProcessConnection::didClose): Notify each connection
+ that the database server connection dropped.
+
2016-07-04 Fujii Hironori <[email protected]>
[GTK] Null WebCore::Range dereference in WebEditorClient::updateGlobalSelection
Modified: trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp (202808 => 202809)
--- trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp 2016-07-04 11:44:11 UTC (rev 202808)
+++ trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp 2016-07-04 15:30:50 UTC (rev 202809)
@@ -1100,7 +1100,6 @@
void WebProcessPool::terminateDatabaseProcess()
{
#if ENABLE(DATABASE_PROCESS)
- ASSERT(m_processes.isEmpty());
if (!m_databaseProcess)
return;
Modified: trunk/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.cpp (202808 => 202809)
--- trunk/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.cpp 2016-07-04 11:44:11 UTC (rev 202808)
+++ trunk/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.cpp 2016-07-04 15:30:50 UTC (rev 202809)
@@ -38,6 +38,7 @@
#include "WebToDatabaseProcessConnection.h"
#include <WebCore/IDBConnectionToServer.h>
#include <WebCore/IDBCursorInfo.h>
+#include <WebCore/IDBDatabaseException.h>
#include <WebCore/IDBError.h>
#include <WebCore/IDBIndexInfo.h>
#include <WebCore/IDBKeyRangeData.h>
@@ -316,6 +317,11 @@
m_connectionToServer->didGetAllDatabaseNames(callbackID, databaseNames);
}
+void WebIDBConnectionToServer::connectionToServerLost()
+{
+ m_connectionToServer->connectionToServerLost({ WebCore::IDBDatabaseException::UnknownError, ASCIILiteral("An internal error was encountered in the Indexed Database server") });
+}
+
} // namespace WebKit
#endif // ENABLE(INDEXED_DATABASE)
Modified: trunk/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.h (202808 => 202809)
--- trunk/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.h 2016-07-04 11:44:11 UTC (rev 202808)
+++ trunk/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.h 2016-07-04 15:30:50 UTC (rev 202809)
@@ -98,6 +98,8 @@
void didReceiveMessage(IPC::Connection&, IPC::MessageDecoder&);
+ void connectionToServerLost();
+
private:
WebIDBConnectionToServer();
Modified: trunk/Source/WebKit2/WebProcess/Databases/WebToDatabaseProcessConnection.cpp (202808 => 202809)
--- trunk/Source/WebKit2/WebProcess/Databases/WebToDatabaseProcessConnection.cpp 2016-07-04 11:44:11 UTC (rev 202808)
+++ trunk/Source/WebKit2/WebProcess/Databases/WebToDatabaseProcessConnection.cpp 2016-07-04 15:30:50 UTC (rev 202809)
@@ -52,9 +52,9 @@
{
#if ENABLE(INDEXED_DATABASE)
if (decoder.messageReceiverName() == Messages::WebIDBConnectionToServer::messageReceiverName()) {
- auto iterator = m_webIDBConnectionsByIdentifier.find(decoder.destinationID());
- if (iterator != m_webIDBConnectionsByIdentifier.end())
- iterator->value->didReceiveMessage(connection, decoder);
+ auto idbConnection = m_webIDBConnectionsByIdentifier.get(decoder.destinationID());
+ if (idbConnection)
+ idbConnection->didReceiveMessage(connection, decoder);
return;
}
#endif
@@ -64,6 +64,12 @@
void WebToDatabaseProcessConnection::didClose(IPC::Connection& connection)
{
+ for (auto& connection : m_webIDBConnectionsByIdentifier.values())
+ connection->connectionToServerLost();
+
+ m_webIDBConnectionsByIdentifier.clear();
+ m_webIDBConnectionsBySession.clear();
+
WebProcess::singleton().webToDatabaseProcessConnectionClosed(this);
}
Modified: trunk/Tools/ChangeLog (202808 => 202809)
--- trunk/Tools/ChangeLog 2016-07-04 11:44:11 UTC (rev 202808)
+++ trunk/Tools/ChangeLog 2016-07-04 15:30:50 UTC (rev 202809)
@@ -1,3 +1,16 @@
+2016-07-04 Brady Eidson <[email protected]>
+
+ WebProcesses don't handle DatabaseProcess going away uncleanly..
+ https://bugs.webkit.org/show_bug.cgi?id=159371
+
+ Reviewed by Alex Christensen.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/WebKit2Cocoa/IndexedDBDatabaseProcessKill-1.html: Added.
+ * TestWebKitAPI/Tests/WebKit2Cocoa/IndexedDBDatabaseProcessKill.mm: Added.
+ (-[DatabaseProcessKillNavigationDelegate webView:didFinishNavigation:]):
+ (-[DatabaseProcessKillMessageHandler userContentController:didReceiveScriptMessage:]):
+
2016-07-04 Carlos Alberto Lopez Perez <[email protected]>
[EFL][GTK] Layout Test doesn't run on Ubuntu 16.04
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (202808 => 202809)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2016-07-04 11:44:11 UTC (rev 202808)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2016-07-04 15:30:50 UTC (rev 202809)
@@ -71,6 +71,8 @@
51714EB81CF8CA17004723C4 /* WebProcessKillIDBCleanup.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51714EB61CF8C7A4004723C4 /* WebProcessKillIDBCleanup.mm */; };
517E7E04151119C100D0B008 /* MemoryCachePruneWithinResourceLoadDelegate.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 517E7E031511187500D0B008 /* MemoryCachePruneWithinResourceLoadDelegate.html */; };
51A5877D1D1B49CD004BA9AF /* IndexedDBMultiProcess-3.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 51A5877C1D1B3D8D004BA9AF /* IndexedDBMultiProcess-3.html */; };
+ 51A587851D2739E3004BA9AF /* IndexedDBDatabaseProcessKill-1.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 51A587821D272EB5004BA9AF /* IndexedDBDatabaseProcessKill-1.html */; };
+ 51A587861D273AA9004BA9AF /* IndexedDBDatabaseProcessKill.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51A587841D272EF3004BA9AF /* IndexedDBDatabaseProcessKill.mm */; };
51B1EE961C80FAEF0064FB98 /* IndexedDBPersistence-1.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 51B1EE941C80FADD0064FB98 /* IndexedDBPersistence-1.html */; };
51B1EE971C80FAEF0064FB98 /* IndexedDBPersistence-2.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 51B1EE951C80FADD0064FB98 /* IndexedDBPersistence-2.html */; };
51BCEE4E1C84F53B0042C82E /* IndexedDBMultiProcess-1.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 51BCEE4C1C84F52C0042C82E /* IndexedDBMultiProcess-1.html */; };
@@ -470,6 +472,7 @@
dstPath = TestWebKitAPI.resources;
dstSubfolderSpec = 7;
files = (
+ 51A587851D2739E3004BA9AF /* IndexedDBDatabaseProcessKill-1.html in Copy Resources */,
51A5877D1D1B49CD004BA9AF /* IndexedDBMultiProcess-3.html in Copy Resources */,
9984FACE1CFFB090008D198C /* editable-body.html in Copy Resources */,
51714EB41CF8C78C004723C4 /* WebProcessKillIDBCleanup-1.html in Copy Resources */,
@@ -700,6 +703,8 @@
517E7DFB15110EA600D0B008 /* MemoryCachePruneWithinResourceLoadDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MemoryCachePruneWithinResourceLoadDelegate.mm; sourceTree = "<group>"; };
517E7E031511187500D0B008 /* MemoryCachePruneWithinResourceLoadDelegate.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = MemoryCachePruneWithinResourceLoadDelegate.html; sourceTree = "<group>"; };
51A5877C1D1B3D8D004BA9AF /* IndexedDBMultiProcess-3.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "IndexedDBMultiProcess-3.html"; sourceTree = "<group>"; };
+ 51A587821D272EB5004BA9AF /* IndexedDBDatabaseProcessKill-1.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "IndexedDBDatabaseProcessKill-1.html"; sourceTree = "<group>"; };
+ 51A587841D272EF3004BA9AF /* IndexedDBDatabaseProcessKill.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = IndexedDBDatabaseProcessKill.mm; sourceTree = "<group>"; };
51B1EE8D1C80F5880064FB98 /* IndexedDBPersistence.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = IndexedDBPersistence.mm; sourceTree = "<group>"; };
51B1EE941C80FADD0064FB98 /* IndexedDBPersistence-1.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "IndexedDBPersistence-1.html"; sourceTree = "<group>"; };
51B1EE951C80FADD0064FB98 /* IndexedDBPersistence-2.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "IndexedDBPersistence-2.html"; sourceTree = "<group>"; };
@@ -1151,6 +1156,7 @@
2D8104CB1BEC13E70020DA46 /* FindInPage.mm */,
2D1FE0AF1AD465C1006CD9E6 /* FixedLayoutSize.mm */,
CDE195B31CFE0ADE0053D256 /* FullscreenTopContentInset.mm */,
+ 51A587841D272EF3004BA9AF /* IndexedDBDatabaseProcessKill.mm */,
51BCEE491C84F4AF0042C82E /* IndexedDBMultiProcess.mm */,
51B1EE8D1C80F5880064FB98 /* IndexedDBPersistence.mm */,
37D36ED61AF42ECD00BAF5D9 /* LoadAlternateHTMLString.mm */,
@@ -1257,6 +1263,7 @@
5714ECB81CA8B58800051AC8 /* DownloadRequestOriginalURL.html */,
5714ECBC1CA8C21800051AC8 /* DownloadRequestOriginalURL2.html */,
5714ECBA1CA8BFD100051AC8 /* DownloadRequestOriginalURLFrame.html */,
+ 51A587821D272EB5004BA9AF /* IndexedDBDatabaseProcessKill-1.html */,
51BCEE4C1C84F52C0042C82E /* IndexedDBMultiProcess-1.html */,
51BCEE4D1C84F52C0042C82E /* IndexedDBMultiProcess-2.html */,
51A5877C1D1B3D8D004BA9AF /* IndexedDBMultiProcess-3.html */,
@@ -2095,6 +2102,7 @@
7CCE7F241A411AF600447C4C /* Navigation.mm in Sources */,
A14FC5881B8991BF00D107EB /* ContentFiltering.mm in Sources */,
7CCE7F021A411AE600447C4C /* NewFirstVisuallyNonEmptyLayout.cpp in Sources */,
+ 51A587861D273AA9004BA9AF /* IndexedDBDatabaseProcessKill.mm in Sources */,
7CCE7F031A411AE600447C4C /* NewFirstVisuallyNonEmptyLayoutFails.cpp in Sources */,
7CCE7F041A411AE600447C4C /* NewFirstVisuallyNonEmptyLayoutForImages.cpp in Sources */,
764322D71B61CCC30024F801 /* WordBoundaryTypingAttributes.mm in Sources */,
Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/IndexedDBDatabaseProcessKill-1.html (0 => 202809)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/IndexedDBDatabaseProcessKill-1.html (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/IndexedDBDatabaseProcessKill-1.html 2016-07-04 15:30:50 UTC (rev 202809)
@@ -0,0 +1,33 @@
+<script>
+
+var database;
+
+for (var i = 0; i < 100; ++i) {
+ var request = window.indexedDB.deleteDatabase("IndexedDBDatabaseProcessKill");
+ request._onsuccess_ = function() {
+ window.webkit.messageHandlers.testHandler.postMessage('DeleteRequestDone');
+ }
+ request._onerror_ = function() {
+ window.webkit.messageHandlers.testHandler.postMessage('DeleteRequestError');
+ }
+
+ request = window.indexedDB.open("IndexedDBDatabaseProcessKill");
+ request._onsuccess_ = function() {
+ window.webkit.messageHandlers.testHandler.postMessage('OpenRequestDone');
+ }
+ request._onerror_ = function() {
+ window.webkit.messageHandlers.testHandler.postMessage('OpenRequestError');
+ }
+ request._onupgradeneeded_ = function(e) {
+ database = e.target.result;
+ database._onerror_ = function() {
+ notifyDatabaseErrorReceived = function() {
+ window.webkit.messageHandlers.testHandler.postMessage('DatabaseErrorReceived');
+ }
+ setTimeout("setTimeout(notifyDatabaseErrorReceived, 0)", 0);
+ }
+ window.webkit.messageHandlers.testHandler.postMessage('OpenRequestUpgradeNeeded');
+ }
+}
+
+</script>
Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/IndexedDBDatabaseProcessKill.mm (0 => 202809)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/IndexedDBDatabaseProcessKill.mm (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/IndexedDBDatabaseProcessKill.mm 2016-07-04 15:30:50 UTC (rev 202809)
@@ -0,0 +1,126 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+
+#import "PlatformUtilities.h"
+#import "Test.h"
+#import <WebKit/WKProcessPoolPrivate.h>
+#import <WebKit/WKUserContentControllerPrivate.h>
+#import <WebKit/WKWebViewConfigurationPrivate.h>
+#import <WebKit/WebKit.h>
+#import <WebKit/_WKProcessPoolConfiguration.h>
+#import <wtf/RetainPtr.h>
+
+#if WK_API_ENABLED
+
+static bool isDoneWithNavigation;
+
+@interface DatabaseProcessKillNavigationDelegate : NSObject <WKNavigationDelegate>
+@end
+
+@implementation DatabaseProcessKillNavigationDelegate
+
+- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation
+{
+ isDoneWithNavigation = true;
+}
+
+@end
+
+static bool receivedScriptMessage;
+static bool receivedAtLeastOneOpenError;
+static bool receivedAtLeastOneDeleteError;
+static bool openRequestUpgradeNeeded;
+static bool databaseErrorReceived;
+
+@interface DatabaseProcessKillMessageHandler : NSObject <WKScriptMessageHandler>
+@end
+
+@implementation DatabaseProcessKillMessageHandler
+
+- (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message
+{
+ receivedScriptMessage = true;
+
+ if ([[message body] isEqualToString:@"DatabaseErrorReceived"]) {
+ databaseErrorReceived = true;
+ return;
+ }
+
+ if ([[message body] isEqualToString:@"OpenRequestUpgradeNeeded"]) {
+ openRequestUpgradeNeeded = true;
+ return;
+ }
+
+ if ([[message body] isEqualToString:@"DeleteRequestError"]) {
+ receivedAtLeastOneDeleteError = true;
+ return;
+ }
+
+ if ([[message body] isEqualToString:@"OpenRequestError"])
+ receivedAtLeastOneOpenError = true;
+}
+
+@end
+
+TEST(IndexedDB, DatabaseProcessKill)
+{
+ RetainPtr<DatabaseProcessKillMessageHandler> handler = adoptNS([[DatabaseProcessKillMessageHandler alloc] init]);
+ RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+ [[configuration userContentController] addScriptMessageHandler:handler.get() name:@"testHandler"];
+
+ // Allow file URLs to load non-file resources
+ [configuration _setAllowUniversalAccessFromFileURLs:YES];
+
+ RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
+
+ DatabaseProcessKillNavigationDelegate *delegate = [[DatabaseProcessKillNavigationDelegate alloc] init];
+ [webView setNavigationDelegate:delegate];
+
+ NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"IndexedDBDatabaseProcessKill-1" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
+ [webView loadRequest:request];
+
+ TestWebKitAPI::Util::run(&isDoneWithNavigation);
+
+ bool killedDBProcess = false;
+ while (true) {
+ if (databaseErrorReceived)
+ break;
+
+ receivedScriptMessage = false;
+ TestWebKitAPI::Util::run(&receivedScriptMessage);
+ if (!killedDBProcess && openRequestUpgradeNeeded) {
+ killedDBProcess = true;
+ [configuration.get().processPool _terminateDatabaseProcess];
+ }
+ }
+
+ EXPECT_EQ(receivedAtLeastOneOpenError, true);
+ EXPECT_EQ(receivedAtLeastOneDeleteError, true);
+ EXPECT_EQ(databaseErrorReceived, true);
+}
+
+#endif