Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / storage / indexeddb / transaction-ordering.html
blob6c6d6e6ea1c398929e4c35bdb66b633253342d6b
1 <!DOCTYPE html>
2 <script src="../../resources/js-test.js"></script>
3 <script src="resources/shared.js"></script>
4 <script>
6 description("Verify Indexed DB transactions are ordered per spec");
8 indexedDBTest(prepareDatabase, onOpen);
10 function prepareDatabase(evt)
12 preamble(evt);
13 evalAndLog("db = event.target.result");
14 evalAndLog("store = db.createObjectStore('store')");
17 function onOpen(evt)
19 preamble(evt);
20 evalAndLog("db = event.target.result");
21 debug("");
22 debug("Create in order tx1, tx2");
23 evalAndLog("tx1 = db.transaction('store', 'readwrite')");
24 evalAndLog("tx2 = db.transaction('store', 'readwrite')");
25 debug("");
26 debug("Use in order tx2, tx1");
27 evalAndLog("tx2.objectStore('store').get(0)");
28 evalAndLog("tx1.objectStore('store').get(0)");
29 debug("");
30 evalAndLog("order = []");
32 tx1.oncomplete = function(evt) {
33 debug("tx1 complete");
34 order.push(1);
35 if (order.length === 2) done();
38 tx2.oncomplete = function(evt) {
39 debug("tx1 complete");
40 order.push(2);
41 if (order.length === 2) done();
44 function done() {
45 preamble();
46 // IndexedDB Spec:
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 ])");
55 finishJSTest();
60 </script>