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/system/tests/ioutils/test_ioutils_mac_xattr.html | |
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/system/tests/ioutils/test_ioutils_mac_xattr.html')
-rw-r--r-- | dom/system/tests/ioutils/test_ioutils_mac_xattr.html | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/dom/system/tests/ioutils/test_ioutils_mac_xattr.html b/dom/system/tests/ioutils/test_ioutils_mac_xattr.html new file mode 100644 index 0000000000..cd6e7aeb5d --- /dev/null +++ b/dom/system/tests/ioutils/test_ioutils_mac_xattr.html @@ -0,0 +1,90 @@ +<!-- Any copyright is dedicated to the Public Domain. +- http://creativecommons.org/publicdomain/zero/1.0/ --> +<!DOCTYPE HTML> +<html> + +<head> + <meta charset="utf-8"> + <title>Test the IOUtils file I/O API</title> + <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" href="chrome://mochikit/content/tests/SimpleTest/test.css" /> + <script src="file_ioutils_test_fixtures.js"></script> + <script> + "use strict"; + + const { Assert } = ChromeUtils.import("resource://testing-common/Assert.jsm"); + const { FileUtils } = ChromeUtils.import("resource://gre/modules/FileUtils.jsm"); + + const ATTR = "bogus.attr"; + const VALUE = new TextEncoder().encode("bogus"); + + add_task(async function test_macXAttr() { + const tmpDir = PathUtils.join(PathUtils.tempDir, "ioutils-macos-xattr.tmp.d"); + + await createDir(tmpDir); + + const path = PathUtils.join(tmpDir, "file.tmp"); + ok(!await IOUtils.exists(path), "File should not exist"); + await IOUtils.writeUTF8(path, ""); + + ok( + !await IOUtils.hasMacXAttr(path, ATTR), + "File does not have an extended attribute at creation" + ); + + info("Testing getting an attribute that does not exist"); + await Assert.rejects( + IOUtils.getMacXAttr(path, ATTR), + /NotFoundError: The file `.+' does not have an extended attribute/, + "IOUtils::getMacXAttr rejects when the attribute does not exist" + ); + + info("Testing setting an attribute"); + await IOUtils.setMacXAttr(path, ATTR, VALUE); + ok( + await IOUtils.hasMacXAttr(path, ATTR), + "File has extended attribute after setting" + ); + + { + info("Testing getting an attribute") + const value = await IOUtils.getMacXAttr(path, ATTR); + Assert.deepEqual( + Array.from(value), + Array.from(VALUE), + "Attribute value should match" + ); + } + + info("Testing removing an attribute"); + await IOUtils.delMacXAttr(path, ATTR); + await Assert.rejects( + IOUtils.getMacXAttr(path, ATTR), + /NotFoundError: The file `.+' does not have an extended attribute/, + "IOUtils::delMacXAttr removes the attribute" + ); + + ok( + !await IOUtils.hasMacXAttr(path, ATTR), + "File does not have extended attribute after removing" + ); + + info("Testing removing an attribute that does not exist"); + await Assert.rejects( + IOUtils.delMacXAttr(path, ATTR), + /NotFoundError: The file `.+' does not have an extended attribute/, + "IOUtils::delMacXAttr rejects when the attribute does not exist" + ); + + await cleanup(tmpDir); + }); + </script> +</head> + +<body> + <p id="display"></p> + <div id="content" style="display: none"></div> + <pre id="test"></pre> +</body> + +</html> |