2 <script src=
"../../resources/js-test.js"></script>
3 <script src=
"resources/shared.js"></script>
6 description("Verify Indexed DB transactions are ordered per spec");
8 indexedDBTest(prepareDatabase
, onOpen
);
10 function prepareDatabase(evt
)
13 evalAndLog("db = event.target.result");
14 evalAndLog("store = db.createObjectStore('store')");
20 evalAndLog("db = event.target.result");
22 debug("Create in order tx1, tx2");
23 evalAndLog("tx1 = db.transaction('store', 'readwrite')");
24 evalAndLog("tx2 = db.transaction('store', 'readwrite')");
26 debug("Use in order tx2, tx1");
27 evalAndLog("tx2.objectStore('store').get(0)");
28 evalAndLog("tx1.objectStore('store').get(0)");
30 evalAndLog("order = []");
32 tx1
.oncomplete = function(evt
) {
33 debug("tx1 complete");
35 if (order
.length
=== 2) done();
38 tx2
.oncomplete = function(evt
) {
39 debug("tx1 complete");
41 if (order
.length
=== 2) done();
47 // https://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#transaction-concept
49 // If multiple "readwrite" transactions are attempting to
50 // access the same object store (i.e. if they have overlapping
51 // scope), the transaction that was created first must be the
52 // transaction which gets access to the object store first.
54 shouldBeTrue("areArraysEqual(order, [ 1, 2 ])");