1
0
Fork 0
firefox/toolkit/components/commandlines/test/unit/test_resolvefile.js
Daniel Baumann 5e9a113729
Adding upstream version 140.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-25 09:37:52 +02:00

36 lines
1 KiB
JavaScript

/* 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."
);
});