2 * Any copyright is dedicated to the Public Domain.
3 * http://creativecommons.org/publicdomain/zero/1.0/
6 const PR_USEC_PER_SEC
= 1000000;
8 const NS_ERROR_STORAGE_BUSY
= Cr
.NS_ERROR_STORAGE_BUSY
;
10 loadScript("dom/quota/test/common/global.js");
12 function getProfileDir() {
13 return Services
.dirsvc
.get("ProfD", Ci
.nsIFile
);
16 // Given a "/"-delimited path relative to a base file (or the profile
17 // directory if a base file is not provided) return an nsIFile representing the
18 // path. This does not test for the existence of the file or parent
19 // directories. It is safe even on Windows where the directory separator is
20 // not "/", but make sure you're not passing in a "\"-delimited path.
21 function getRelativeFile(relativePath
, baseFile
) {
23 baseFile
= getProfileDir();
26 let file
= baseFile
.clone();
28 if (Services
.appinfo
.OS
=== "WINNT") {
29 let winFile
= file
.QueryInterface(Ci
.nsILocalFileWin
);
30 winFile
.useDOSDevicePathSyntax
= true;
33 relativePath
.split("/").forEach(function (component
) {
34 if (component
== "..") {
37 file
.append(component
);
44 function getCurrentPrincipal() {
45 return Cc
["@mozilla.org/systemprincipal;1"].createInstance(Ci
.nsIPrincipal
);
48 function getSimpleDatabase(principal
, persistence
) {
49 let connection
= Cc
["@mozilla.org/dom/sdb-connection;1"].createInstance(
54 principal
= getCurrentPrincipal();
57 connection
.init(principal
, persistence
);
62 async
function requestFinished(request
) {
63 await
new Promise(function (resolve
) {
64 request
.callback = function () {
69 if (request
.resultCode
!== Cr
.NS_OK
) {
70 throw new RequestError(request
.resultCode
, request
.resultName
);
73 return request
.result
;