From d8bbc7858622b6d9c278469aab701ca0b609cddf Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 15 May 2024 05:35:49 +0200 Subject: Merging upstream version 126.0. Signed-off-by: Daniel Baumann --- dom/indexedDB/test/mochitest-common.toml | 3 + dom/indexedDB/test/test_open_and_databases.html | 19 ++++++ dom/indexedDB/test/test_third_party.html | 8 +-- .../test/unit/test_connection_idle_maintenance.js | 2 +- .../unit/test_connection_idle_maintenance_stop.js | 2 +- dom/indexedDB/test/unit/test_open_and_databases.js | 76 ++++++++++++++++++++++ .../test/unit/xpcshell-head-parent-process.js | 8 ++- dom/indexedDB/test/unit/xpcshell-shared.toml | 2 + 8 files changed, 112 insertions(+), 8 deletions(-) create mode 100644 dom/indexedDB/test/test_open_and_databases.html create mode 100644 dom/indexedDB/test/unit/test_open_and_databases.js (limited to 'dom/indexedDB/test') diff --git a/dom/indexedDB/test/mochitest-common.toml b/dom/indexedDB/test/mochitest-common.toml index d42228da45..0959f36e13 100644 --- a/dom/indexedDB/test/mochitest-common.toml +++ b/dom/indexedDB/test/mochitest-common.toml @@ -73,6 +73,7 @@ support-files = [ "unit/test_objectStore_remove_values.js", "unit/test_object_identity.js", "unit/test_odd_result_order.js", + "unit/test_open_and_databases.js", "unit/test_open_empty_db.js", "unit/test_open_for_principal.js", "unit/test_open_objectStore.js", @@ -299,6 +300,8 @@ skip-if = [ ["test_odd_result_order.html"] +["test_open_and_databases.html"] + ["test_open_empty_db.html"] ["test_open_for_principal.html"] diff --git a/dom/indexedDB/test/test_open_and_databases.html b/dom/indexedDB/test/test_open_and_databases.html new file mode 100644 index 0000000000..9d0113136e --- /dev/null +++ b/dom/indexedDB/test/test_open_and_databases.html @@ -0,0 +1,19 @@ + + + + Indexed Database Property Test + + + + + + + + + + + + diff --git a/dom/indexedDB/test/test_third_party.html b/dom/indexedDB/test/test_third_party.html index ee90de8dac..439f50d754 100644 --- a/dom/indexedDB/test/test_third_party.html +++ b/dom/indexedDB/test/test_third_party.html @@ -25,12 +25,12 @@ { host: "http://sub1.test2.example.org:8000", cookieBehavior: BEHAVIOR_REJECT, expectedResultFrame1: false, expectedResultFrame2: false }, { host: "http://" + window.location.host, cookieBehavior: BEHAVIOR_REJECTFOREIGN, expectedResultFrame1: true, expectedResultFrame2: true }, - { host: "http://example.com", cookieBehavior: BEHAVIOR_REJECTFOREIGN, expectedResultFrame1: false, expectedResultFrame2: true }, - { host: "http://sub1.test2.example.org:8000", cookieBehavior: BEHAVIOR_REJECTFOREIGN, expectedResultFrame1: false, expectedResultFrame2: true }, + { host: "http://example.com", cookieBehavior: BEHAVIOR_REJECTFOREIGN, expectedResultFrame1: false, expectedResultFrame2: false }, + { host: "http://sub1.test2.example.org:8000", cookieBehavior: BEHAVIOR_REJECTFOREIGN, expectedResultFrame1: false, expectedResultFrame2: false }, { host: "http://" + window.location.host, cookieBehavior: BEHAVIOR_LIMITFOREIGN, expectedResultFrame1: true, expectedResultFrame2: true }, - { host: "http://example.com", cookieBehavior: BEHAVIOR_LIMITFOREIGN, expectedResultFrame1: false, expectedResultFrame2: true }, - { host: "http://sub1.test2.example.org:8000", cookieBehavior: BEHAVIOR_LIMITFOREIGN, expectedResultFrame1: false, expectedResultFrame2: true }, + { host: "http://example.com", cookieBehavior: BEHAVIOR_LIMITFOREIGN, expectedResultFrame1: false, expectedResultFrame2: false }, + { host: "http://sub1.test2.example.org:8000", cookieBehavior: BEHAVIOR_LIMITFOREIGN, expectedResultFrame1: false, expectedResultFrame2: false }, ]; const iframe1Path = 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"] -- cgit v1.2.3