blob: cc7d9d97a278dc9c362158ac5fb307cc928065ed (
plain)
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
|
/**
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
const INT64_MIN = -0x8000000000000000n;
class RequestError extends Error {
constructor(resultCode, resultName) {
super(`Request failed (code: ${resultCode}, name: ${resultName})`);
this.name = "RequestError";
this.resultCode = resultCode;
this.resultName = resultName;
}
}
function openDBRequestUpgradeNeeded(request) {
return new Promise(function (resolve, reject) {
request.onerror = function (event) {
ok(false, "indexedDB error, '" + event.target.error.name + "'");
reject(event);
};
request.onupgradeneeded = function (event) {
resolve(event);
};
request.onsuccess = function (event) {
ok(false, "Got success, but did not expect it!");
reject(event);
};
});
}
function openDBRequestSucceeded(request) {
return new Promise(function (resolve, reject) {
request.onerror = function (event) {
ok(false, "indexedDB error, '" + event.target.error.name + "'");
reject(event);
};
request.onupgradeneeded = function (event) {
ok(false, "Got upgrade, but did not expect it!");
reject(event);
};
request.onsuccess = function (event) {
resolve(event);
};
});
}
|