Commit 9460e2b7 authored by jorlow@chromium.org's avatar jorlow@chromium.org

2011-01-27 David Grogan <dgrogan@google.com>

        Reviewed by Jeremy Orlow.

        initial support for close() in indexeddb backend
        https://bugs.webkit.org/show_bug.cgi?id=53150

        * storage/indexeddb/transaction-after-close-expected.txt: Added.
        * storage/indexeddb/transaction-after-close.html: Added.
2011-01-27  David Grogan  <dgrogan@google.com>

        Reviewed by Jeremy Orlow.

        initial support for close() in indexeddb backend
        https://bugs.webkit.org/show_bug.cgi?id=53150

        Test: storage/indexeddb/transaction-after-close.html

        * storage/IDBDatabase.cpp:
        (WebCore::IDBDatabase::IDBDatabase):
        (WebCore::IDBDatabase::transaction):
        (WebCore::IDBDatabase::close):
        * storage/IDBDatabase.h:
        * storage/IDBDatabase.idl:
        * storage/IDBDatabaseBackendImpl.cpp:
        (WebCore::IDBDatabaseBackendImpl::transaction):
        (WebCore::IDBDatabaseBackendImpl::close):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@76820 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 46b465c4
2011-01-27 David Grogan <dgrogan@google.com>
Reviewed by Jeremy Orlow.
initial support for close() in indexeddb backend
https://bugs.webkit.org/show_bug.cgi?id=53150
* storage/indexeddb/transaction-after-close-expected.txt: Added.
* storage/indexeddb/transaction-after-close.html: Added.
2011-01-27 Dirk Schulze <krit@webkit.org>
Reviewed by Nikolas Zimmermann.
Test closing a database connection in IndexedDB.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS 'webkitIndexedDB' in window is true
PASS webkitIndexedDB == null is false
webkitIndexedDB.open('some db name')
PASS 'onsuccess' in result is true
PASS 'onerror' in result is true
PASS 'readyState' in result is true
An event should fire shortly...
openSuccess():
Success event fired:
PASS 'result' in event is true
PASS 'code' in event is false
PASS 'message' in event is false
PASS 'source' in event is true
PASS event.source != null is true
PASS 'onsuccess' in event.target is true
PASS 'onerror' in event.target is true
PASS 'readyState' in event.target is true
PASS event.target.readyState is event.target.DONE
db = event.result
result = db.setVersion('version 1')
Success event fired:
PASS 'result' in event is true
PASS 'code' in event is false
PASS 'message' in event is false
PASS 'source' in event is true
PASS event.source != null is true
PASS 'onsuccess' in event.target is true
PASS 'onerror' in event.target is true
PASS 'readyState' in event.target is true
PASS event.target.readyState is event.target.DONE
Deleted all object stores.
store = db.createObjectStore('store')
request = store.put('x', 'y')
Success event fired:
PASS 'result' in event is true
PASS 'code' in event is false
PASS 'message' in event is false
PASS 'source' in event is true
PASS event.source != null is true
PASS 'onsuccess' in event.target is true
PASS 'onerror' in event.target is true
PASS 'readyState' in event.target is true
PASS event.target.readyState is event.target.DONE
running first transaction
currentTransaction = db.transaction([], webkitIDBTransaction.READ_WRITE)
objectStore.put('a', 'b')
db.close()
Expecting exception from db.transaction([], webkitIDBTransaction.READ_WRITE)
PASS code is webkitIDBDatabaseException.NOT_ALLOWED_ERR
verify that we can reopen the db after calling close
webkitIndexedDB.open('some db name')
PASS 'onsuccess' in result is true
PASS 'onerror' in result is true
PASS 'readyState' in result is true
An event should fire shortly...
Success event fired:
PASS 'result' in event is true
PASS 'code' in event is false
PASS 'message' in event is false
PASS 'source' in event is true
PASS event.source != null is true
PASS 'onsuccess' in event.target is true
PASS 'onerror' in event.target is true
PASS 'readyState' in event.target is true
PASS event.target.readyState is event.target.DONE
second_db = event.result
currentTransaction = second_db.transaction([], webkitIDBTransaction.READ_WRITE)
request = store.put('1', '2')
Success event fired:
PASS 'result' in event is true
PASS 'code' in event is false
PASS 'message' in event is false
PASS 'source' in event is true
PASS event.source != null is true
PASS 'onsuccess' in event.target is true
PASS 'onerror' in event.target is true
PASS 'readyState' in event.target is true
PASS event.target.readyState is event.target.DONE
PASS successfullyParsed is true
TEST COMPLETE
<html>
<head>
<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
<script src="../../fast/js/resources/js-test-pre.js"></script>
<script src="../../fast/js/resources/js-test-post-function.js"></script>
<script src="resources/shared.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script>
description("Test closing a database connection in IndexedDB.");
if (window.layoutTestController)
layoutTestController.waitUntilDone();
function test()
{
shouldBeTrue("'webkitIndexedDB' in window");
shouldBeFalse("webkitIndexedDB == null");
result = evalAndLog("webkitIndexedDB.open('some db name')");
verifyResult(result);
result.onsuccess = openSuccess;
result.onerror = unexpectedErrorCallback;
}
function openSuccess()
{
debug("openSuccess():");
verifySuccessEvent(event);
window.db = evalAndLog("db = event.result");
result = evalAndLog("result = db.setVersion('version 1')");
result.onsuccess = inSetVersion;
result.onerror = unexpectedErrorCallback;
}
function inSetVersion()
{
verifySuccessEvent(event);
deleteAllObjectStores(db, doSetVersionStuff);
}
function doSetVersionStuff()
{
event.result.oncomplete = runFirstRegularTransaction;
event.result.onabort = unexpectedAbortCallback;
store = evalAndLog("store = db.createObjectStore('store')");
request = evalAndLog("request = store.put('x', 'y')");
request.onsuccess = onPutSuccess;
request.onerror = unexpectedErrorCallback;
}
function onPutSuccess()
{
verifySuccessEvent(event);
}
function runFirstRegularTransaction()
{
debug("running first transaction")
currentTransaction = evalAndLog("currentTransaction = db.transaction([], webkitIDBTransaction.READ_WRITE)");
currentTransaction.onabort = unexpectedAbortCallback;
currentTransaction.oncomplete = firstTransactionComplete;
objectStore = currentTransaction.objectStore('store');
result = evalAndLog("objectStore.put('a', 'b')");
result.onerror = unexpectedErrorCallback;
}
function firstTransactionComplete()
{
evalAndLog("db.close()");
evalAndExpectException("db.transaction([], webkitIDBTransaction.READ_WRITE)", "webkitIDBDatabaseException.NOT_ALLOWED_ERR");
debug("")
debug("verify that we can reopen the db after calling close")
result = evalAndLog("webkitIndexedDB.open('some db name')");
verifyResult(result);
result.onsuccess = onSecondOpen
result.onerror = unexpectedErrorCallback;
}
function onSecondOpen() {
verifySuccessEvent(event);
second_db = evalAndLog("second_db = event.result");
currentTransaction = evalAndLog("currentTransaction = second_db.transaction([], webkitIDBTransaction.READ_WRITE)");
store = currentTransaction.objectStore('store');
request = evalAndLog("request = store.put('1', '2')");
request.onsuccess = onFinalPutSuccess;
request.onerror = unexpectedErrorCallback;
currentTransaction.oncomplete = done;
currentTransaction.onabort = unexpectedAbortCallback;
}
function onFinalPutSuccess() {
verifySuccessEvent(event);
}
var successfullyParsed = true;
test();
</script>
</body>
</html>
2011-01-27 David Grogan <dgrogan@google.com>
Reviewed by Jeremy Orlow.
initial support for close() in indexeddb backend
https://bugs.webkit.org/show_bug.cgi?id=53150
Test: storage/indexeddb/transaction-after-close.html
* storage/IDBDatabase.cpp:
(WebCore::IDBDatabase::IDBDatabase):
(WebCore::IDBDatabase::transaction):
(WebCore::IDBDatabase::close):
* storage/IDBDatabase.h:
* storage/IDBDatabase.idl:
* storage/IDBDatabaseBackendImpl.cpp:
(WebCore::IDBDatabaseBackendImpl::transaction):
(WebCore::IDBDatabaseBackendImpl::close):
2011-01-27 Dirk Schulze <krit@webkit.org>
Reviewed by Nikolas Zimmermann.
......@@ -46,6 +46,7 @@ const unsigned long defaultTimeout = 0; // Infinite.
IDBDatabase::IDBDatabase(PassRefPtr<IDBDatabaseBackendInterface> backend)
: m_backend(backend)
, m_noNewTransactions(false)
{
// We pass a reference of this object before it can be adopted.
relaxAdoptionRequirement();
......@@ -109,6 +110,10 @@ PassRefPtr<IDBTransaction> IDBDatabase::transaction(ScriptExecutionContext* cont
ec = IDBDatabaseException::CONSTRAINT_ERR;
return 0;
}
if (m_noNewTransactions) {
ec = IDBDatabaseException::NOT_ALLOWED_ERR;
return 0;
}
// We need to create a new transaction synchronously. Locks are acquired asynchronously. Operations
// can be queued against the transaction at any point. They will start executing as soon as the
......@@ -126,7 +131,7 @@ PassRefPtr<IDBTransaction> IDBDatabase::transaction(ScriptExecutionContext* cont
void IDBDatabase::close()
{
m_backend->close();
m_noNewTransactions = true;
}
} // namespace WebCore
......
......@@ -76,6 +76,8 @@ private:
RefPtr<IDBDatabaseBackendInterface> m_backend;
RefPtr<IDBTransactionBackendInterface> m_setVersionTransaction;
bool m_noNewTransactions;
};
} // namespace WebCore
......
......@@ -40,8 +40,7 @@ module storage {
raises (IDBDatabaseException);
[CallWith=ScriptExecutionContext] IDBTransaction transaction(in [Optional] DOMStringList storeNames, in [Optional] unsigned short mode, in [Optional] unsigned long timeout)
raises (IDBDatabaseException);
// FIXME: Implement.
//void close();
void close();
};
}
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