1 if (this.importScripts) {
2 importScripts('../../../resources/js-test.js');
3 importScripts('shared.js');
6 description("Check that scope restrictions on read-write transactions are enforced.");
8 indexedDBTest(prepareDatabase, runTransactions);
10 function prepareDatabase(evt)
13 evalAndLog("db = event.target.result");
14 evalAndLog("db.createObjectStore('a')");
15 evalAndLog("db.createObjectStore('b')");
16 evalAndLog("db.createObjectStore('c')");
19 function runTransactions(evt)
22 evalAndLog("db = event.target.result");
25 evalAndLog("transaction1 = db.transaction(['a'], 'readwrite')");
26 evalAndLog("transaction1Started = false");
27 evalAndLog("transaction1Complete = false");
28 request = evalAndLog("transaction1.objectStore('a').get(0)");
29 request.onerror = unexpectedErrorCallback;
30 request.onsuccess = function() {
32 evalAndLog("transaction1Started = true");
34 transaction1.onabort = unexpectedAbortCallback;
35 transaction1.oncomplete = function() {
37 evalAndLog("transaction1Complete = true");
38 shouldBeFalse("transaction2Started");
39 shouldBeFalse("transaction3Started");
43 debug("transaction2 overlaps with transaction1, so must wait until transaction1 completes");
44 evalAndLog("transaction2 = db.transaction(['a', 'b'], 'readwrite')");
45 evalAndLog("transaction2Started = false");
46 evalAndLog("transaction2Complete = false");
47 request = evalAndLog("transaction2.objectStore('a').get(0)");
48 request.onerror = unexpectedErrorCallback;
49 request.onsuccess = function() {
51 shouldBeTrue("transaction1Complete");
52 evalAndLog("transaction2Started = true");
54 transaction2.onabort = unexpectedAbortCallback;
55 transaction2.oncomplete = function() {
57 evalAndLog("transaction2Complete = true");
58 shouldBeFalse("transaction3Started");
62 debug("transaction3 overlaps with transaction2, so must wait until transaction2 completes");
63 debug("even though it does not overlap with transaction1");
64 evalAndLog("transaction3 = db.transaction(['b', 'c'], 'readwrite')");
65 evalAndLog("transaction3Started = false");
66 evalAndLog("transaction3Complete = false");
67 request = evalAndLog("transaction3.objectStore('b').get(0)");
68 request.onerror = unexpectedErrorCallback;
69 request.onsuccess = function() {
71 shouldBeTrue("transaction1Complete");
72 shouldBeTrue("transaction2Complete");
73 evalAndLog("transaction3Started = true");
75 transaction3.onabort = unexpectedAbortCallback;
76 transaction3.oncomplete = function() {
78 evalAndLog("transaction3Complete = true");