<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[197313] releases/WebKitGTK/webkit-2.12</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/197313">197313</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2016-02-28 23:35:53 -0800 (Sun, 28 Feb 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/197231">r197231</a> - Modern IDB: New database versions are never committed to SQLite.
&lt;rdar://problem/24860952&gt; and https://bugs.webkit.org/show_bug.cgi?id=154741

Modern IDB: If a database handle is not open, files are not actually deleted from disk
https://bugs.webkit.org/show_bug.cgi?id=154756

Reviewed by Alex Christensen.

Source/WebCore:

Tested by API test &quot;IndexedDBPersistence&quot;

* Modules/indexeddb/server/IDBServer.cpp:
(WebCore::IDBServer::IDBServer::deleteDatabase): If there's not an open handle to the database, create one.

* Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
(WebCore::IDBServer::SQLiteIDBBackingStore::beginTransaction): If a version change transaction, actually
  set the new version on disk.

* Modules/indexeddb/server/UniqueIDBDatabase.cpp:
(WebCore::IDBServer::UniqueIDBDatabase::performCurrentDeleteOperation):
(WebCore::IDBServer::UniqueIDBDatabase::deleteBackingStore): If there is no open backing store, create one.
  This is necessary to both read the current database version, and to actually delete the file on disk.
(WebCore::IDBServer::UniqueIDBDatabase::didDeleteBackingStore): If necessary, manufacture a &quot;most recently
  deleted database info&quot; from the version returned by deleteBackingStore.
* Modules/indexeddb/server/UniqueIDBDatabase.h:

Source/WebKit2:

Add WK2 SPI to force termination of the database process.

* UIProcess/API/Cocoa/WKProcessPool.mm:
(-[WKProcessPool _terminateDatabaseProcess]):
* UIProcess/API/Cocoa/WKProcessPoolPrivate.h:
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::terminateDatabaseProcess):
* UIProcess/WebProcessPool.h:

Tools:

This also happens to test the previously untested fix for http://trac.webkit.org/changeset/197190

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2Cocoa/IndexedDBPersistence-1.html: Added.
* TestWebKitAPI/Tests/WebKit2Cocoa/IndexedDBPersistence-2.html: Added.
* TestWebKitAPI/Tests/WebKit2Cocoa/IndexedDBPersistence.mm: Added.
(-[IndexedDBNavigationDelegate webView:didFinishNavigation:]):
(-[IndexedDBMessageHandler userContentController:didReceiveScriptMessage:]):
(TEST):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#releasesWebKitGTKwebkit212SourceWebCoreChangeLog">releases/WebKitGTK/webkit-2.12/Source/WebCore/ChangeLog</a></li>
<li><a href="#releasesWebKitGTKwebkit212SourceWebCoreModulesindexeddbserverIDBServercpp">releases/WebKitGTK/webkit-2.12/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit212SourceWebCoreModulesindexeddbserverSQLiteIDBBackingStorecpp">releases/WebKitGTK/webkit-2.12/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit212SourceWebCoreModulesindexeddbserverUniqueIDBDatabasecpp">releases/WebKitGTK/webkit-2.12/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit212SourceWebCoreModulesindexeddbserverUniqueIDBDatabaseh">releases/WebKitGTK/webkit-2.12/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.h</a></li>
<li><a href="#releasesWebKitGTKwebkit212SourceWebKit2ChangeLog">releases/WebKitGTK/webkit-2.12/Source/WebKit2/ChangeLog</a></li>
<li><a href="#releasesWebKitGTKwebkit212SourceWebKit2UIProcessAPICocoaWKProcessPoolmm">releases/WebKitGTK/webkit-2.12/Source/WebKit2/UIProcess/API/Cocoa/WKProcessPool.mm</a></li>
<li><a href="#releasesWebKitGTKwebkit212SourceWebKit2UIProcessAPICocoaWKProcessPoolPrivateh">releases/WebKitGTK/webkit-2.12/Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h</a></li>
<li><a href="#releasesWebKitGTKwebkit212SourceWebKit2UIProcessWebProcessPoolcpp">releases/WebKitGTK/webkit-2.12/Source/WebKit2/UIProcess/WebProcessPool.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit212SourceWebKit2UIProcessWebProcessPoolh">releases/WebKitGTK/webkit-2.12/Source/WebKit2/UIProcess/WebProcessPool.h</a></li>
<li><a href="#releasesWebKitGTKwebkit212ToolsChangeLog">releases/WebKitGTK/webkit-2.12/Tools/ChangeLog</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#releasesWebKitGTKwebkit212ToolsTestWebKitAPITestsWebKit2CocoaIndexedDBPersistence1html">releases/WebKitGTK/webkit-2.12/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/IndexedDBPersistence-1.html</a></li>
<li><a href="#releasesWebKitGTKwebkit212ToolsTestWebKitAPITestsWebKit2CocoaIndexedDBPersistence2html">releases/WebKitGTK/webkit-2.12/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/IndexedDBPersistence-2.html</a></li>
<li><a href="#releasesWebKitGTKwebkit212ToolsTestWebKitAPITestsWebKit2CocoaIndexedDBPersistencemm">releases/WebKitGTK/webkit-2.12/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/IndexedDBPersistence.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="releasesWebKitGTKwebkit212SourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.12/Source/WebCore/ChangeLog (197312 => 197313)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.12/Source/WebCore/ChangeLog        2016-02-29 07:35:21 UTC (rev 197312)
+++ releases/WebKitGTK/webkit-2.12/Source/WebCore/ChangeLog        2016-02-29 07:35:53 UTC (rev 197313)
</span><span class="lines">@@ -1,5 +1,32 @@
</span><span class="cx"> 2016-02-26  Brady Eidson  &lt;beidson@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Modern IDB: New database versions are never committed to SQLite.
+        &lt;rdar://problem/24860952&gt; and https://bugs.webkit.org/show_bug.cgi?id=154741
+        
+        Modern IDB: If a database handle is not open, files are not actually deleted from disk
+        https://bugs.webkit.org/show_bug.cgi?id=154756
+
+        Reviewed by Alex Christensen.
+
+        Tested by API test &quot;IndexedDBPersistence&quot;
+
+        * Modules/indexeddb/server/IDBServer.cpp:
+        (WebCore::IDBServer::IDBServer::deleteDatabase): If there's not an open handle to the database, create one.
+
+        * Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
+        (WebCore::IDBServer::SQLiteIDBBackingStore::beginTransaction): If a version change transaction, actually
+          set the new version on disk.
+        
+        * Modules/indexeddb/server/UniqueIDBDatabase.cpp:
+        (WebCore::IDBServer::UniqueIDBDatabase::performCurrentDeleteOperation):
+        (WebCore::IDBServer::UniqueIDBDatabase::deleteBackingStore): If there is no open backing store, create one.
+          This is necessary to both read the current database version, and to actually delete the file on disk.
+        (WebCore::IDBServer::UniqueIDBDatabase::didDeleteBackingStore): If necessary, manufacture a &quot;most recently
+          deleted database info&quot; from the version returned by deleteBackingStore.
+        * Modules/indexeddb/server/UniqueIDBDatabase.h:
+
+2016-02-26  Brady Eidson  &lt;beidson@apple.com&gt;
+
</ins><span class="cx">         Modern IDB: Using existing database info from SQLite backing store is busted.
</span><span class="cx">         &lt;rdar://problem/24848143&gt; and https://bugs.webkit.org/show_bug.cgi?id=154735
</span><span class="cx"> 
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit212SourceWebCoreModulesindexeddbserverIDBServercpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.12/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp (197312 => 197313)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.12/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp        2016-02-29 07:35:21 UTC (rev 197312)
+++ releases/WebKitGTK/webkit-2.12/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp        2016-02-29 07:35:53 UTC (rev 197313)
</span><span class="lines">@@ -151,10 +151,8 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     auto* database = m_uniqueIDBDatabaseMap.get(requestData.databaseIdentifier());
</span><del>-    if (!database) {
-        connection-&gt;didDeleteDatabase(IDBResultData::deleteDatabaseSuccess(requestData.requestIdentifier(), IDBDatabaseInfo(requestData.databaseIdentifier().databaseName(), 0)));
-        return;
-    }
</del><ins>+    if (!database)
+        database = &amp;getOrCreateUniqueIDBDatabase(requestData.databaseIdentifier());
</ins><span class="cx"> 
</span><span class="cx">     database-&gt;handleDelete(*connection, requestData);
</span><span class="cx"> }
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit212SourceWebCoreModulesindexeddbserverSQLiteIDBBackingStorecpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.12/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp (197312 => 197313)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.12/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp        2016-02-29 07:35:21 UTC (rev 197312)
+++ releases/WebKitGTK/webkit-2.12/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp        2016-02-29 07:35:53 UTC (rev 197313)
</span><span class="lines">@@ -623,9 +623,16 @@
</span><span class="cx">     addResult.iterator-&gt;value = std::make_unique&lt;SQLiteIDBTransaction&gt;(*this, info);
</span><span class="cx"> 
</span><span class="cx">     auto error = addResult.iterator-&gt;value-&gt;begin(*m_sqliteDB);
</span><del>-    if (error.isNull() &amp;&amp; info.mode() == IndexedDB::TransactionMode::VersionChange)
</del><ins>+    if (error.isNull() &amp;&amp; info.mode() == IndexedDB::TransactionMode::VersionChange) {
</ins><span class="cx">         m_originalDatabaseInfoBeforeVersionChange = std::make_unique&lt;IDBDatabaseInfo&gt;(*m_databaseInfo);
</span><span class="cx"> 
</span><ins>+        SQLiteStatement sql(*m_sqliteDB, ASCIILiteral(&quot;UPDATE IDBDatabaseInfo SET value = ? where key = 'DatabaseVersion';&quot;));
+        if (sql.prepare() != SQLITE_OK
+            || sql.bindText(1, String::number(info.newVersion())) != SQLITE_OK
+            || sql.step() != SQLITE_DONE)
+            error = { IDBDatabaseException::UnknownError, ASCIILiteral(&quot;Failed to store new database version in database&quot;) };
+    }
+
</ins><span class="cx">     return error;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit212SourceWebCoreModulesindexeddbserverUniqueIDBDatabasecpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.12/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp (197312 => 197313)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.12/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp        2016-02-29 07:35:21 UTC (rev 197312)
+++ releases/WebKitGTK/webkit-2.12/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp        2016-02-29 07:35:53 UTC (rev 197313)
</span><span class="lines">@@ -193,30 +193,38 @@
</span><span class="cx">     // In that scenario only the first request will actually have to delete the database.
</span><span class="cx">     // Subsequent requests can immediately notify their completion.
</span><span class="cx"> 
</span><del>-    if (m_databaseInfo) {
-        m_deleteBackingStoreInProgress = true;
-        m_server.postDatabaseTask(createCrossThreadTask(*this, &amp;UniqueIDBDatabase::deleteBackingStore));
-    } else {
-        ASSERT(m_mostRecentDeletedDatabaseInfo);
-        didDeleteBackingStore();
</del><ins>+    if (!m_deleteBackingStoreInProgress) {
+        if (!m_databaseInfo &amp;&amp; m_mostRecentDeletedDatabaseInfo)
+            didDeleteBackingStore(0);
+        else {
+            m_deleteBackingStoreInProgress = true;
+            m_server.postDatabaseTask(createCrossThreadTask(*this, &amp;UniqueIDBDatabase::deleteBackingStore, m_identifier));
+        }
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void UniqueIDBDatabase::deleteBackingStore()
</del><ins>+void UniqueIDBDatabase::deleteBackingStore(const IDBDatabaseIdentifier&amp; identifier)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(!isMainThread());
</span><span class="cx">     LOG(IndexedDB, &quot;(db) UniqueIDBDatabase::deleteBackingStore&quot;);
</span><span class="cx"> 
</span><ins>+    uint64_t deletedVersion = 0;
+
</ins><span class="cx">     if (m_backingStore) {
</span><span class="cx">         m_backingStore-&gt;deleteBackingStore();
</span><span class="cx">         m_backingStore = nullptr;
</span><span class="cx">         m_backingStoreSupportsSimultaneousTransactions = false;
</span><ins>+    } else {
+        auto backingStore = m_server.createBackingStore(identifier);
+        auto databaseInfo = backingStore-&gt;getOrEstablishDatabaseInfo();
+        deletedVersion = databaseInfo.version();
+        backingStore-&gt;deleteBackingStore();
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    m_server.postDatabaseTaskReply(createCrossThreadTask(*this, &amp;UniqueIDBDatabase::didDeleteBackingStore));
</del><ins>+    m_server.postDatabaseTaskReply(createCrossThreadTask(*this, &amp;UniqueIDBDatabase::didDeleteBackingStore, deletedVersion));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void UniqueIDBDatabase::didDeleteBackingStore()
</del><ins>+void UniqueIDBDatabase::didDeleteBackingStore(uint64_t deletedVersion)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(isMainThread());
</span><span class="cx">     LOG(IndexedDB, &quot;(main) UniqueIDBDatabase::didDeleteBackingStore&quot;);
</span><span class="lines">@@ -231,7 +239,12 @@
</span><span class="cx">     if (m_databaseInfo)
</span><span class="cx">         m_mostRecentDeletedDatabaseInfo = WTFMove(m_databaseInfo);
</span><span class="cx"> 
</span><del>-    ASSERT(m_mostRecentDeletedDatabaseInfo);
</del><ins>+    // If this UniqueIDBDatabase was brought into existence for the purpose of deleting the file on disk,
+    // we won't have a m_mostRecentDeletedDatabaseInfo. In that case, we'll manufacture one using the
+    // passed in deletedVersion argument.
+    if (!m_mostRecentDeletedDatabaseInfo)
+        m_mostRecentDeletedDatabaseInfo = std::make_unique&lt;IDBDatabaseInfo&gt;(m_identifier.databaseName(), deletedVersion);
+
</ins><span class="cx">     m_currentOpenDBRequest-&gt;notifyDidDeleteDatabase(*m_mostRecentDeletedDatabaseInfo);
</span><span class="cx">     m_currentOpenDBRequest = nullptr;
</span><span class="cx"> 
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit212SourceWebCoreModulesindexeddbserverUniqueIDBDatabaseh"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.12/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.h (197312 => 197313)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.12/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.h        2016-02-29 07:35:21 UTC (rev 197312)
+++ releases/WebKitGTK/webkit-2.12/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.h        2016-02-29 07:35:53 UTC (rev 197313)
</span><span class="lines">@@ -125,7 +125,7 @@
</span><span class="cx">     void inProgressTransactionCompleted(const IDBResourceIdentifier&amp;);
</span><span class="cx"> 
</span><span class="cx">     // Database thread operations
</span><del>-    void deleteBackingStore();
</del><ins>+    void deleteBackingStore(const IDBDatabaseIdentifier&amp;);
</ins><span class="cx">     void openBackingStore(const IDBDatabaseIdentifier&amp;);
</span><span class="cx">     void performCommitTransaction(uint64_t callbackIdentifier, const IDBResourceIdentifier&amp; transactionIdentifier);
</span><span class="cx">     void performAbortTransaction(uint64_t callbackIdentifier, const IDBResourceIdentifier&amp; transactionIdentifier);
</span><span class="lines">@@ -145,7 +145,7 @@
</span><span class="cx">     void performActivateTransactionInBackingStore(uint64_t callbackIdentifier, const IDBTransactionInfo&amp;);
</span><span class="cx"> 
</span><span class="cx">     // Main thread callbacks
</span><del>-    void didDeleteBackingStore();
</del><ins>+    void didDeleteBackingStore(uint64_t deletedVersion);
</ins><span class="cx">     void didOpenBackingStore(const IDBDatabaseInfo&amp;);
</span><span class="cx">     void didPerformCreateObjectStore(uint64_t callbackIdentifier, const IDBError&amp;, const IDBObjectStoreInfo&amp;);
</span><span class="cx">     void didPerformDeleteObjectStore(uint64_t callbackIdentifier, const IDBError&amp;, uint64_t objectStoreIdentifier);
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit212SourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.12/Source/WebKit2/ChangeLog (197312 => 197313)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.12/Source/WebKit2/ChangeLog        2016-02-29 07:35:21 UTC (rev 197312)
+++ releases/WebKitGTK/webkit-2.12/Source/WebKit2/ChangeLog        2016-02-29 07:35:53 UTC (rev 197313)
</span><span class="lines">@@ -1,3 +1,22 @@
</span><ins>+2016-02-26  Brady Eidson  &lt;beidson@apple.com&gt;
+
+        Modern IDB: New database versions are never committed to SQLite.
+        &lt;rdar://problem/24860952&gt; and https://bugs.webkit.org/show_bug.cgi?id=154741
+        
+        Modern IDB: If a database handle is not open, files are not actually deleted from disk
+        https://bugs.webkit.org/show_bug.cgi?id=154756
+
+        Reviewed by Alex Christensen.
+
+        Add WK2 SPI to force termination of the database process.
+
+        * UIProcess/API/Cocoa/WKProcessPool.mm:
+        (-[WKProcessPool _terminateDatabaseProcess]):
+        * UIProcess/API/Cocoa/WKProcessPoolPrivate.h:
+        * UIProcess/WebProcessPool.cpp:
+        (WebKit::WebProcessPool::terminateDatabaseProcess):
+        * UIProcess/WebProcessPool.h:
+
</ins><span class="cx"> 2016-02-25  Brady Eidson  &lt;beidson@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Remove LegacyIDB.
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit212SourceWebKit2UIProcessAPICocoaWKProcessPoolmm"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.12/Source/WebKit2/UIProcess/API/Cocoa/WKProcessPool.mm (197312 => 197313)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.12/Source/WebKit2/UIProcess/API/Cocoa/WKProcessPool.mm        2016-02-29 07:35:21 UTC (rev 197312)
+++ releases/WebKitGTK/webkit-2.12/Source/WebKit2/UIProcess/API/Cocoa/WKProcessPool.mm        2016-02-29 07:35:53 UTC (rev 197313)
</span><span class="lines">@@ -251,6 +251,11 @@
</span><span class="cx">     _processPool-&gt;setAutomationSession(automationSession ? automationSession-&gt;_session.get() : nullptr);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (void)_terminateDatabaseProcess
+{
+    _processPool-&gt;terminateDatabaseProcess();
+}
+
</ins><span class="cx"> @end
</span><span class="cx"> 
</span><span class="cx"> #endif // WK_API_ENABLED
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit212SourceWebKit2UIProcessAPICocoaWKProcessPoolPrivateh"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.12/Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h (197312 => 197313)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.12/Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h        2016-02-29 07:35:21 UTC (rev 197312)
+++ releases/WebKitGTK/webkit-2.12/Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h        2016-02-29 07:35:53 UTC (rev 197313)
</span><span class="lines">@@ -59,6 +59,9 @@
</span><span class="cx"> - (void)_automationCapabilitiesDidChange WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
</span><span class="cx"> - (void)_setAutomationSession:(_WKAutomationSession *)automationSession WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
</span><span class="cx"> 
</span><ins>+// Test only. Should be called only while no web content processes are running.
+- (void)_terminateDatabaseProcess;
+
</ins><span class="cx"> @end
</span><span class="cx"> 
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit212SourceWebKit2UIProcessWebProcessPoolcpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.12/Source/WebKit2/UIProcess/WebProcessPool.cpp (197312 => 197313)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.12/Source/WebKit2/UIProcess/WebProcessPool.cpp        2016-02-29 07:35:21 UTC (rev 197312)
+++ releases/WebKitGTK/webkit-2.12/Source/WebKit2/UIProcess/WebProcessPool.cpp        2016-02-29 07:35:53 UTC (rev 197313)
</span><span class="lines">@@ -1072,6 +1072,16 @@
</span><span class="cx">         m_networkProcess-&gt;send(Messages::NetworkProcess::ClearCachedCredentials(), 0);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebProcessPool::terminateDatabaseProcess()
+{
+    ASSERT(m_processes.isEmpty());
+    if (!m_databaseProcess)
+        return;
+
+    m_databaseProcess-&gt;terminate();
+    m_databaseProcess = nullptr;
+}
+
</ins><span class="cx"> void WebProcessPool::allowSpecificHTTPSCertificateForHost(const WebCertificateInfo* certificate, const String&amp; host)
</span><span class="cx"> {
</span><span class="cx">     if (m_networkProcess)
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit212SourceWebKit2UIProcessWebProcessPoolh"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.12/Source/WebKit2/UIProcess/WebProcessPool.h (197312 => 197313)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.12/Source/WebKit2/UIProcess/WebProcessPool.h        2016-02-29 07:35:21 UTC (rev 197312)
+++ releases/WebKitGTK/webkit-2.12/Source/WebKit2/UIProcess/WebProcessPool.h        2016-02-29 07:35:53 UTC (rev 197313)
</span><span class="lines">@@ -243,6 +243,7 @@
</span><span class="cx">     bool isUsingTestingNetworkSession() const { return m_shouldUseTestingNetworkSession; }
</span><span class="cx"> 
</span><span class="cx">     void clearCachedCredentials();
</span><ins>+    void terminateDatabaseProcess();
</ins><span class="cx"> 
</span><span class="cx">     void allowSpecificHTTPSCertificateForHost(const WebCertificateInfo*, const String&amp; host);
</span><span class="cx"> 
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit212ToolsChangeLog"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.12/Tools/ChangeLog (197312 => 197313)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.12/Tools/ChangeLog        2016-02-29 07:35:21 UTC (rev 197312)
+++ releases/WebKitGTK/webkit-2.12/Tools/ChangeLog        2016-02-29 07:35:53 UTC (rev 197313)
</span><span class="lines">@@ -1,3 +1,23 @@
</span><ins>+2016-02-26  Brady Eidson  &lt;beidson@apple.com&gt;
+
+        Modern IDB: New database versions are never committed to SQLite.
+        &lt;rdar://problem/24860952&gt; and https://bugs.webkit.org/show_bug.cgi?id=154741
+        
+        Modern IDB: If a database handle is not open, files are not actually deleted from disk
+        https://bugs.webkit.org/show_bug.cgi?id=154756
+
+        Reviewed by Alex Christensen.
+
+        This also happens to test the previously untested fix for http://trac.webkit.org/changeset/197190
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKit2Cocoa/IndexedDBPersistence-1.html: Added.
+        * TestWebKitAPI/Tests/WebKit2Cocoa/IndexedDBPersistence-2.html: Added.
+        * TestWebKitAPI/Tests/WebKit2Cocoa/IndexedDBPersistence.mm: Added.
+        (-[IndexedDBNavigationDelegate webView:didFinishNavigation:]):
+        (-[IndexedDBMessageHandler userContentController:didReceiveScriptMessage:]):
+        (TEST):
+
</ins><span class="cx"> 2016-02-18  Philippe Normand  &lt;pnormand@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [GStreamer] Bump internal jhbuild versions to 1.6.3
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit212ToolsTestWebKitAPITestsWebKit2CocoaIndexedDBPersistence1html"></a>
<div class="addfile"><h4>Added: releases/WebKitGTK/webkit-2.12/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/IndexedDBPersistence-1.html (0 => 197313)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.12/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/IndexedDBPersistence-1.html                                (rev 0)
+++ releases/WebKitGTK/webkit-2.12/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/IndexedDBPersistence-1.html        2016-02-29 07:35:53 UTC (rev 197313)
</span><span class="lines">@@ -0,0 +1,35 @@
</span><ins>+&lt;script&gt;
+
+var request = window.indexedDB.deleteDatabase(&quot;IndexedDBPersistence&quot;);
+request.onsuccess = function(e)
+{
+    continueTest();
+}
+request.onerror = function(e)
+{
+    // Unexpected error
+    window.webkit.messageHandlers.testHandler.postMessage('Error');
+}
+
+function continueTest()
+{
+    var request = window.indexedDB.open(&quot;IndexedDBPersistence&quot;, 2);
+
+    request.onsuccess = function()
+    {
+        window.webkit.messageHandlers.testHandler.postMessage('Success');
+
+    }
+    request.onerror = function()
+    {
+        // Unexpected error
+        window.webkit.messageHandlers.testHandler.postMessage('Error');
+    }
+    request.onupgradeneeded = function(event)
+    {
+        window.webkit.messageHandlers.testHandler.postMessage('UpgradeNeeded');
+
+        event.target.result.createObjectStore(&quot;TestObjectStore&quot;);
+    }
+}
+&lt;/script&gt;
</ins></span></pre></div>
<a id="releasesWebKitGTKwebkit212ToolsTestWebKitAPITestsWebKit2CocoaIndexedDBPersistence2html"></a>
<div class="addfile"><h4>Added: releases/WebKitGTK/webkit-2.12/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/IndexedDBPersistence-2.html (0 => 197313)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.12/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/IndexedDBPersistence-2.html                                (rev 0)
+++ releases/WebKitGTK/webkit-2.12/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/IndexedDBPersistence-2.html        2016-02-29 07:35:53 UTC (rev 197313)
</span><span class="lines">@@ -0,0 +1,22 @@
</span><ins>+&lt;script&gt;
+
+var request = window.indexedDB.open(&quot;IndexedDBPersistence&quot;);
+
+request.onsuccess = function(event)
+{
+    window.webkit.messageHandlers.testHandler.postMessage(event.target.result.version + &quot; &quot; + event.target.result.objectStoreNames[0]);
+}
+
+request.onerror = function()
+{
+    // Unexpected error
+    window.webkit.messageHandlers.testHandler.postMessage('Unexpected Error');
+}
+
+request.onupgradeneeded = function()
+{
+    // Unexpected error
+    window.webkit.messageHandlers.testHandler.postMessage('Unexpected UpgradeNeeded');
+}
+
+&lt;/script&gt;
</ins></span></pre></div>
<a id="releasesWebKitGTKwebkit212ToolsTestWebKitAPITestsWebKit2CocoaIndexedDBPersistencemm"></a>
<div class="addfile"><h4>Added: releases/WebKitGTK/webkit-2.12/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/IndexedDBPersistence.mm (0 => 197313)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.12/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/IndexedDBPersistence.mm                                (rev 0)
+++ releases/WebKitGTK/webkit-2.12/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/IndexedDBPersistence.mm        2016-02-29 07:35:53 UTC (rev 197313)
</span><span class="lines">@@ -0,0 +1,109 @@
</span><ins>+/*
+ * 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 &quot;config.h&quot;
+
+#import &quot;PlatformUtilities.h&quot;
+#import &quot;Test.h&quot;
+#import &lt;WebKit/WebKit.h&gt;
+#import &lt;WebKit/WKProcessPoolPrivate.h&gt;
+#import &lt;WebKit/WKUserContentControllerPrivate.h&gt;
+#import &lt;WebKit/_WKProcessPoolConfiguration.h&gt;
+#import &lt;WebKit/_WKUserStyleSheet.h&gt;
+#import &lt;wtf/RetainPtr.h&gt;
+
+#if WK_API_ENABLED
+
+static bool isDoneWithNavigation;
+
+@interface IndexedDBNavigationDelegate : NSObject &lt;WKNavigationDelegate&gt;
+@end
+
+@implementation IndexedDBNavigationDelegate
+
+- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation
+{
+    isDoneWithNavigation = true;
+}
+
+@end
+
+static bool receivedScriptMessage;
+static RetainPtr&lt;WKScriptMessage&gt; lastScriptMessage;
+
+@interface IndexedDBMessageHandler : NSObject &lt;WKScriptMessageHandler&gt;
+@end
+
+@implementation IndexedDBMessageHandler
+
+- (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message
+{
+    receivedScriptMessage = true;
+    lastScriptMessage = message;
+}
+
+@end
+
+TEST(IndexedDB, IndexedDBPersistence)
+{
+    RetainPtr&lt;IndexedDBMessageHandler&gt; handler = adoptNS([[IndexedDBMessageHandler alloc] init]);
+    RetainPtr&lt;WKWebViewConfiguration&gt; configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+    [[configuration userContentController] addScriptMessageHandler:handler.get() name:@&quot;testHandler&quot;];
+
+    RetainPtr&lt;WKWebView&gt; webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
+
+    NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@&quot;IndexedDBPersistence-1&quot; withExtension:@&quot;html&quot; subdirectory:@&quot;TestWebKitAPI.resources&quot;]];
+    [webView loadRequest:request];
+
+    TestWebKitAPI::Util::run(&amp;receivedScriptMessage);
+    receivedScriptMessage = false;
+    RetainPtr&lt;NSString&gt; string1 = (NSString *)[lastScriptMessage body];
+
+    TestWebKitAPI::Util::run(&amp;receivedScriptMessage);
+    receivedScriptMessage = false;
+    RetainPtr&lt;NSString&gt; string2 = (NSString *)[lastScriptMessage body];
+
+    // Ditch this web view (ditching its web process)
+    webView = nil;
+
+    // Terminate the database process
+    [configuration.get().processPool _terminateDatabaseProcess];
+
+    // Make a new web view to finish the test
+    webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
+
+    request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@&quot;IndexedDBPersistence-2&quot; withExtension:@&quot;html&quot; subdirectory:@&quot;TestWebKitAPI.resources&quot;]];
+    [webView loadRequest:request];
+
+    TestWebKitAPI::Util::run(&amp;receivedScriptMessage);
+    receivedScriptMessage = false;
+    RetainPtr&lt;NSString&gt; string3 = (NSString *)[lastScriptMessage body];
+
+    EXPECT_WK_STREQ(@&quot;UpgradeNeeded&quot;, string1.get());
+    EXPECT_WK_STREQ(@&quot;Success&quot;, string2.get());
+    EXPECT_WK_STREQ(@&quot;2 TestObjectStore&quot;, string3.get());
+}
+
+#endif
</ins></span></pre>
</div>
</div>

</body>
</html>