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 --- .../test/unit/test_createCommandLine.js | 62 ++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 toolkit/components/commandlines/test/unit/test_createCommandLine.js (limited to 'toolkit/components/commandlines/test/unit/test_createCommandLine.js') diff --git a/toolkit/components/commandlines/test/unit/test_createCommandLine.js b/toolkit/components/commandlines/test/unit/test_createCommandLine.js new file mode 100644 index 0000000000..08c02981d9 --- /dev/null +++ b/toolkit/components/commandlines/test/unit/test_createCommandLine.js @@ -0,0 +1,62 @@ +/* Any copyright is dedicated to the Public Domain. +http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +add_task(async function test_createCommandLine() { + const EXISTING_FILE = do_get_file("xpcshell.toml"); + + // Test `arguments`. + let cmdLine = Cu.createCommandLine( + [], + null, + Ci.nsICommandLine.STATE_REMOTE_EXPLICIT + ); + Assert.equal(cmdLine.length, 0); + Assert.throws(() => cmdLine.workingDirectory, /NS_ERROR_NOT_INITIALIZED/); + Assert.equal(cmdLine.state, Ci.nsICommandLine.STATE_REMOTE_EXPLICIT); + + cmdLine = Cu.createCommandLine( + ["test"], + null, + Ci.nsICommandLine.STATE_REMOTE_EXPLICIT + ); + Assert.equal(cmdLine.length, 1); + Assert.equal(cmdLine.getArgument(0), "test"); + Assert.throws(() => cmdLine.getArgument(1), /NS_ERROR_ILLEGAL_VALUE/); + Assert.throws(() => cmdLine.workingDirectory, /NS_ERROR_NOT_INITIALIZED/); + Assert.equal(cmdLine.state, Ci.nsICommandLine.STATE_REMOTE_EXPLICIT); + + cmdLine = Cu.createCommandLine( + ["test1", "test2"], + null, + Ci.nsICommandLine.STATE_REMOTE_EXPLICIT + ); + Assert.equal(cmdLine.length, 2); + Assert.equal(cmdLine.getArgument(0), "test1"); + Assert.equal(cmdLine.getArgument(1), "test2"); + Assert.throws(() => cmdLine.getArgument(2), /NS_ERROR_ILLEGAL_VALUE/); + Assert.throws(() => cmdLine.workingDirectory, /NS_ERROR_NOT_INITIALIZED/); + Assert.equal(cmdLine.state, Ci.nsICommandLine.STATE_REMOTE_EXPLICIT); + + // Test `workingDirectory`. + cmdLine = Cu.createCommandLine( + [], + EXISTING_FILE.parent, + Ci.nsICommandLine.STATE_REMOTE_AUTO + ); + Assert.equal(cmdLine.length, 0); + Assert.equal(cmdLine.workingDirectory.path, EXISTING_FILE.parent.path); + Assert.equal(cmdLine.state, Ci.nsICommandLine.STATE_REMOTE_AUTO); + + // Test `state`. + cmdLine = Cu.createCommandLine([], null, Ci.nsICommandLine.STATE_REMOTE_AUTO); + Assert.equal(cmdLine.state, Ci.nsICommandLine.STATE_REMOTE_AUTO); + + cmdLine = Cu.createCommandLine( + [], + EXISTING_FILE.parent, + Ci.nsICommandLine.STATE_REMOTE_EXPLICIT + ); + Assert.equal(cmdLine.state, Ci.nsICommandLine.STATE_REMOTE_EXPLICIT); +}); -- cgit v1.2.3