2 * Any copyright is dedicated to the Public Domain.
3 * http://creativecommons.org/publicdomain/zero/1.0/
6 const { PrincipalUtils
} = ChromeUtils
.importESModule(
7 "resource://testing-common/dom/quota/test/modules/PrincipalUtils.sys.mjs"
9 const { QuotaUtils
} = ChromeUtils
.importESModule(
10 "resource://testing-common/dom/quota/test/modules/QuotaUtils.sys.mjs"
12 const { SimpleDBUtils
} = ChromeUtils
.importESModule(
13 "resource://testing-common/dom/simpledb/test/modules/SimpleDBUtils.sys.mjs"
16 async
function testSteps() {
18 Ci
.nsIQuotaArtificialFailure
.CATEGORY_NONE
,
19 Ci
.nsIQuotaArtificialFailure
.CATEGORY_INITIALIZE_ORIGIN
,
21 const principal
= PrincipalUtils
.createPrincipal("https://example.com");
24 for (let category
of categories
) {
25 info("Creating database");
28 const connection
= SimpleDBUtils
.createConnection(principal
);
30 const openRequest
= connection
.open(name
);
31 await SimpleDBUtils
.requestFinished(openRequest
);
33 const closeRequest
= connection
.close();
34 await SimpleDBUtils
.requestFinished(closeRequest
);
37 info("Resetting storage");
40 const request
= Services
.qms
.reset();
41 await QuotaUtils
.requestFinished(request
);
44 info("Opening database");
46 const ex
= await QuotaUtils
.withArtificialFailures(
48 /* probability */ 100,
49 Cr
.NS_ERROR_FILE_ACCESS_DENIED
,
51 const connection
= SimpleDBUtils
.createConnection(principal
);
52 const request
= connection
.open(name
);
54 await SimpleDBUtils
.requestFinished(request
);
62 if (category
== Ci
.nsIQuotaArtificialFailure
.CATEGORY_NONE
) {
63 Assert
.ok(!ex
, "Should not have thrown");
65 Assert
.ok(ex
, "Should have thrown");
68 // NS_ERROR_FILE_ACCESS_DENIED is mapped to NS_ERROR_FAILURE during error
71 "Threw right result code"
75 info("Clearing storage");
78 const request
= Services
.qms
.clear();
79 await QuotaUtils
.requestFinished(request
);