diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /dom/fs/test/mochitest | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/fs/test/mochitest')
17 files changed, 385 insertions, 0 deletions
diff --git a/dom/fs/test/mochitest/head.js b/dom/fs/test/mochitest/head.js new file mode 100644 index 0000000000..321ca0291b --- /dev/null +++ b/dom/fs/test/mochitest/head.js @@ -0,0 +1,82 @@ +/** + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +async function require_module(id) { + if (!require_module.moduleLoader) { + const { ModuleLoader } = await import( + "/tests/dom/quota/test/modules/ModuleLoader.js" + ); + + const base = window.location.href; + + const depth = "../../../../"; + + const { Assert } = await import("/tests/dom/quota/test/modules/Assert.js"); + + const { Utils } = await import("/tests/dom/quota/test/modules/Utils.js"); + + const proto = { + Assert, + Cr: SpecialPowers.Cr, + navigator, + TextEncoder, + Utils, + }; + + require_module.moduleLoader = new ModuleLoader(base, depth, proto); + } + + return require_module.moduleLoader.require(id); +} + +async function run_test_in_worker(script) { + const { runTestInWorker } = await import( + "/tests/dom/quota/test/modules/WorkerDriver.js" + ); + + const base = window.location.href; + + const listener = { + onOk(value, message) { + ok(value, message); + }, + onIs(a, b, message) { + is(a, b, message); + }, + onInfo(message) { + info(message); + }, + }; + + await runTestInWorker(script, base, listener); +} + +// XXX This can be removed once we use <profile>/storage. See bug 1798015. +async function removeAllEntries() { + const root = await navigator.storage.getDirectory(); + for await (const value of root.values()) { + root.removeEntry(value.name, { recursive: true }); + } +} + +add_setup(async function () { + const { setStoragePrefs, clearStoragesForOrigin } = await import( + "/tests/dom/quota/test/modules/StorageUtils.js" + ); + + const optionalPrefsToSet = [ + ["dom.fs.enabled", true], + ["dom.fs.writable_file_stream.enabled", true], + ["dom.workers.modules.enabled", true], + ]; + + await setStoragePrefs(optionalPrefsToSet); + + SimpleTest.registerCleanupFunction(async function () { + await removeAllEntries(); + + await clearStoragesForOrigin(SpecialPowers.wrap(document).nodePrincipal); + }); +}); diff --git a/dom/fs/test/mochitest/mochitest.ini b/dom/fs/test/mochitest/mochitest.ini new file mode 100644 index 0000000000..aa9f93b006 --- /dev/null +++ b/dom/fs/test/mochitest/mochitest.ini @@ -0,0 +1,24 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +[DEFAULT] +skip-if = xorigin +support-files = + head.js + +# Skip all tests if xorigin since we'll fail GetStorage() with ePartitionForeignOrDeny +[test_basics.html] +scheme=https +[test_basics_worker.html] +scheme=https +[test_fileSystemDirectoryHandle.html] +scheme=https +[test_fileSystemDirectoryHandle_worker.html] +scheme=https +[test_syncAccessHandle_worker.html] +scheme=https +[test_writableFileStream.html] +scheme=https +[test_writableFileStream_worker.html] +scheme=https diff --git a/dom/fs/test/mochitest/test_basics.html b/dom/fs/test/mochitest/test_basics.html new file mode 100644 index 0000000000..5c609233b5 --- /dev/null +++ b/dom/fs/test/mochitest/test_basics.html @@ -0,0 +1,28 @@ +<!-- + Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ +--> +<html> +<head> + <title>File System Test</title> + + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> + + <script type="text/javascript" src="head.js"></script> + <script type="text/javascript"> + add_task(async function init() { + const testSet = "dom/fs/test/common/test_basics.js"; + + const testCases = await require_module(testSet); + + Object.values(testCases).forEach(testItem => { + add_task(testItem); + }); + }); + </script> +</head> + +<body></body> + +</html> diff --git a/dom/fs/test/mochitest/test_basics_worker.html b/dom/fs/test/mochitest/test_basics_worker.html new file mode 100644 index 0000000000..72ad7b8c41 --- /dev/null +++ b/dom/fs/test/mochitest/test_basics_worker.html @@ -0,0 +1,22 @@ +<!-- + Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ +--> +<html> +<head> + <title>File System Test</title> + + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> + + <script type="text/javascript" src="head.js"></script> + <script type="text/javascript"> + add_task(async function worker() { + await run_test_in_worker("worker/test_basics_worker.js"); + }); + </script> +</head> + +<body></body> + +</html> diff --git a/dom/fs/test/mochitest/test_fileSystemDirectoryHandle.html b/dom/fs/test/mochitest/test_fileSystemDirectoryHandle.html new file mode 100644 index 0000000000..35f3a72e2f --- /dev/null +++ b/dom/fs/test/mochitest/test_fileSystemDirectoryHandle.html @@ -0,0 +1,28 @@ +<!-- + Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ +--> +<html> +<head> + <title>File System Test</title> + + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> + + <script type="text/javascript" src="head.js"></script> + <script type="text/javascript"> + add_task(async function init() { + const testSet = "dom/fs/test/common/test_fileSystemDirectoryHandle.js"; + + const testCases = await require_module(testSet); + + Object.values(testCases).forEach(testItem => { + add_task(testItem); + }); + }); + </script> +</head> + +<body></body> + +</html> diff --git a/dom/fs/test/mochitest/test_fileSystemDirectoryHandle_worker.html b/dom/fs/test/mochitest/test_fileSystemDirectoryHandle_worker.html new file mode 100644 index 0000000000..2f52079435 --- /dev/null +++ b/dom/fs/test/mochitest/test_fileSystemDirectoryHandle_worker.html @@ -0,0 +1,22 @@ +<!-- + Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ +--> +<html> +<head> + <title>File System Test</title> + + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> + + <script type="text/javascript" src="head.js"></script> + <script type="text/javascript"> + add_task(async function worker() { + await run_test_in_worker("worker/test_fileSystemDirectoryHandle_worker.js"); + }); + </script> +</head> + +<body></body> + +</html> diff --git a/dom/fs/test/mochitest/test_syncAccessHandle_worker.html b/dom/fs/test/mochitest/test_syncAccessHandle_worker.html new file mode 100644 index 0000000000..42980b1d55 --- /dev/null +++ b/dom/fs/test/mochitest/test_syncAccessHandle_worker.html @@ -0,0 +1,22 @@ +<!-- + Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ +--> +<html> +<head> + <title>File System Test</title> + + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> + + <script type="text/javascript" src="head.js"></script> + <script type="text/javascript"> + add_task(async function worker() { + await run_test_in_worker("worker/test_syncAccessHandle_worker.js"); + }); + </script> +</head> + +<body></body> + +</html> diff --git a/dom/fs/test/mochitest/test_writableFileStream.html b/dom/fs/test/mochitest/test_writableFileStream.html new file mode 100644 index 0000000000..3d39349ef5 --- /dev/null +++ b/dom/fs/test/mochitest/test_writableFileStream.html @@ -0,0 +1,31 @@ +<!-- + Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ +--> +<html> +<head> + <title>File System Test</title> + + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> + + <script type="text/javascript" src="head.js"></script> + <script type="text/javascript"> + add_task(async function init() { + const testSet = "dom/fs/test/common/test_writableFileStream.js"; + + const testCases = await require_module(testSet); + + Object.values(testCases).forEach(testItem => { + // We can't shrink storage size in a mochitest. + if (testItem.name != "quotaTest") { + add_task(testItem); + } + }); + }); + </script> +</head> + +<body></body> + +</html> diff --git a/dom/fs/test/mochitest/test_writableFileStream_worker.html b/dom/fs/test/mochitest/test_writableFileStream_worker.html new file mode 100644 index 0000000000..a762e78c3f --- /dev/null +++ b/dom/fs/test/mochitest/test_writableFileStream_worker.html @@ -0,0 +1,22 @@ +<!-- + Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ +--> +<html> +<head> + <title>File System Test</title> + + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> + + <script type="text/javascript" src="head.js"></script> + <script type="text/javascript"> + add_task(async function worker() { + await run_test_in_worker("worker/test_writableFileStream_worker.js"); + }); + </script> +</head> + +<body></body> + +</html> diff --git a/dom/fs/test/mochitest/worker/.eslintrc.js b/dom/fs/test/mochitest/worker/.eslintrc.js new file mode 100644 index 0000000000..93bf938654 --- /dev/null +++ b/dom/fs/test/mochitest/worker/.eslintrc.js @@ -0,0 +1,12 @@ +/** + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +"use strict"; + +module.exports = { + env: { + worker: true, + }, +}; diff --git a/dom/fs/test/mochitest/worker/dummy.js b/dom/fs/test/mochitest/worker/dummy.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/dom/fs/test/mochitest/worker/dummy.js diff --git a/dom/fs/test/mochitest/worker/head.js b/dom/fs/test/mochitest/worker/head.js new file mode 100644 index 0000000000..72e1869bde --- /dev/null +++ b/dom/fs/test/mochitest/worker/head.js @@ -0,0 +1,22 @@ +/** + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +async function require_module(id) { + if (!require_module.moduleLoader) { + importScripts("/tests/dom/quota/test/modules/worker/ModuleLoader.js"); + + const base = location.href; + + const depth = "../../../../../"; + + importScripts("/tests/dom/quota/test/modules/worker/Assert.js"); + + importScripts("/tests/dom/quota/test/modules/worker/Utils.js"); + + require_module.moduleLoader = new globalThis.ModuleLoader(base, depth); + } + + return require_module.moduleLoader.require(id); +} diff --git a/dom/fs/test/mochitest/worker/mochitest.ini b/dom/fs/test/mochitest/worker/mochitest.ini new file mode 100644 index 0000000000..9b5b2cbd98 --- /dev/null +++ b/dom/fs/test/mochitest/worker/mochitest.ini @@ -0,0 +1,14 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +[DEFAULT] +support-files = + head.js + test_basics_worker.js + test_fileSystemDirectoryHandle_worker.js + test_syncAccessHandle_worker.js + test_writableFileStream_worker.js + +[dummy.js] +skip-if = true diff --git a/dom/fs/test/mochitest/worker/test_basics_worker.js b/dom/fs/test/mochitest/worker/test_basics_worker.js new file mode 100644 index 0000000000..e4a4958071 --- /dev/null +++ b/dom/fs/test/mochitest/worker/test_basics_worker.js @@ -0,0 +1,11 @@ +/** + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +add_task(async function init() { + const testCases = await require_module("dom/fs/test/common/test_basics.js"); + Object.values(testCases).forEach(async testItem => { + add_task(testItem); + }); +}); diff --git a/dom/fs/test/mochitest/worker/test_fileSystemDirectoryHandle_worker.js b/dom/fs/test/mochitest/worker/test_fileSystemDirectoryHandle_worker.js new file mode 100644 index 0000000000..d4ba0b387c --- /dev/null +++ b/dom/fs/test/mochitest/worker/test_fileSystemDirectoryHandle_worker.js @@ -0,0 +1,13 @@ +/** + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +add_task(async function init() { + const testCases = await require_module( + "dom/fs/test/common/test_fileSystemDirectoryHandle.js" + ); + Object.values(testCases).forEach(async testItem => { + add_task(testItem); + }); +}); diff --git a/dom/fs/test/mochitest/worker/test_syncAccessHandle_worker.js b/dom/fs/test/mochitest/worker/test_syncAccessHandle_worker.js new file mode 100644 index 0000000000..be53a5a7e1 --- /dev/null +++ b/dom/fs/test/mochitest/worker/test_syncAccessHandle_worker.js @@ -0,0 +1,16 @@ +/** + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +add_task(async function init() { + const testCases = await require_module( + "dom/fs/test/common/test_syncAccessHandle.js" + ); + Object.values(testCases).forEach(async testItem => { + // We can't shrink storage size in a mochitest. + if (testItem.name != "quotaTest") { + add_task(testItem); + } + }); +}); diff --git a/dom/fs/test/mochitest/worker/test_writableFileStream_worker.js b/dom/fs/test/mochitest/worker/test_writableFileStream_worker.js new file mode 100644 index 0000000000..f294a719db --- /dev/null +++ b/dom/fs/test/mochitest/worker/test_writableFileStream_worker.js @@ -0,0 +1,16 @@ +/** + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +add_task(async function init() { + const testCases = await require_module( + "dom/fs/test/common/test_writableFileStream.js" + ); + Object.values(testCases).forEach(async testItem => { + // We can't shrink storage size in a mochitest. + if (testItem.name != "quotaTest") { + add_task(testItem); + } + }); +}); |