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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
/**
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
var testGenerator = testSteps();
function testSteps()
{
const dbNames = [
"No files",
"Blobs and mutable files"
]
const version = 1;
const objectStoreName = "test";
clearAllDatabases(continueToNextStepSync);
yield undefined;
installPackagedProfile("mutableFileUpgrade_profile");
let request = indexedDB.open(dbNames[0], version);
request.onerror = errorHandler;
request.onupgradeneeded = unexpectedSuccessHandler;
request.onsuccess = grabEventAndContinueHandler;
let event = yield undefined;
is(event.type, "success", "Correct event type");
let db = event.target.result;
db.onerror = errorHandler;
request = db.transaction([objectStoreName])
.objectStore(objectStoreName)
.get(1);
request.onsuccess = grabEventAndContinueHandler;
event = yield undefined;
is(event.target.result, "text", "Correct result");
request = indexedDB.open(dbNames[1], version);
request.onerror = errorHandler;
request.onupgradeneeded = unexpectedSuccessHandler;
request.onsuccess = grabEventAndContinueHandler;
event = yield undefined;
is(event.type, "success", "Correct event type");
db = event.target.result;
db.onerror = errorHandler;
request = db.transaction([objectStoreName])
.objectStore(objectStoreName)
.get(1);
request.onsuccess = grabEventAndContinueHandler;
event = yield undefined;
is(event.target.result, "text", "Correct result");
request = db.transaction([objectStoreName])
.objectStore(objectStoreName)
.get(2);
request.onsuccess = grabEventAndContinueHandler;
event = yield undefined;
verifyBlob(event.target.result, getBlob("blob0"));
yield undefined;
request = db.transaction([objectStoreName])
.objectStore(objectStoreName)
.get(3);
request.onsuccess = grabEventAndContinueHandler;
event = yield undefined;
let result = event.target.result;
verifyBlob(result[0], getBlob("blob1"));
yield undefined;
verifyBlob(result[1], getBlob("blob2"));
yield undefined;
request = db.transaction([objectStoreName])
.objectStore(objectStoreName)
.get(4);
request.onsuccess = grabEventAndContinueHandler;
event = yield undefined;
verifyMutableFile(event.target.result, getFile("mutablefile0", "", ""));
yield undefined;
request = db.transaction([objectStoreName])
.objectStore(objectStoreName)
.get(5);
request.onsuccess = grabEventAndContinueHandler;
event = yield undefined;
result = event.target.result;
verifyMutableFile(result[0], getFile("mutablefile1", "", ""));
yield undefined;
verifyMutableFile(result[1], getFile("mutablefile2", "", ""));
yield undefined;
request = db.transaction([objectStoreName])
.objectStore(objectStoreName)
.get(6);
request.onsuccess = grabEventAndContinueHandler;
event = yield undefined;
result = event.target.result;
verifyBlob(result[0], getBlob("blob3"));
yield undefined;
verifyMutableFile(result[1], getFile("mutablefile3", "", ""));
yield undefined;
finishTest();
yield undefined;
}
|