1 if (this.importScripts) {
2 importScripts('../../../resources/js-test.js');
3 importScripts('shared.js');
6 description("Check that readwrite transactions with overlapping scopes do not run in parallel.");
12 request = evalAndLog("indexedDB.deleteDatabase(dbname)");
13 request.onerror = unexpectedBlockedCallback;
14 request.onblocked = unexpectedBlockedCallback;
15 request.onsuccess = openConnection1;
18 function openConnection1()
21 request = evalAndLog("indexedDB.open(dbname, 1)");
22 request.onerror = unexpectedBlockedCallback;
23 request.onblocked = unexpectedBlockedCallback;
24 request.onupgradeneeded = function openOnUpgradeNeeded1(evt) {
26 evalAndLog("db = event.target.result");
27 evalAndLog("store = db.createObjectStore('store')");
29 request.onsuccess = function openOnSuccess(evt) {
31 evalAndLog("db1 = event.target.result");
36 function openConnection2()
39 request = evalAndLog("indexedDB.open(dbname, 1)");
40 request.onerror = unexpectedBlockedCallback;
41 request.onblocked = unexpectedBlockedCallback;
42 request.onupgradeneeded = unexpectedUpgradeNeededCallback;
43 request.onsuccess = function openOnSuccess2(evt) {
45 evalAndLog("db2 = event.target.result");
53 evalAndLog("transaction1 = db1.transaction('store', 'readwrite')");
54 transaction1.onabort = unexpectedAbortCallback;
55 evalAndLog("transaction2 = db2.transaction('store', 'readwrite')");
56 transaction1.onabort = unexpectedAbortCallback;
58 evalAndLog("transaction1PutSuccess = false");
59 evalAndLog("transaction1Complete = false");
60 evalAndLog("transaction2PutSuccess = false");
61 evalAndLog("transaction2Complete = false");
64 debug("Keep transaction1 alive for a while and ensure transaction2 doesn't start");
66 evalAndLog("count = 0");
68 (function doTransaction1Put() {
69 request = evalAndLog("transaction1.objectStore('store').put(1, count++)");
70 request.onerror = unexpectedErrorCallback;
71 request.onsuccess = function put1OnSuccess(evt) {
73 evalAndLog("transaction1PutSuccess = true");
80 transaction1.oncomplete = function onTransaction1Complete(evt) {
82 evalAndLog("transaction1Complete = true");
83 shouldBeFalse("transaction2PutSuccess");
84 shouldBeFalse("transaction2Complete");
87 request = evalAndLog("transaction2.objectStore('store').put(2, 0)");
88 request.onerror = unexpectedErrorCallback;
89 request.onsuccess = function put2OnSuccess(evt) {
91 evalAndLog("transaction2PutSuccess = true");
92 shouldBeTrue("transaction1Complete");
95 transaction2.oncomplete = function onTransaction2Complete(evt) {
97 evalAndLog("transaction2Complete = true");
98 shouldBeTrue("transaction1PutSuccess");
99 shouldBeTrue("transaction1Complete");
100 shouldBeTrue("transaction2PutSuccess");