<!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>[194587] trunk</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/194587">194587</a></dd>
<dt>Author</dt> <dd>beidson@apple.com</dd>
<dt>Date</dt> <dd>2016-01-05 09:44:50 -0800 (Tue, 05 Jan 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Modern IDB: Transactions from a previous page can leak forward to the next.
https://bugs.webkit.org/show_bug.cgi?id=152698

Reviewed by Alex Christensen.

Source/WebCore:

Test: storage/indexeddb/modern/transactions-stop-on-navigation.html

This patch is mostly about actually implementing IDBDatabase::stop and IDBTransaction::stop.
Most of the rest of the scattered changes are about cleaning up now-incorrect ASSERTs.

* Modules/indexeddb/client/IDBDatabaseImpl.cpp:
(WebCore::IDBClient::IDBDatabase::close):
(WebCore::IDBClient::IDBDatabase::maybeCloseInServer):
(WebCore::IDBClient::IDBDatabase::stop):
(WebCore::IDBClient::IDBDatabase::startVersionChangeTransaction):
(WebCore::IDBClient::IDBDatabase::didAbortTransaction):
* Modules/indexeddb/client/IDBDatabaseImpl.h:

* Modules/indexeddb/client/IDBOpenDBRequestImpl.cpp:
(WebCore::IDBClient::IDBOpenDBRequest::requestCompleted):

* Modules/indexeddb/client/IDBRequestImpl.h:

* Modules/indexeddb/client/IDBTransactionImpl.cpp:
(WebCore::IDBClient::IDBTransaction::IDBTransaction):
(WebCore::IDBClient::IDBTransaction::stop):
(WebCore::IDBClient::IDBTransaction::abortOnServerAndCancelRequests):

* Modules/indexeddb/server/UniqueIDBDatabase.cpp:
(WebCore::IDBServer::UniqueIDBDatabase::performCurrentDeleteOperation):
(WebCore::IDBServer::UniqueIDBDatabase::didPerformAbortTransaction):

LayoutTests:

* storage/indexeddb/modern/resources/transactions-stop-on-navigation-2.html: Added.
* storage/indexeddb/modern/resources/transactions-stop-on-navigation.js: Added.
* storage/indexeddb/modern/transactions-stop-on-navigation-expected.txt: Added.
* storage/indexeddb/modern/transactions-stop-on-navigation.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbclientIDBDatabaseImplcpp">trunk/Source/WebCore/Modules/indexeddb/client/IDBDatabaseImpl.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbclientIDBDatabaseImplh">trunk/Source/WebCore/Modules/indexeddb/client/IDBDatabaseImpl.h</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbclientIDBOpenDBRequestImplcpp">trunk/Source/WebCore/Modules/indexeddb/client/IDBOpenDBRequestImpl.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbclientIDBRequestImplh">trunk/Source/WebCore/Modules/indexeddb/client/IDBRequestImpl.h</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbclientIDBTransactionImplcpp">trunk/Source/WebCore/Modules/indexeddb/client/IDBTransactionImpl.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbserverUniqueIDBDatabasecpp">trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsstorageindexeddbmodernresourcestransactionsstoponnavigation2html">trunk/LayoutTests/storage/indexeddb/modern/resources/transactions-stop-on-navigation-2.html</a></li>
<li><a href="#trunkLayoutTestsstorageindexeddbmodernresourcestransactionsstoponnavigationjs">trunk/LayoutTests/storage/indexeddb/modern/resources/transactions-stop-on-navigation.js</a></li>
<li><a href="#trunkLayoutTestsstorageindexeddbmoderntransactionsstoponnavigationexpectedtxt">trunk/LayoutTests/storage/indexeddb/modern/transactions-stop-on-navigation-expected.txt</a></li>
<li><a href="#trunkLayoutTestsstorageindexeddbmoderntransactionsstoponnavigationhtml">trunk/LayoutTests/storage/indexeddb/modern/transactions-stop-on-navigation.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (194586 => 194587)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-01-05 17:31:46 UTC (rev 194586)
+++ trunk/LayoutTests/ChangeLog        2016-01-05 17:44:50 UTC (rev 194587)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2016-01-05  Brady Eidson  &lt;beidson@apple.com&gt;
+
+        Modern IDB: Transactions from a previous page can leak forward to the next.
+        https://bugs.webkit.org/show_bug.cgi?id=152698
+
+        Reviewed by Alex Christensen.
+
+        * storage/indexeddb/modern/resources/transactions-stop-on-navigation-2.html: Added.
+        * storage/indexeddb/modern/resources/transactions-stop-on-navigation.js: Added.
+        * storage/indexeddb/modern/transactions-stop-on-navigation-expected.txt: Added.
+        * storage/indexeddb/modern/transactions-stop-on-navigation.html: Added.
+
</ins><span class="cx"> 2016-01-05  Youenn Fablet  &lt;youenn.fablet@crf.canon.fr&gt;
</span><span class="cx"> 
</span><span class="cx">         Marking imported/w3c/web-platform-tests/html/dom/dynamic-markup-insertion/opening-the-input-stream/010.html
</span></span></pre></div>
<a id="trunkLayoutTestsstorageindexeddbmodernresourcestransactionsstoponnavigation2html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/storage/indexeddb/modern/resources/transactions-stop-on-navigation-2.html (0 => 194587)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/storage/indexeddb/modern/resources/transactions-stop-on-navigation-2.html                                (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/modern/resources/transactions-stop-on-navigation-2.html        2016-01-05 17:44:50 UTC (rev 194587)
</span><span class="lines">@@ -0,0 +1,40 @@
</span><ins>+Makes sure transactions stop on navigation to a new page.&lt;br&gt;
+If the previous page's transaction is blindly charging forward, this test will probably timeout.&lt;br&gt;
+If the previous page's connection/transactions did not clean up properly, the delete request in this test will incorrectly be blocked.&lt;br&gt;
+If every thing is peachy keen, the delete request in this test will correctly succeed.&lt;br&gt;
+&lt;div id=&quot;logger&quot;&gt;&lt;/div&gt;
+&lt;script&gt;
+
+function log(msg)
+{
+    document.getElementById(&quot;logger&quot;).innerHTML += msg + &quot;&lt;br&gt;&quot;;
+}
+
+function done()
+{
+    log(&quot;Done.&quot;);
+    if (window.testRunner)
+        testRunner.notifyDone();
+}
+
+// Calling &quot;deleteDatabase&quot; while there are already open connections causes those connections to first receive a versionChange event.
+// If the transaction/connection from the previous page is still active, then deleting the database will timeout because the previous connection will never be able to respond to the version change event.
+// Deleting the database should immediately succeed.
+
+var request = window.indexedDB.deleteDatabase('transactions-stop-on-navigation.html');
+request.onsuccess = deleteSuccess;
+request.onblocked = deleteBlocked;
+
+function deleteSuccess()
+{
+    log(&quot;Delete request was successful.&quot;);
+    done();
+}
+
+function deleteBlocked()
+{
+    log(&quot;Delete request was blocked - it should not have been.&quot;);
+    done();
+}
+
+&lt;/script&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsstorageindexeddbmodernresourcestransactionsstoponnavigationjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/storage/indexeddb/modern/resources/transactions-stop-on-navigation.js (0 => 194587)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/storage/indexeddb/modern/resources/transactions-stop-on-navigation.js                                (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/modern/resources/transactions-stop-on-navigation.js        2016-01-05 17:44:50 UTC (rev 194587)
</span><span class="lines">@@ -0,0 +1,28 @@
</span><ins>+description(&quot;Makes sure transactions stop on navigation to a new page.&quot;);
+
+indexedDBTest(prepareDatabase, openSuccess);
+
+function prepareDatabase()
+{
+    evalAndLog(&quot;connection = event.target.result;&quot;);
+
+    evalAndLog(&quot;store = connection.createObjectStore('name');&quot;);
+    evalAndLog(&quot;index = store.createIndex('name', 'foo');&quot;);
+}
+
+function openSuccess()
+{
+    evalAndLog(&quot;connection.close();&quot;);
+    evalAndLog(&quot;request = window.indexedDB.open('transactions-stop-on-navigation.html');&quot;);
+    evalAndLog(&quot;request.onsuccess = opened;&quot;);
+}
+
+function opened(event)
+{
+    evalAndLog(&quot;connection = event.target.result;&quot;);
+    evalAndLog(&quot;transaction = connection.transaction('name', 'readwrite');&quot;);
+    for (var i = 0; i &lt; 100; ++i)
+        evalAndLog(&quot;transaction.objectStore('name').put('bar', 'foo');&quot;);
+    
+    window.location.href = &quot;resources/transactions-stop-on-navigation-2.html&quot;;
+}
</ins></span></pre></div>
<a id="trunkLayoutTestsstorageindexeddbmoderntransactionsstoponnavigationexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/storage/indexeddb/modern/transactions-stop-on-navigation-expected.txt (0 => 194587)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/storage/indexeddb/modern/transactions-stop-on-navigation-expected.txt                                (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/modern/transactions-stop-on-navigation-expected.txt        2016-01-05 17:44:50 UTC (rev 194587)
</span><span class="lines">@@ -0,0 +1,7 @@
</span><ins>+Makes sure transactions stop on navigation to a new page.
+If the previous page's transaction is blindly charging forward, this test will probably timeout.
+If the previous page's connection/transactions did not clean up properly, the delete request in this test will incorrectly be blocked.
+If every thing is peachy keen, the delete request in this test will correctly succeed.
+Delete request was successful.
+Done.
+
</ins></span></pre></div>
<a id="trunkLayoutTestsstorageindexeddbmoderntransactionsstoponnavigationhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/storage/indexeddb/modern/transactions-stop-on-navigation.html (0 => 194587)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/storage/indexeddb/modern/transactions-stop-on-navigation.html                                (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/modern/transactions-stop-on-navigation.html        2016-01-05 17:44:50 UTC (rev 194587)
</span><span class="lines">@@ -0,0 +1,9 @@
</span><ins>+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../../resources/js-test.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../resources/shared.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;script src=&quot;resources/transactions-stop-on-navigation.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (194586 => 194587)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-01-05 17:31:46 UTC (rev 194586)
+++ trunk/Source/WebCore/ChangeLog        2016-01-05 17:44:50 UTC (rev 194587)
</span><span class="lines">@@ -1,3 +1,37 @@
</span><ins>+2016-01-05  Brady Eidson  &lt;beidson@apple.com&gt;
+
+        Modern IDB: Transactions from a previous page can leak forward to the next.
+        https://bugs.webkit.org/show_bug.cgi?id=152698
+
+        Reviewed by Alex Christensen.
+
+        Test: storage/indexeddb/modern/transactions-stop-on-navigation.html
+
+        This patch is mostly about actually implementing IDBDatabase::stop and IDBTransaction::stop.
+        Most of the rest of the scattered changes are about cleaning up now-incorrect ASSERTs.
+
+        * Modules/indexeddb/client/IDBDatabaseImpl.cpp:
+        (WebCore::IDBClient::IDBDatabase::close):
+        (WebCore::IDBClient::IDBDatabase::maybeCloseInServer):
+        (WebCore::IDBClient::IDBDatabase::stop):
+        (WebCore::IDBClient::IDBDatabase::startVersionChangeTransaction):
+        (WebCore::IDBClient::IDBDatabase::didAbortTransaction):
+        * Modules/indexeddb/client/IDBDatabaseImpl.h:
+        
+        * Modules/indexeddb/client/IDBOpenDBRequestImpl.cpp:
+        (WebCore::IDBClient::IDBOpenDBRequest::requestCompleted):
+        
+        * Modules/indexeddb/client/IDBRequestImpl.h:
+        
+        * Modules/indexeddb/client/IDBTransactionImpl.cpp:
+        (WebCore::IDBClient::IDBTransaction::IDBTransaction):
+        (WebCore::IDBClient::IDBTransaction::stop):
+        (WebCore::IDBClient::IDBTransaction::abortOnServerAndCancelRequests):
+        
+        * Modules/indexeddb/server/UniqueIDBDatabase.cpp:
+        (WebCore::IDBServer::UniqueIDBDatabase::performCurrentDeleteOperation):
+        (WebCore::IDBServer::UniqueIDBDatabase::didPerformAbortTransaction):
+
</ins><span class="cx"> 2016-01-05  Zan Dobersek  &lt;zdobersek@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed. Attempting to fix the AppleWin build after r194577.
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbclientIDBDatabaseImplcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBDatabaseImpl.cpp (194586 => 194587)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/client/IDBDatabaseImpl.cpp        2016-01-05 17:31:46 UTC (rev 194586)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBDatabaseImpl.cpp        2016-01-05 17:44:50 UTC (rev 194587)
</span><span class="lines">@@ -223,12 +223,16 @@
</span><span class="cx"> 
</span><span class="cx"> void IDBDatabase::close()
</span><span class="cx"> {
</span><ins>+    LOG(IndexedDB, &quot;IDBDatabase::close - %&quot; PRIu64, m_databaseConnectionIdentifier);
+
</ins><span class="cx">     m_closePending = true;
</span><span class="cx">     maybeCloseInServer();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void IDBDatabase::maybeCloseInServer()
</span><span class="cx"> {
</span><ins>+    LOG(IndexedDB, &quot;IDBDatabase::maybeCloseInServer - %&quot; PRIu64, m_databaseConnectionIdentifier);
+
</ins><span class="cx">     if (m_closedInServer)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="lines">@@ -254,12 +258,33 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void IDBDatabase::stop()
+{
+    LOG(IndexedDB, &quot;IDBDatabase::stop - %&quot; PRIu64, m_databaseConnectionIdentifier);
+
+    Vector&lt;IDBResourceIdentifier&gt; transactionIdentifiers;
+    transactionIdentifiers.reserveInitialCapacity(m_activeTransactions.size());
+
+    for (auto&amp; id : m_activeTransactions.keys())
+        transactionIdentifiers.uncheckedAppend(id);
+
+    for (auto&amp; id : transactionIdentifiers) {
+        IDBTransaction* transaction = m_activeTransactions.get(id);
+        if (transaction)
+            transaction-&gt;stop();
+    }
+
+    close();
+}
+
</ins><span class="cx"> Ref&lt;IDBTransaction&gt; IDBDatabase::startVersionChangeTransaction(const IDBTransactionInfo&amp; info, IDBOpenDBRequest&amp; request)
</span><span class="cx"> {
</span><span class="cx">     LOG(IndexedDB, &quot;IDBDatabase::startVersionChangeTransaction %s&quot;, info.identifier().loggingString().utf8().data());
</span><span class="cx"> 
</span><span class="cx">     ASSERT(!m_versionChangeTransaction);
</span><span class="cx">     ASSERT(info.mode() == IndexedDB::TransactionMode::VersionChange);
</span><ins>+    ASSERT(!m_closePending);
+    ASSERT(scriptExecutionContext());
</ins><span class="cx"> 
</span><span class="cx">     Ref&lt;IDBTransaction&gt; transaction = IDBTransaction::create(*this, info, request);
</span><span class="cx">     m_versionChangeTransaction = &amp;transaction.get();
</span><span class="lines">@@ -323,8 +348,7 @@
</span><span class="cx">         ASSERT(transaction.originalDatabaseInfo());
</span><span class="cx">         ASSERT(m_info.version() == transaction.originalDatabaseInfo()-&gt;version());
</span><span class="cx">         m_closePending = true;
</span><del>-        m_closedInServer = true;
-        m_serverConnection-&gt;databaseConnectionClosed(*this);
</del><ins>+        maybeCloseInServer();
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     didCommitOrAbortTransaction(transaction);
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbclientIDBDatabaseImplh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBDatabaseImpl.h (194586 => 194587)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/client/IDBDatabaseImpl.h        2016-01-05 17:31:46 UTC (rev 194586)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBDatabaseImpl.h        2016-01-05 17:44:50 UTC (rev 194587)
</span><span class="lines">@@ -68,6 +68,7 @@
</span><span class="cx"> 
</span><span class="cx">     virtual const char* activeDOMObjectName() const override final;
</span><span class="cx">     virtual bool canSuspendForDocumentSuspension() const override final;
</span><ins>+    virtual void stop() override final;
</ins><span class="cx"> 
</span><span class="cx">     const IDBDatabaseInfo&amp; info() const { return m_info; }
</span><span class="cx">     uint64_t databaseConnectionIdentifier() const { return m_databaseConnectionIdentifier; }
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbclientIDBOpenDBRequestImplcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBOpenDBRequestImpl.cpp (194586 => 194587)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/client/IDBOpenDBRequestImpl.cpp        2016-01-05 17:31:46 UTC (rev 194586)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBOpenDBRequestImpl.cpp        2016-01-05 17:44:50 UTC (rev 194587)
</span><span class="lines">@@ -162,6 +162,9 @@
</span><span class="cx"> {
</span><span class="cx">     LOG(IndexedDB, &quot;IDBOpenDBRequest::requestCompleted&quot;);
</span><span class="cx"> 
</span><ins>+    if (m_contextStopped)
+        return;
+
</ins><span class="cx">     switch (data.type()) {
</span><span class="cx">     case IDBResultType::Error:
</span><span class="cx">         onError(data);
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbclientIDBRequestImplh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBRequestImpl.h (194586 => 194587)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/client/IDBRequestImpl.h        2016-01-05 17:31:46 UTC (rev 194586)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBRequestImpl.h        2016-01-05 17:44:50 UTC (rev 194587)
</span><span class="lines">@@ -129,6 +129,7 @@
</span><span class="cx">     RefPtr&lt;DOMError&gt; m_domError;
</span><span class="cx">     IDBError m_idbError;
</span><span class="cx">     IndexedDB::RequestType m_requestType = { IndexedDB::RequestType::Other };
</span><ins>+    bool m_contextStopped { false };
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     void onError();
</span><span class="lines">@@ -143,8 +144,6 @@
</span><span class="cx">     IndexedDB::IndexRecordType m_requestedIndexRecordType;
</span><span class="cx"> 
</span><span class="cx">     RefPtr&lt;IDBCursor&gt; m_pendingCursor;
</span><del>-
-    bool m_contextStopped { false };
</del><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace IDBClient
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbclientIDBTransactionImplcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBTransactionImpl.cpp (194586 => 194587)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/client/IDBTransactionImpl.cpp        2016-01-05 17:31:46 UTC (rev 194586)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBTransactionImpl.cpp        2016-01-05 17:44:50 UTC (rev 194587)
</span><span class="lines">@@ -67,6 +67,8 @@
</span><span class="cx">     , m_openDBRequest(request)
</span><span class="cx"> 
</span><span class="cx"> {
</span><ins>+    LOG(IndexedDB, &quot;IDBTransaction::IDBTransaction - %s&quot;, m_info.loggingString().utf8().data());
+
</ins><span class="cx">     relaxAdoptionRequirement();
</span><span class="cx"> 
</span><span class="cx">     if (m_info.mode() == IndexedDB::TransactionMode::VersionChange) {
</span><span class="lines">@@ -211,9 +213,7 @@
</span><span class="cx">     for (auto&amp; operation : m_abortQueue)
</span><span class="cx">         operation-&gt;completed(IDBResultData::error(operation-&gt;identifier(), error));
</span><span class="cx"> 
</span><del>-    // Since we're aborting, this abortOnServerAndCancelRequests() operation should be the only
-    // in-progress operation, and it should be impossible to have queued any further operations.
-    ASSERT(m_transactionOperationMap.size() == 1);
</del><ins>+    // Since we're aborting, it should be impossible to have queued any further operations.
</ins><span class="cx">     ASSERT(m_transactionOperationQueue.isEmpty());
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -234,8 +234,20 @@
</span><span class="cx"> 
</span><span class="cx"> void IDBTransaction::stop()
</span><span class="cx"> {
</span><del>-    ASSERT(!m_contextStopped);
</del><ins>+    LOG(IndexedDB, &quot;IDBTransaction::stop&quot;);
+
+    // IDBDatabase::stop() calls IDBTransaction::stop() for each of its active transactions.
+    // Since the order of calling ActiveDOMObject::stop() is random, we might already have been stopped.
+    if (m_contextStopped)
+        return;
+
</ins><span class="cx">     m_contextStopped = true;
</span><ins>+
+    if (isFinishedOrFinishing())
+        return;
+
+    ExceptionCodeWithMessage ec;
+    abort(ec);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool IDBTransaction::isActive() const
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbserverUniqueIDBDatabasecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp (194586 => 194587)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp        2016-01-05 17:31:46 UTC (rev 194586)
+++ trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp        2016-01-05 17:44:50 UTC (rev 194587)
</span><span class="lines">@@ -178,8 +178,14 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    // Even though we have no open database connections, we might have close-pending database connections
+    // that are waiting on transactions to complete.
+    if (!m_inProgressTransactions.isEmpty()) {
+        ASSERT(!m_closePendingDatabaseConnections.isEmpty());
+        return;
+    }
+
</ins><span class="cx">     ASSERT(!hasAnyPendingCallbacks());
</span><del>-    ASSERT(m_inProgressTransactions.isEmpty());
</del><span class="cx">     ASSERT(m_pendingTransactions.isEmpty());
</span><span class="cx">     ASSERT(m_openDatabaseConnections.isEmpty());
</span><span class="cx"> 
</span><span class="lines">@@ -975,7 +981,7 @@
</span><span class="cx">     LOG(IndexedDB, &quot;(main) UniqueIDBDatabase::didPerformAbortTransaction&quot;);
</span><span class="cx"> 
</span><span class="cx">     if (m_versionChangeTransaction &amp;&amp; m_versionChangeTransaction-&gt;info().identifier() == transactionIdentifier) {
</span><del>-        ASSERT(&amp;m_versionChangeTransaction-&gt;databaseConnection() == m_versionChangeDatabaseConnection);
</del><ins>+        ASSERT(!m_versionChangeDatabaseConnection || &amp;m_versionChangeTransaction-&gt;databaseConnection() == m_versionChangeDatabaseConnection);
</ins><span class="cx">         ASSERT(m_versionChangeTransaction-&gt;originalDatabaseInfo());
</span><span class="cx">         m_databaseInfo = std::make_unique&lt;IDBDatabaseInfo&gt;(*m_versionChangeTransaction-&gt;originalDatabaseInfo());
</span><span class="cx">     }
</span></span></pre>
</div>
</div>

</body>
</html>