summaryrefslogtreecommitdiffstats
path: root/toolkit/components/commandlines/test/unit/test_resolvefile.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /toolkit/components/commandlines/test/unit/test_resolvefile.js
parentInitial commit. (diff)
downloadthunderbird-upstream.tar.xz
thunderbird-upstream.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 'toolkit/components/commandlines/test/unit/test_resolvefile.js')
-rw-r--r--toolkit/components/commandlines/test/unit/test_resolvefile.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/toolkit/components/commandlines/test/unit/test_resolvefile.js b/toolkit/components/commandlines/test/unit/test_resolvefile.js
new file mode 100644
index 0000000000..ce4d2dba8d
--- /dev/null
+++ b/toolkit/components/commandlines/test/unit/test_resolvefile.js
@@ -0,0 +1,36 @@
+/* Any copyright is dedicated to the Public Domain.
+http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+add_task(async function test_resolveFile() {
+ const EXISTING_FILE = do_get_file("xpcshell.ini");
+ // We explicitly do not initialize this with a working dir.
+ let cmdLine = Cu.createCommandLine(
+ [],
+ null,
+ Ci.nsICommandLine.STATE_REMOTE_EXPLICIT
+ );
+ let fileByPath = cmdLine.resolveFile(EXISTING_FILE.path);
+ info("Resolved: " + fileByPath.path);
+ Assert.ok(EXISTING_FILE.equals(fileByPath), "Should find the same file");
+
+ Assert.ok(
+ !cmdLine.resolveFile("xpcshell.ini"),
+ "Should get null for relative files."
+ );
+
+ // Now create a commandline with a working dir:
+ cmdLine = Cu.createCommandLine(
+ [],
+ EXISTING_FILE.parent,
+ Ci.nsICommandLine.STATE_REMOTE_EXPLICIT
+ );
+ let resolvedTxtFile = cmdLine.resolveFile("xpcshell.ini");
+
+ info("Resolved: " + resolvedTxtFile.path);
+ Assert.ok(
+ EXISTING_FILE.equals(resolvedTxtFile),
+ "Should resolve relative file."
+ );
+});