1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
// META: script=resources/support.js
indexeddb_test(
(t, db) => {
const store = db.createObjectStore('store');
},
(t, db1) => {
// Open a second connection to the same database.
const open_request = indexedDB.open(db1.name);
open_request.onerror = t.unreached_func('open() should succeed');
open_request.onupgradeneeded =
t.unreached_func('second connection should not upgrade');
open_request.onsuccess = t.step_func(() => {
const db2 = open_request.result;
t.add_cleanup(() => { db2.close(); });
const transaction1 = db1.transaction('store', 'readwrite', {durability: 'relaxed'});
transaction1.onabort = t.unreached_func('transaction1 should complete');
const transaction2 = db2.transaction('store', 'readwrite', {durability: 'relaxed'});
transaction2.onabort = t.unreached_func('transaction2 should complete');
let transaction1PutSuccess = false;
let transaction1Complete = false;
let transaction2PutSuccess = false;
// Keep transaction1 alive for a while and ensure transaction2
// doesn't start.
let count = 0;
(function doTransaction1Put() {
const request = transaction1.objectStore('store').put(1, count++);
request.onerror = t.unreached_func('request should succeed');
request.onsuccess = t.step_func(evt => {
transaction1PutSuccess = true;
if (count < 5) {
doTransaction1Put();
}
});
}());
transaction1.oncomplete = t.step_func(evt => {
transaction1Complete = true;
assert_false(
transaction2PutSuccess,
'transaction1 should complete before transaction2 put succeeds');
});
const request = transaction2.objectStore('store').put(2, 0);
request.onerror = t.unreached_func('request should succeed');
request.onsuccess = t.step_func(evt => {
transaction2PutSuccess = true;
assert_true(
transaction1Complete,
'transaction2 put should not succeed before transaction1 completes');
});
transaction2.oncomplete = t.step_func_done(evt => {
assert_true(
transaction1PutSuccess,
'transaction1 put should succeed before transaction2 runs');
assert_true(
transaction1Complete,
'transaction1 should complete before transaction2 runs');
assert_true(
transaction2PutSuccess,
'transaction2 put should succeed before transaction2 completes');
});
});
},
"Check that readwrite transactions with overlapping scopes do not run in parallel.");
|