Commit 04aa1987 authored by dgrogan@chromium.org's avatar dgrogan@chromium.org
Browse files

IndexedDB: Don't wedge if page reloads with pending upgradeneeded

https://bugs.webkit.org/show_bug.cgi?id=98091

Reviewed by Tony Chang.

Source/WebCore:

Test: storage/indexeddb/dont-wedge.html

* Modules/indexeddb/IDBOpenDBRequest.cpp:
(WebCore::IDBOpenDBRequest::onUpgradeNeeded):
This got the same treatment as IDBRequest::onSuccess(Transaction).
Explicitly tell the backend objects that they are going away so that
m_runningVersionChangeTransaction is cleared and connectionCount()
decreases.

LayoutTests:

dont-wedge.js was derived from
transaction-coordination-across-databases.js.

This would have passed in DRT without this patch, but not in
content_shell.

* storage/indexeddb/dont-wedge-expected.txt: Added.
* storage/indexeddb/dont-wedge.html: Added.
* storage/indexeddb/resources/dont-wedge.js: Added.
(test):
(deleteDatabase1.request.onblocked):
(deleteDatabase1):
(deleteDatabase2):
(isAfterReload):
(reload):
(openDatabase1.request.onupgradeneeded):
(openDatabase1.request.onsuccess):
(openDatabase1):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@130199 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 654d3b67
2012-10-02 David Grogan <dgrogan@chromium.org>
IndexedDB: Don't wedge if page reloads with pending upgradeneeded
https://bugs.webkit.org/show_bug.cgi?id=98091
Reviewed by Tony Chang.
dont-wedge.js was derived from
transaction-coordination-across-databases.js.
This would have passed in DRT without this patch, but not in
content_shell.
* storage/indexeddb/dont-wedge-expected.txt: Added.
* storage/indexeddb/dont-wedge.html: Added.
* storage/indexeddb/resources/dont-wedge.js: Added.
(test):
(deleteDatabase1.request.onblocked):
(deleteDatabase1):
(deleteDatabase2):
(isAfterReload):
(reload):
(openDatabase1.request.onupgradeneeded):
(openDatabase1.request.onsuccess):
(openDatabase1):
2012-10-02 David Grogan <dgrogan@chromium.org>
 
http/tests/inspector/indexeddb/database-structure.html start to crash after r124675
Check that a page reloaded during an in-flight upgradeneeded event doesn't hang.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.msIndexedDB || self.OIndexedDB;
dbname = "dont-wedge.html"
dbname1 = dbname + '1'
dbname2 = dbname + '2'
deleteDatabase1():
indexedDB.deleteDatabase(dbname1)
In a multi process implementation this deleteDatabase may be blocked temporarily, so we don't check for either the presence or absence of a blocked event.
deleteDatabase2():
indexedDB.deleteDatabase(dbname2)
openDatabase1():
indexedDB.open(dbname1, 1)
openOnUpgradeNeeded1():
db1 = event.target.result
store1 = db1.createObjectStore('store')
store1.put(0, 0)
openOnSuccess1():
PASS isAfterReload() is true
PASS successfullyParsed is true
TEST COMPLETE
<html>
<head>
<script src="../../fast/js/resources/js-test-pre.js"></script>
<script src="resources/shared.js"></script>
</head>
<body>
<script src="resources/dont-wedge.js"></script>
<script src="../../fast/js/resources/js-test-post.js"></script>
</body>
</html>
if (this.importScripts) {
importScripts('../../../fast/js/resources/js-test-pre.js');
importScripts('shared.js');
}
description("Check that a page reloaded during an in-flight upgradeneeded event doesn't hang.");
function test()
{
removeVendorPrefixes();
setDBNameFromPath();
evalAndLog("dbname1 = dbname + '1'");
evalAndLog("dbname2 = dbname + '2'");
deleteDatabase1();
}
function deleteDatabase1()
{
preamble();
request = evalAndLog("indexedDB.deleteDatabase(dbname1)");
request.onerror = unexpectedBlockedCallback;
if (!isAfterReload())
request.onblocked = unexpectedBlockedCallback;
else
debug("In a multi process implementation this deleteDatabase may be blocked temporarily, so we don't check for either the presence or absence of a blocked event.");
request.onsuccess = deleteDatabase2;
}
function deleteDatabase2()
{
preamble();
request = evalAndLog("indexedDB.deleteDatabase(dbname2)");
request.onerror = unexpectedBlockedCallback;
request.onblocked = unexpectedBlockedCallback;
request.onsuccess = openDatabase1;
}
function isAfterReload()
{
return document.location.search == "?second";
}
function reload()
{
document.location += "?second";
}
function openDatabase1()
{
preamble();
request = evalAndLog("indexedDB.open(dbname1, 1)");
request.onerror = unexpectedBlockedCallback;
request.onblocked = unexpectedBlockedCallback;
request.onupgradeneeded = function openOnUpgradeNeeded1(evt) {
preamble(evt);
evalAndLog("db1 = event.target.result");
evalAndLog("store1 = db1.createObjectStore('store')");
evalAndLog("store1.put(0, 0)");
};
request.onsuccess = function openOnSuccess1(evt) {
preamble(evt);
shouldBeTrue("isAfterReload()");
finishJSTest();
};
if (!isAfterReload())
reload();
}
test();
2012-10-02 David Grogan <dgrogan@chromium.org>
IndexedDB: Don't wedge if page reloads with pending upgradeneeded
https://bugs.webkit.org/show_bug.cgi?id=98091
Reviewed by Tony Chang.
Test: storage/indexeddb/dont-wedge.html
* Modules/indexeddb/IDBOpenDBRequest.cpp:
(WebCore::IDBOpenDBRequest::onUpgradeNeeded):
This got the same treatment as IDBRequest::onSuccess(Transaction).
Explicitly tell the backend objects that they are going away so that
m_runningVersionChangeTransaction is cleared and connectionCount()
decreases.
2012-10-02 David Grogan <dgrogan@chromium.org>
 
http/tests/inspector/indexeddb/database-structure.html start to crash after r124675
......@@ -71,6 +71,13 @@ void IDBOpenDBRequest::onBlocked(int64_t oldVersion)
void IDBOpenDBRequest::onUpgradeNeeded(int64_t oldVersion, PassRefPtr<IDBTransactionBackendInterface> prpTransactionBackend, PassRefPtr<IDBDatabaseBackendInterface> prpDatabaseBackend)
{
IDB_TRACE("IDBOpenDBRequest::onUpgradeNeeded()");
if (m_contextStopped || !scriptExecutionContext()) {
RefPtr<IDBTransactionBackendInterface> transaction = prpTransactionBackend;
transaction->abort();
RefPtr<IDBDatabaseBackendInterface> db = prpDatabaseBackend;
db->close(m_databaseCallbacks);
return;
}
if (!shouldEnqueueEvent())
return;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment