summaryrefslogtreecommitdiffstats
path: root/dom/fs/test/mochitest
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /dom/fs/test/mochitest
parentInitial commit. (diff)
downloadfirefox-e51783d008170d9ab27d25da98ca3a38b0a41b67.tar.xz
firefox-e51783d008170d9ab27d25da98ca3a38b0a41b67.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/fs/test/mochitest')
-rw-r--r--dom/fs/test/mochitest/head.js82
-rw-r--r--dom/fs/test/mochitest/mochitest.toml35
-rw-r--r--dom/fs/test/mochitest/test_basics.html28
-rw-r--r--dom/fs/test/mochitest/test_basics_worker.html22
-rw-r--r--dom/fs/test/mochitest/test_fileSystemDirectoryHandle.html28
-rw-r--r--dom/fs/test/mochitest/test_fileSystemDirectoryHandle_worker.html22
-rw-r--r--dom/fs/test/mochitest/test_syncAccessHandle_worker.html22
-rw-r--r--dom/fs/test/mochitest/test_writableFileStream.html31
-rw-r--r--dom/fs/test/mochitest/test_writableFileStream_worker.html22
-rw-r--r--dom/fs/test/mochitest/worker/.eslintrc.js12
-rw-r--r--dom/fs/test/mochitest/worker/dummy.js0
-rw-r--r--dom/fs/test/mochitest/worker/head.js22
-rw-r--r--dom/fs/test/mochitest/worker/mochitest.toml15
-rw-r--r--dom/fs/test/mochitest/worker/test_basics_worker.js11
-rw-r--r--dom/fs/test/mochitest/worker/test_fileSystemDirectoryHandle_worker.js13
-rw-r--r--dom/fs/test/mochitest/worker/test_syncAccessHandle_worker.js16
-rw-r--r--dom/fs/test/mochitest/worker/test_writableFileStream_worker.js16
17 files changed, 397 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..167e7c0c52
--- /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.mjs"
+ );
+
+ const base = window.location.href;
+
+ const depth = "../../../../";
+
+ const { Assert } = await import("/tests/dom/quota/test/modules/Assert.mjs");
+
+ const { Utils } = await import("/tests/dom/quota/test/modules/Utils.mjs");
+
+ 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.mjs"
+ );
+
+ 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.mjs"
+ );
+
+ 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.toml b/dom/fs/test/mochitest/mochitest.toml
new file mode 100644
index 0000000000..e138469768
--- /dev/null
+++ b/dom/fs/test/mochitest/mochitest.toml
@@ -0,0 +1,35 @@
+# 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"
+skip-if = [
+ "os == 'win'", # Bug 1841281
+ "os == 'linux' && debug", # Bug 1841281
+ "os == 'mac' && debug", # Bug 1841281
+]
+
+["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.toml b/dom/fs/test/mochitest/worker/mochitest.toml
new file mode 100644
index 0000000000..830c8f267d
--- /dev/null
+++ b/dom/fs/test/mochitest/worker/mochitest.toml
@@ -0,0 +1,15 @@
+# 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);
+ }
+ });
+});