blob: 8301b3292dd115a457993e6589f5db7d67830927 (
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
/**
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
loadScript("dom/quota/test/common/file.js");
async function testSteps() {
// First, ensure the origin can be initialized and used by a client that uses
// SQLite databases.
// Todo: consider using simpleDB once it supports using storage for SQLite.
info("Testing SQLite database with an origin that ends with a dot");
const principal = getPrincipal("https://example.com.");
let request = indexedDB.openForPrincipal(principal, "myIndexedDB");
await openDBRequestUpgradeNeeded(request);
info("Testing simple operations");
const database = request.result;
const objectStore = database.createObjectStore("Blobs", {});
objectStore.add(getNullBlob(200), 42);
await openDBRequestSucceeded(request);
database.close();
info("Reseting");
request = reset();
await requestFinished(request);
let idbDB = getRelativeFile(
"storage/default/https+++example.com./idb/2320029346mByDIdnedxe.sqlite"
);
ok(idbDB.exists(), "IDB database was created successfully");
// Second, ensure storage initialization works fine with the origin.
info("Testing storage initialization and temporary storage initialization");
request = init();
await requestFinished(request);
request = initTemporaryStorage();
await requestFinished(request);
// Third, ensure QMS APIs that touch the client directory for the origin work
// fine.
info("Testing getUsageForPrincipal");
request = getOriginUsage(principal);
await requestFinished(request);
ok(
request.result instanceof Ci.nsIQuotaOriginUsageResult,
"The result is nsIQuotaOriginUsageResult instance"
);
ok(request.result.usage > 0, "Total usage is not empty");
ok(request.result.fileUsage > 0, "File usage is not empty");
info("Testing clearStoragesForPrincipal");
request = clearOrigin(principal, "default");
await requestFinished(request);
}
|