1 if (this.importScripts) {
2 importScripts('../../../resources/js-test.js');
3 importScripts('shared.js');
6 description("Check that read-only transactions don't starve read-write transactions.");
8 indexedDBTest(prepareDatabase, runTransactions);
10 function prepareDatabase(evt)
13 evalAndLog("db = event.target.result");
14 evalAndLog("db.createObjectStore('store')");
17 function runTransactions(evt)
20 evalAndLog("db = event.target.result");
23 evalAndLog("readWriteTransactionStarted = false");
24 evalAndLog("readWriteTransactionComplete = false");
26 startReadOnlyTransaction();
30 function startReadOnlyTransaction()
33 evalAndLog("transaction = db.transaction('store', 'readonly')");
34 transaction.onabort = unexpectedAbortCallback;
35 evalAndLog("store = transaction.objectStore('store')");
36 debug("Keep the transaction alive with an endless series of gets");
39 request = store.get(0);
40 request.onsuccess = function() {
41 if (!readWriteTransactionStarted)
42 startReadWriteTransaction();
44 if (!readWriteTransactionComplete)
51 function startReadWriteTransaction()
54 evalAndLog("transaction = db.transaction('store', 'readwrite')");
55 transaction.onabort = unexpectedAbortCallback;
56 evalAndLog("readWriteTransactionStarted = true");
57 transaction.oncomplete = function readWriteTransactionComplete() {
59 testPassed("Transaction wasn't starved");
60 evalAndLog("readWriteTransactionComplete = true");