From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../commandlines/test/unit/test_resolvefile.js | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 toolkit/components/commandlines/test/unit/test_resolvefile.js (limited to 'toolkit/components/commandlines/test/unit/test_resolvefile.js') 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..2c1d01b049 --- /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.toml"); + // 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.toml"), + "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.toml"); + + info("Resolved: " + resolvedTxtFile.path); + Assert.ok( + EXISTING_FILE.equals(resolvedTxtFile), + "Should resolve relative file." + ); +}); -- cgit v1.2.3