2 * Any copyright is dedicated to the Public Domain.
3 * http://creativecommons.org/publicdomain/zero/1.0/
6 async
function testSteps() {
9 origin
: "http://example.com",
15 origin
: "http://localhost",
21 origin
: "http://www.mozilla.org",
35 origin
: "http://example.com",
41 origin
: "http://localhost",
47 origin
: "http://www.mozilla.org",
53 function verifyResult(result
, expectedOrigins
) {
54 ok(result
instanceof Array
, "Got an array object");
57 expectedOrigins
.length
,
58 "Correct number of elements"
61 info("Sorting elements");
63 result
.sort(function (a
, b
) {
64 let originA
= a
.origin
;
65 let originB
= b
.origin
;
67 if (originA
< originB
) {
70 if (originA
> originB
) {
76 info("Verifying elements");
78 for (let i
= 0; i
< result
.length
; i
++) {
80 let b
= expectedOrigins
[i
];
81 Assert
.equal(a
.origin
, b
.origin
, "Origin equals");
82 Assert
.equal(a
.persisted
, b
.persisted
, "Persisted equals");
83 Assert
.equal(a
.usage
, b
.usage
, "Usage equals");
91 let request
= clear();
92 await
requestFinished(request
);
94 info("Getting usage");
96 request
= getUsage(dummy
, /* getAll */ true);
97 let result
= await
requestFinished(request
);
99 info("Verifying result");
101 verifyResult(result
, []);
106 await
requestFinished(request
);
108 info("Installing package");
110 // The profile contains IndexedDB databases placed across the repositories.
111 // The file create_db.js in the package was run locally, specifically it was
112 // temporarily added to xpcshell.ini and then executed:
113 // mach xpcshell-test --interactive dom/quota/test/xpcshell/create_db.js
114 installPackage("getUsage_profile");
116 info("Getting usage");
118 request
= getUsage(dummy
, /* getAll */ false);
119 result
= await
requestFinished(request
);
121 info("Verifying result");
123 verifyResult(result
, origins
);
125 info("Getting usage");
127 request
= getUsage(dummy
, /* getAll */ true);
128 result
= await
requestFinished(request
);
130 info("Verifying result");
132 verifyResult(result
, allOrigins
);
134 info("Getting usage");
136 Services
.prefs
.setIntPref(
137 "dom.quotaManager.originOperations.pauseOnIOThreadMs",
141 request
= getUsage(dummy
, /* getAll */ true);
143 info("Cancelling request");
148 result
= await
requestFinished(request
);
149 ok(false, "Should have thrown");
151 ok(true, "Should have thrown");
155 "Threw right result code"
159 Services
.prefs
.clearUserPref(
160 "dom.quotaManager.originOperations.pauseOnIOThreadMs"