summaryrefslogtreecommitdiffstats
path: root/dom/quota/test/common/global.js
diff options
context:
space:
mode:
Diffstat (limited to 'dom/quota/test/common/global.js')
-rw-r--r--dom/quota/test/common/global.js47
1 files changed, 47 insertions, 0 deletions
diff --git a/dom/quota/test/common/global.js b/dom/quota/test/common/global.js
new file mode 100644
index 0000000000..cc7d9d97a2
--- /dev/null
+++ b/dom/quota/test/common/global.js
@@ -0,0 +1,47 @@
+/**
+ * Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+const INT64_MIN = -0x8000000000000000n;
+
+class RequestError extends Error {
+ constructor(resultCode, resultName) {
+ super(`Request failed (code: ${resultCode}, name: ${resultName})`);
+ this.name = "RequestError";
+ this.resultCode = resultCode;
+ this.resultName = resultName;
+ }
+}
+
+function openDBRequestUpgradeNeeded(request) {
+ return new Promise(function (resolve, reject) {
+ request.onerror = function (event) {
+ ok(false, "indexedDB error, '" + event.target.error.name + "'");
+ reject(event);
+ };
+ request.onupgradeneeded = function (event) {
+ resolve(event);
+ };
+ request.onsuccess = function (event) {
+ ok(false, "Got success, but did not expect it!");
+ reject(event);
+ };
+ });
+}
+
+function openDBRequestSucceeded(request) {
+ return new Promise(function (resolve, reject) {
+ request.onerror = function (event) {
+ ok(false, "indexedDB error, '" + event.target.error.name + "'");
+ reject(event);
+ };
+ request.onupgradeneeded = function (event) {
+ ok(false, "Got upgrade, but did not expect it!");
+ reject(event);
+ };
+ request.onsuccess = function (event) {
+ resolve(event);
+ };
+ });
+}