summaryrefslogtreecommitdiffstats
path: root/content/test/data/indexeddb/transaction_run_forever.js
diff options
context:
space:
mode:
Diffstat (limited to 'content/test/data/indexeddb/transaction_run_forever.js')
-rw-r--r--content/test/data/indexeddb/transaction_run_forever.js85
1 files changed, 40 insertions, 45 deletions
diff --git a/content/test/data/indexeddb/transaction_run_forever.js b/content/test/data/indexeddb/transaction_run_forever.js
index 3a79340..f6c65c0 100644
--- a/content/test/data/indexeddb/transaction_run_forever.js
+++ b/content/test/data/indexeddb/transaction_run_forever.js
@@ -2,64 +2,59 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-loopCount = 0;
-function endlessLoop()
+function test()
{
- var request = objectStore.get(0);
- request.onsuccess = endlessLoop;
- request.onerror = unexpectedErrorCallback;
+ // Do not use indexedDBTest() - need to specify the database name
+ var dbname = "doesnt-hang-test";
- loopCount += 1;
- if (loopCount == 7) {
- // If we've already looped 7 times, it's pretty safe to assume
- // we'll continue looping for some time...
- debug("Looping infinitely within a transaction.");
- done();
- }
+ var request = indexedDB.deleteDatabase(dbname);
+ request.onerror = unexpectedErrorCallback;
+ request.onblocked = unexpectedBlockedCallback;
+ request.onsuccess = function() {
+ var request = indexedDB.open(dbname, 1);
+ request.onerror = unexpectedErrorCallback;
+ request.onblocked = unexpectedBlockedCallback;
+ request.onupgradeneeded = onUpgradeNeeded;
+ request.onsuccess = onOpenSuccess;
+ };
}
-function newTransactionComplete()
+function onUpgradeNeeded()
{
- debug('The transaction completed.');
-
- var finalTransaction = db.transaction(['employees'],
- 'readonly');
- finalTransaction.oncomplete = unexpectedCompleteCallback;
- finalTransaction.onabort = unexpectedErrorCallback;
-
- objectStore = finalTransaction.objectStore('employees');
- endlessLoop();
- endlessLoop(); // Make sure at least one is in flight at any time.
+ // We are now in a set version transaction.
+ debug('Creating object store.');
+ var db = event.target.result;
+ db.createObjectStore('store');
}
-function onSetVersionComplete()
+
+var objectStore;
+function onOpenSuccess()
{
+ var db = event.target.result;
+
debug('Creating new transaction.');
- var newTransaction = db.transaction(['employees'], 'readwrite');
- newTransaction.oncomplete = newTransactionComplete;
- newTransaction.onabort = unexpectedAbortCallback;
+ var transaction = db.transaction('store', 'readwrite');
+ transaction.oncomplete = unexpectedCompleteCallback;
+ transaction.onabort = unexpectedAbortCallback;
+ objectStore = transaction.objectStore('store');
- var request = newTransaction.objectStore('employees').put(
- {id: 0, name: 'John Doe', desk: 'LON-BEL-123'});
- request.onerror = unexpectedErrorCallback;
+ debug('Starting endless loop...');
+ endlessLoop();
}
-function onSetVersion()
+var loopCount = 0;
+function endlessLoop()
{
- // We are now in a set version transaction.
- debug('Creating object store.');
- db = event.target.result;
- deleteAllObjectStores(db);
- var objectStore = db.createObjectStore('employees', {keyPath: 'id'});
-}
+ var request = objectStore.get(0);
+ request.onsuccess = endlessLoop;
+ request.onerror = unexpectedErrorCallback;
-function test()
-{
- if ('webkitIndexedDB' in window) {
- indexedDB = webkitIndexedDB;
- IDBCursor = webkitIDBCursor;
- IDBKeyRange = webkitIDBKeyRange;
- IDBTransaction = webkitIDBTransaction;
+ loopCount += 1;
+ if (loopCount == 7) {
+ // If we've already looped 7 times, it's pretty safe to assume
+ // we'll continue looping for some time...
+ debug("Looping infinitely within a transaction.");
+ done();
}
- indexedDBTest(onSetVersion, onSetVersionComplete);
}