summaryrefslogtreecommitdiffstats
path: root/dom/indexedDB/test/unit
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:34:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:34:50 +0000
commitdef92d1b8e9d373e2f6f27c366d578d97d8960c6 (patch)
tree2ef34b9ad8bb9a9220e05d60352558b15f513894 /dom/indexedDB/test/unit
parentAdding debian version 125.0.3-1. (diff)
downloadfirefox-def92d1b8e9d373e2f6f27c366d578d97d8960c6.tar.xz
firefox-def92d1b8e9d373e2f6f27c366d578d97d8960c6.zip
Merging upstream version 126.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/indexedDB/test/unit')
-rw-r--r--dom/indexedDB/test/unit/test_connection_idle_maintenance.js2
-rw-r--r--dom/indexedDB/test/unit/test_connection_idle_maintenance_stop.js2
-rw-r--r--dom/indexedDB/test/unit/test_open_and_databases.js76
-rw-r--r--dom/indexedDB/test/unit/xpcshell-head-parent-process.js8
-rw-r--r--dom/indexedDB/test/unit/xpcshell-shared.toml2
5 files changed, 86 insertions, 4 deletions
diff --git a/dom/indexedDB/test/unit/test_connection_idle_maintenance.js b/dom/indexedDB/test/unit/test_connection_idle_maintenance.js
index 288f656c65..819b0b61bb 100644
--- a/dom/indexedDB/test/unit/test_connection_idle_maintenance.js
+++ b/dom/indexedDB/test/unit/test_connection_idle_maintenance.js
@@ -8,7 +8,7 @@ async function testSteps() {
// A constant used to deal with small decrease in usage when transactions are
// transferred from the WAL file back into the original database, also called
// as checkpointing.
- const cosmologicalConstant = 31768;
+ const cosmologicalConstant = 20000;
// The length of time that database connections will be held open after all
// transactions have completed before doing idle maintenance.
diff --git a/dom/indexedDB/test/unit/test_connection_idle_maintenance_stop.js b/dom/indexedDB/test/unit/test_connection_idle_maintenance_stop.js
index 33dc69b210..5453e4dc4e 100644
--- a/dom/indexedDB/test/unit/test_connection_idle_maintenance_stop.js
+++ b/dom/indexedDB/test/unit/test_connection_idle_maintenance_stop.js
@@ -8,7 +8,7 @@ async function testSteps() {
// A constant used to deal with small decrease in usage when transactions are
// transferred from the WAL file back into the original database, also called
// as checkpointing.
- const cosmologicalConstant = 32768;
+ const cosmologicalConstant = 35000;
// The maximum number of threads that can be used for database activity at a
// single time.
diff --git a/dom/indexedDB/test/unit/test_open_and_databases.js b/dom/indexedDB/test/unit/test_open_and_databases.js
new file mode 100644
index 0000000000..b13cba067a
--- /dev/null
+++ b/dom/indexedDB/test/unit/test_open_and_databases.js
@@ -0,0 +1,76 @@
+/**
+ * Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+/* exported testSteps */
+async function testSteps() {
+ const openInfos = [
+ { name: "foo-a", version: 1 },
+ { name: "foo-b", version: 1 },
+ ];
+
+ info("Creating databases");
+
+ for (let index = 0; index < openInfos.length; index++) {
+ const openInfo = openInfos[index];
+
+ const request = indexedDB.open(openInfo.name, openInfo.version);
+
+ await expectingUpgrade(request);
+
+ const event = await expectingSuccess(request);
+
+ const database = event.target.result;
+
+ database.close();
+ }
+
+ info("Getting databases");
+
+ const databasesPromise = indexedDB.databases();
+
+ info("Opening databases");
+
+ const openPromises = [];
+
+ for (let index = 0; index < openInfos.length; index++) {
+ const openInfo = openInfos[index];
+
+ const request = indexedDB.open(openInfo.name, openInfo.version);
+
+ const promise = expectingSuccess(request);
+
+ openPromises.push(promise);
+ }
+
+ info("Waiting for databases operation to complete");
+
+ const databaseInfos = await databasesPromise;
+
+ info("Verifying databases");
+
+ is(
+ databaseInfos.length,
+ openInfos.length,
+ "The result of databases() should contain one result per database"
+ );
+
+ for (let index = 0; index < openInfos.length; index++) {
+ const openInfo = openInfos[index];
+
+ ok(
+ databaseInfos.some(function (element) {
+ return (
+ element.name === openInfo.name && element.version === openInfo.version
+ );
+ }),
+ "The result of databases() should be a sequence of the correct names " +
+ "and versions of all databases for the origin"
+ );
+ }
+
+ info("Waiting for open operations to complete");
+
+ await Promise.all(openPromises);
+}
diff --git a/dom/indexedDB/test/unit/xpcshell-head-parent-process.js b/dom/indexedDB/test/unit/xpcshell-head-parent-process.js
index f6bd2608ef..840eef7908 100644
--- a/dom/indexedDB/test/unit/xpcshell-head-parent-process.js
+++ b/dom/indexedDB/test/unit/xpcshell-head-parent-process.js
@@ -56,7 +56,11 @@ if (!this.runTest) {
if (testSteps.constructor.name === "AsyncFunction") {
// Do run our existing cleanup function that would normally be called by
// the generator's call to finishTest().
- registerCleanupFunction(resetTesting);
+ registerCleanupFunction(function () {
+ if (SpecialPowers.isMainProcess()) {
+ resetTesting();
+ }
+ });
add_task(testSteps);
@@ -644,7 +648,7 @@ var SpecialPowers = {
clearUserPref(prefName) {
Services.prefs.clearUserPref(prefName);
},
- // Copied (and slightly adjusted) from testing/specialpowers/content/SpecialPowersAPI.jsm
+ // Copied (and slightly adjusted) from testing/specialpowers/api.js
exactGC(callback) {
let count = 0;
diff --git a/dom/indexedDB/test/unit/xpcshell-shared.toml b/dom/indexedDB/test/unit/xpcshell-shared.toml
index ac1183ab2d..f967236a9e 100644
--- a/dom/indexedDB/test/unit/xpcshell-shared.toml
+++ b/dom/indexedDB/test/unit/xpcshell-shared.toml
@@ -111,6 +111,8 @@ skip-if = ["os == 'android'"] # bug 864843
["test_odd_result_order.js"]
+["test_open_and_databases.js"]
+
["test_open_empty_db.js"]
["test_open_for_principal.js"]