- Revision
- 126239
- Author
- [email protected]
- Date
- 2012-08-21 18:08:45 -0700 (Tue, 21 Aug 2012)
Log Message
IndexedDB: Fire error at request when abort is called in upgradeneeded
https://bugs.webkit.org/show_bug.cgi?id=94402
Reviewed by Tony Chang.
Source/WebCore:
Tests - updated intversion-abort-in-initial-upgradeneeded-expected.txt
* Modules/indexeddb/IDBDatabaseBackendImpl.cpp:
(WebCore::IDBDatabaseBackendImpl::transactionFinishedAndAbortFired):
(WebCore::IDBDatabaseBackendImpl::transactionFinishedAndCompleteFired):
(WebCore):
(WebCore::IDBDatabaseBackendImpl::runIntVersionChangeTransaction):
Now that second-half open calls don't get abandoned on the queue, we
can ASSERT that there's at most one of them at any time.
* Modules/indexeddb/IDBDatabaseBackendImpl.h:
(IDBDatabaseBackendImpl):
* Modules/indexeddb/IDBRequest.cpp:
(WebCore::IDBRequest::dispatchEvent):
Move setting m_didFireUpgradeNeededEvent before dispatching the event.
If abort is called in the event handler an error event will be
enqueued and ASSERT_WITH_MESSAGE(m_readyState == PENDING ||
m_didFireUpgradeNeededEvent, ...) needs to pass.
* Modules/indexeddb/IDBTransactionBackendImpl.cpp:
(WebCore::IDBTransactionBackendImpl::abort):
(WebCore::IDBTransactionBackendImpl::commit):
LayoutTests:
* storage/indexeddb/intversion-abort-in-initial-upgradeneeded-expected.txt:
Only remaining error in this test is versions not being reset in
memory.
* storage/indexeddb/resources/intversion-abort-in-initial-upgradeneeded.js:
(deleteSuccess):
(upgradeNeeded):
(onAbort):
(onError):
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (126238 => 126239)
--- trunk/LayoutTests/ChangeLog 2012-08-22 01:05:09 UTC (rev 126238)
+++ trunk/LayoutTests/ChangeLog 2012-08-22 01:08:45 UTC (rev 126239)
@@ -1,3 +1,20 @@
+2012-08-21 David Grogan <[email protected]>
+
+ IndexedDB: Fire error at request when abort is called in upgradeneeded
+ https://bugs.webkit.org/show_bug.cgi?id=94402
+
+ Reviewed by Tony Chang.
+
+ * storage/indexeddb/intversion-abort-in-initial-upgradeneeded-expected.txt:
+ Only remaining error in this test is versions not being reset in
+ memory.
+
+ * storage/indexeddb/resources/intversion-abort-in-initial-upgradeneeded.js:
+ (deleteSuccess):
+ (upgradeNeeded):
+ (onAbort):
+ (onError):
+
2012-08-21 Sheriff Bot <[email protected]>
Unreviewed, rolling out r126233.
Modified: trunk/LayoutTests/storage/indexeddb/intversion-abort-in-initial-upgradeneeded-expected.txt (126238 => 126239)
--- trunk/LayoutTests/storage/indexeddb/intversion-abort-in-initial-upgradeneeded-expected.txt 2012-08-22 01:05:09 UTC (rev 126238)
+++ trunk/LayoutTests/storage/indexeddb/intversion-abort-in-initial-upgradeneeded-expected.txt 2012-08-22 01:08:45 UTC (rev 126239)
@@ -9,8 +9,7 @@
indexedDB.deleteDatabase(dbname)
indexedDB.open(dbname, 2)
request._onupgradeneeded_ = upgradeNeeded
-FIXME: This should get an error event of type AbortError
-request._onerror_ = unexpectedErrorCallback
+request._onerror_ = onError
upgradeNeeded():
PASS db.version is 2
@@ -18,6 +17,14 @@
onAbort():
FAIL event.target.db.version should be 0. Was 2.
+PASS request.transaction is non-null.
+
+onError():
+PASS db is event.target.result
+PASS request is event.target
+PASS event.target.error.name is "AbortError"
+FAIL event.target.result.version should be 0. Was 2.
+PASS request.transaction is null
PASS successfullyParsed is true
TEST COMPLETE
Modified: trunk/LayoutTests/storage/indexeddb/resources/intversion-abort-in-initial-upgradeneeded.js (126238 => 126239)
--- trunk/LayoutTests/storage/indexeddb/resources/intversion-abort-in-initial-upgradeneeded.js 2012-08-22 01:05:09 UTC (rev 126238)
+++ trunk/LayoutTests/storage/indexeddb/resources/intversion-abort-in-initial-upgradeneeded.js 2012-08-22 01:08:45 UTC (rev 126239)
@@ -19,16 +19,13 @@
request = evalAndLog("indexedDB.open(dbname, 2)");
request._onsuccess_ = unexpectedSuccessCallback;
evalAndLog("request._onupgradeneeded_ = upgradeNeeded");
- debug("FIXME: This should get an error event of type AbortError");
- evalAndLog("request._onerror_ = unexpectedErrorCallback");
+ evalAndLog("request._onerror_ = onError");
request._onblocked_ = unexpectedBlockedCallback;
}
function upgradeNeeded(evt)
{
- debug("");
- debug("upgradeNeeded():");
- event = evt;
+ preamble(evt);
db = event.target.result;
shouldBe("db.version", "2");
transaction = event.target.transaction;
@@ -39,10 +36,19 @@
function onAbort(evt)
{
- debug("");
- debug("onAbort():");
- event = evt;
+ preamble(evt);
shouldBe("event.target.db.version", "0");
+ shouldBeNonNull("request.transaction");
+}
+
+function onError(evt)
+{
+ preamble(evt);
+ shouldBe("db", "event.target.result");
+ shouldBe("request", "event.target");
+ shouldBeEqualToString("event.target.error.name", "AbortError");
+ shouldBe("event.target.result.version", "0");
+ shouldBeNull("request.transaction");
finishJSTest();
}
Modified: trunk/Source/WebCore/ChangeLog (126238 => 126239)
--- trunk/Source/WebCore/ChangeLog 2012-08-22 01:05:09 UTC (rev 126238)
+++ trunk/Source/WebCore/ChangeLog 2012-08-22 01:08:45 UTC (rev 126239)
@@ -1,3 +1,33 @@
+2012-08-21 David Grogan <[email protected]>
+
+ IndexedDB: Fire error at request when abort is called in upgradeneeded
+ https://bugs.webkit.org/show_bug.cgi?id=94402
+
+ Reviewed by Tony Chang.
+
+ Tests - updated intversion-abort-in-initial-upgradeneeded-expected.txt
+
+ * Modules/indexeddb/IDBDatabaseBackendImpl.cpp:
+ (WebCore::IDBDatabaseBackendImpl::transactionFinishedAndAbortFired):
+ (WebCore::IDBDatabaseBackendImpl::transactionFinishedAndCompleteFired):
+ (WebCore):
+ (WebCore::IDBDatabaseBackendImpl::runIntVersionChangeTransaction):
+ Now that second-half open calls don't get abandoned on the queue, we
+ can ASSERT that there's at most one of them at any time.
+
+ * Modules/indexeddb/IDBDatabaseBackendImpl.h:
+ (IDBDatabaseBackendImpl):
+ * Modules/indexeddb/IDBRequest.cpp:
+ (WebCore::IDBRequest::dispatchEvent):
+ Move setting m_didFireUpgradeNeededEvent before dispatching the event.
+ If abort is called in the event handler an error event will be
+ enqueued and ASSERT_WITH_MESSAGE(m_readyState == PENDING ||
+ m_didFireUpgradeNeededEvent, ...) needs to pass.
+
+ * Modules/indexeddb/IDBTransactionBackendImpl.cpp:
+ (WebCore::IDBTransactionBackendImpl::abort):
+ (WebCore::IDBTransactionBackendImpl::commit):
+
2012-08-21 Sheriff Bot <[email protected]>
Unreviewed, rolling out r126233.
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.cpp (126238 => 126239)
--- trunk/Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.cpp 2012-08-22 01:05:09 UTC (rev 126238)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.cpp 2012-08-22 01:08:45 UTC (rev 126239)
@@ -320,17 +320,28 @@
}
}
-void IDBDatabaseBackendImpl::transactionFinishedAndEventsFired(PassRefPtr<IDBTransactionBackendImpl> prpTransaction)
+void IDBDatabaseBackendImpl::transactionFinishedAndAbortFired(PassRefPtr<IDBTransactionBackendImpl> prpTransaction)
{
RefPtr<IDBTransactionBackendImpl> transaction = prpTransaction;
if (transaction->mode() == IDBTransaction::VERSION_CHANGE) {
// If this was an open-with-version call, there will be a "second
// half" open call waiting for us in processPendingCalls.
// FIXME: When we no longer support setVersion, assert such a thing.
+ if (m_pendingSecondHalfOpenWithVersionCalls.size() == 1) {
+ RefPtr<PendingOpenWithVersionCall> pendingOpenWithVersionCall = m_pendingSecondHalfOpenWithVersionCalls.takeFirst();
+ pendingOpenWithVersionCall->callbacks()->onError(IDBDatabaseError::create(IDBDatabaseException::IDB_ABORT_ERR, "Version change transaction was aborted in upgradeneeded event handler."));
+ }
processPendingCalls();
}
}
+void IDBDatabaseBackendImpl::transactionFinishedAndCompleteFired(PassRefPtr<IDBTransactionBackendImpl> prpTransaction)
+{
+ RefPtr<IDBTransactionBackendImpl> transaction = prpTransaction;
+ if (transaction->mode() == IDBTransaction::VERSION_CHANGE)
+ processPendingCalls();
+}
+
int32_t IDBDatabaseBackendImpl::connectionCount()
{
return m_databaseCallbacksSet.size() + m_pendingConnectionCount;
@@ -486,6 +497,7 @@
ASSERT_NOT_REACHED();
ec = IDBDatabaseException::TRANSACTION_INACTIVE_ERR;
}
+ ASSERT_WITH_MESSAGE(!m_pendingSecondHalfOpenWithVersionCalls.size(), "m_pendingSecondHalfOpenWithVersionCalls.size = %zu", m_pendingSecondHalfOpenWithVersionCalls.size());
m_pendingSecondHalfOpenWithVersionCalls.append(PendingOpenWithVersionCall::create(callbacks, requestedVersion));
}
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.h (126238 => 126239)
--- trunk/Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.h 2012-08-22 01:05:09 UTC (rev 126238)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.h 2012-08-22 01:08:45 UTC (rev 126239)
@@ -72,7 +72,8 @@
IDBTransactionCoordinator* transactionCoordinator() const { return m_transactionCoordinator.get(); }
void transactionStarted(PassRefPtr<IDBTransactionBackendImpl>);
void transactionFinished(PassRefPtr<IDBTransactionBackendImpl>);
- void transactionFinishedAndEventsFired(PassRefPtr<IDBTransactionBackendImpl>);
+ void transactionFinishedAndCompleteFired(PassRefPtr<IDBTransactionBackendImpl>);
+ void transactionFinishedAndAbortFired(PassRefPtr<IDBTransactionBackendImpl>);
private:
IDBDatabaseBackendImpl(const String& name, IDBBackingStore* database, IDBTransactionCoordinator*, IDBFactoryBackendImpl*, const String& uniqueIdentifier);
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBRequest.cpp (126238 => 126239)
--- trunk/Source/WebCore/Modules/indexeddb/IDBRequest.cpp 2012-08-22 01:05:09 UTC (rev 126238)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBRequest.cpp 2012-08-22 01:08:45 UTC (rev 126239)
@@ -469,6 +469,11 @@
cursorToNotify->setValueReady(m_cursorKey.release(), m_cursorPrimaryKey.release(), m_cursorValue.release());
}
+ if (event->type() == eventNames().upgradeneededEvent) {
+ ASSERT(!m_didFireUpgradeNeededEvent);
+ m_didFireUpgradeNeededEvent = true;
+ }
+
// FIXME: When we allow custom event dispatching, this will probably need to change.
ASSERT_WITH_MESSAGE(event->type() == eventNames().successEvent || event->type() == eventNames().errorEvent || event->type() == eventNames().blockedEvent || event->type() == eventNames().upgradeneededEvent, "event type was %s", event->type().string().utf8().data());
const bool setTransactionActive = m_transaction && (event->type() == eventNames().successEvent || event->type() == eventNames().upgradeneededEvent || (event->type() == eventNames().errorEvent && m_errorCode != IDBDatabaseException::IDB_ABORT_ERR));
@@ -483,11 +488,6 @@
if (cursorToNotify)
cursorToNotify->postSuccessHandlerCallback();
- if (event->type() == eventNames().upgradeneededEvent) {
- ASSERT(!m_didFireUpgradeNeededEvent);
- m_didFireUpgradeNeededEvent = true;
- }
-
if (m_transaction) {
if (event->type() == eventNames().errorEvent && dontPreventDefault && !m_requestAborted) {
m_transaction->setError(m_error);
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBTransactionBackendImpl.cpp (126238 => 126239)
--- trunk/Source/WebCore/Modules/indexeddb/IDBTransactionBackendImpl.cpp 2012-08-22 01:05:09 UTC (rev 126238)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBTransactionBackendImpl.cpp 2012-08-22 01:08:45 UTC (rev 126239)
@@ -151,6 +151,8 @@
if (m_callbacks)
m_callbacks->onAbort();
+ m_database->transactionFinishedAndAbortFired(this);
+
m_database = 0;
}
@@ -232,13 +234,14 @@
m_database->transactionCoordinator()->didFinishTransaction(this);
m_database->transactionFinished(this);
- if (committed)
+ if (committed) {
m_callbacks->onComplete();
- else
+ m_database->transactionFinishedAndCompleteFired(this);
+ } else {
m_callbacks->onAbort();
+ m_database->transactionFinishedAndAbortFired(this);
+ }
- m_database->transactionFinishedAndEventsFired(this);
-
m_database = 0;
}