Bug 1945643 - Update to mozilla-nimbus-schemas 2025.1.1 r=chumphreys
[gecko.git] / dom / quota / test / xpcshell / test_originEndsWithDot.js
blob6fd017a58bc43bdd61f47109c7c2eef13aa0353b
1 /**
2 * Any copyright is dedicated to the Public Domain.
3 * http://creativecommons.org/publicdomain/zero/1.0/
4 */
6 loadScript("dom/quota/test/common/file.js");
8 async function testSteps() {
9 // First, ensure the origin can be initialized and used by a client that uses
10 // SQLite databases.
12 // Todo: consider using simpleDB once it supports using storage for SQLite.
13 info("Testing SQLite database with an origin that ends with a dot");
15 const principal = getPrincipal("https://example.com.");
16 let request = indexedDB.openForPrincipal(principal, "myIndexedDB");
17 await openDBRequestUpgradeNeeded(request);
19 info("Testing simple operations");
21 const database = request.result;
23 const objectStore = database.createObjectStore("Blobs", {});
25 objectStore.add(getNullBlob(200), 42);
27 await openDBRequestSucceeded(request);
29 database.close();
31 info("Reseting");
33 request = reset();
34 await requestFinished(request);
36 let idbDB = getRelativeFile(
37 "storage/default/https+++example.com./idb/2320029346mByDIdnedxe.sqlite"
39 ok(idbDB.exists(), "IDB database was created successfully");
41 // Second, ensure storage initialization works fine with the origin.
43 info("Testing storage initialization and temporary storage initialization");
45 request = init();
46 await requestFinished(request);
48 request = initTemporaryStorage();
49 await requestFinished(request);
51 // Third, ensure QMS APIs that touch the client directory for the origin work
52 // fine.
54 info("Testing getUsageForPrincipal");
56 request = getOriginUsage(principal);
57 await requestFinished(request);
59 ok(
60 request.result instanceof Ci.nsIQuotaOriginUsageResult,
61 "The result is nsIQuotaOriginUsageResult instance"
63 Assert.greater(request.result.usage, 0, "Total usage is not empty");
64 Assert.greater(request.result.fileUsage, 0, "File usage is not empty");
66 info("Testing clearStoragesForPrincipal");
68 request = clearOrigin(principal, "default");
69 await requestFinished(request);