Backed out 2 changesets (bug 1742879) for causing build bustage in nsDebug.h CLOSED TREE

Backed out changeset 994d0986757c (bug 1742879)
Backed out changeset d4b8e45faaec (bug 1742879)
This commit is contained in:
Noemi Erli 2021-12-02 09:34:25 +02:00
Родитель 1fc2098688
Коммит 4aa2f8759e
15 изменённых файлов: 157 добавлений и 218 удалений

Просмотреть файл

@ -92,11 +92,70 @@ async function assertOneRemoteBrowserShown(
* @returns nsICommandLine
*/
function constructOnePageCmdLine(aURL) {
return Cu.createCommandLine(
["-url", aURL],
null,
Ci.nsICommandLine.STATE_INITIAL_LAUNCH
);
return {
_arg: aURL,
_argCount: 1,
get length() {
return this._argCount;
},
getArgument(aIndex) {
if (aIndex == 0 && this._argCount) {
return this._arg;
}
throw Components.Exception("", Cr.NS_ERROR_INVALID_ARG);
},
findFlag() {
return -1;
},
removeArguments() {
throw Components.Exception("", Cr.NS_ERROR_NOT_IMPLEMENTED);
},
handleFlag() {
throw Components.Exception("", Cr.NS_ERROR_NOT_IMPLEMENTED);
},
handleFlagWithParam() {
if (this._argCount) {
this._argCount = 0;
return this._arg;
}
return "";
},
get state() {
return 0;
},
STATE_INITIAL_LAUNCH: 0,
STATE_REMOTE_AUTO: 1,
STATE_REMOTE_EXPLICIT: 2,
preventDefault: false,
get workingDirectory() {
throw Components.Exception("", Cr.NS_ERROR_NOT_IMPLEMENTED);
},
get windowContext() {
throw Components.Exception("", Cr.NS_ERROR_NOT_IMPLEMENTED);
},
resolveFile() {
throw Components.Exception("", Cr.NS_ERROR_NOT_IMPLEMENTED);
},
resolveURI() {
return Services.io.newURI(this._arg);
},
QueryInterface: ChromeUtils.generateQI(["nsICommandLine"]),
};
}
add_task(async function setup() {
@ -115,11 +174,7 @@ add_task(async function setup() {
* This tests the default case, where no arguments are passed.
*/
add_task(async function test_default_args_and_homescreen() {
let cmdLine = Cu.createCommandLine(
[],
null,
Ci.nsICommandLine.STATE_INITIAL_LAUNCH
);
let cmdLine = Cu.createCommandLine();
await assertOneRemoteBrowserShown(
cmdLine,
"about:home",

Просмотреть файл

@ -670,22 +670,8 @@ interface nsIXPCComponents_Utils : nsISupports
/* Create a spellchecker object. */
nsIEditorSpellCheck createSpellChecker();
/* Create a commandline object.
*
* @return a new `nsICommandLine` instance.
*
* @param args
* The arguments of the command line, not including the app/program itself.
* @param workingDir
* An optional working directory for the command line.
* @param state
* The command line's state, one of `nsICommandLine.STATE_INITIAL_LAUNCH`,
* `nsICommandLine.STATE_REMOTE_AUTO`, or
* `nsICommandLine.STATE_REMOTE_EXPLICIT`.
*/
nsISupports createCommandLine(in Array<ACString> args,
in nsIFile workingDir,
in unsigned long state);
/* Create a commandline object. */
nsISupports createCommandLine([optional] in nsIFile aWorkingDir);
/* Create a command params object. */
nsICommandParams createCommandParams();

Просмотреть файл

@ -2442,29 +2442,15 @@ nsXPCComponents_Utils::CreateSpellChecker(nsIEditorSpellCheck** aSpellChecker) {
}
NS_IMETHODIMP
nsXPCComponents_Utils::CreateCommandLine(const nsTArray<nsCString>& aArgs,
nsIFile* aWorkingDir, uint32_t aState,
nsXPCComponents_Utils::CreateCommandLine(nsIFile* aWorkingDir,
nsISupports** aCommandLine) {
NS_ENSURE_ARG_MIN(aState, nsICommandLine::STATE_INITIAL_LAUNCH);
NS_ENSURE_ARG_MAX(aState, nsICommandLine::STATE_REMOTE_EXPLICIT);
NS_ENSURE_ARG_POINTER(aCommandLine);
nsCOMPtr<nsISupports> commandLine = new nsCommandLine();
if (aWorkingDir) {
nsCOMPtr<nsICommandLineRunner> runner = do_QueryInterface(commandLine);
nsTArray<const char*> fakeArgv(aArgs.Length() + 2);
// Prepend a dummy argument for the program name, which will be ignored.
fakeArgv.AppendElement(nullptr);
for (const nsCString& arg : aArgs) {
fakeArgv.AppendElement(arg.get());
char* argv[] = {nullptr};
runner->Init(0, argv, aWorkingDir, nsICommandLine::STATE_REMOTE_EXPLICIT);
}
// Append a null terminator.
fakeArgv.AppendElement(nullptr);
nsresult rv = runner->Init(fakeArgv.Length() - 1, fakeArgv.Elements(),
aWorkingDir, aState);
NS_ENSURE_SUCCESS(rv, rv);
commandLine.forget(aCommandLine);
return NS_OK;

Просмотреть файл

@ -149,7 +149,7 @@ function run_test() {
attribute: "callback"
});
let cmdline = Cu.createCommandLine([], null, Ci.nsICommandLine.STATE_INITIAL_LAUNCH);
let cmdline = Cu.createCommandLine();
test_twice(cmdline, {});
test_twice(Object.getPrototypeOf(cmdline), {

Просмотреть файл

@ -39,7 +39,7 @@ interface nsICommandLine : nsISupports
* @param aIndex The argument to retrieve. This index is 0-based, and does
* not include the application name.
* @return The indexth argument.
* @throws NS_ERROR_ILLEGAL_VALUE if aIndex is out of bounds.
* @throws NS_ERROR_INVALID_ARG if aIndex is out of bounds.
*/
AString getArgument(in long aIndex);

Просмотреть файл

@ -1,9 +1,5 @@
function run_test() {
var cmdLine = Cu.createCommandLine(
[],
null,
Ci.nsICommandLine.STATE_INITIAL_LAUNCH
);
var cmdLine = Cu.createCommandLine();
try {
cmdLine.getArgument(cmdLine.length);
} catch (e) {}

Просмотреть файл

@ -3,10 +3,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
function run_test() {
var commandLine = Cu.createCommandLine(
[],
null,
Ci.nsICommandLine.STATE_INITIAL_LAUNCH
);
var commandLine = Cu.createCommandLine();
Assert.ok("length" in commandLine);
}

Просмотреть файл

@ -1,62 +0,0 @@
/* 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.ini");
// 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);
});

Просмотреть файл

@ -1,66 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
const { AppConstants } = ChromeUtils.import(
"resource://gre/modules/AppConstants.jsm"
);
add_task(async function test_handleFlagWithParam() {
let goodInputs = [
["-arg", "value"],
["--arg", "value"],
["-arg=value"],
["--arg=value"],
];
let badInputs = [["-arg", "-value"]];
// Accepted only on Windows. Perhaps surprisingly, "/arg=value" is not accepted.
let windowsInputs = [["/arg", "value"], ["/arg:value"]];
if (AppConstants.platform == "win") {
goodInputs.push(...windowsInputs);
}
for (let args of goodInputs) {
let cmdLine = Cu.createCommandLine(
args,
null,
Ci.nsICommandLine.STATE_REMOTE_EXPLICIT
);
Assert.equal(
cmdLine.handleFlagWithParam("arg", false),
"value",
`${JSON.stringify(args)} yields 'value' for 'arg'`
);
}
for (let args of badInputs) {
let cmdLine = Cu.createCommandLine(
args,
null,
Ci.nsICommandLine.STATE_REMOTE_EXPLICIT
);
Assert.throws(
() => cmdLine.handleFlagWithParam("arg", false),
/NS_ERROR_ILLEGAL_VALUE/,
`${JSON.stringify(args)} throws for 'arg'`
);
}
if (AppConstants.platform != "win") {
// No special meaning on non-Windows platforms.
for (let args of windowsInputs) {
let cmdLine = Cu.createCommandLine(
args,
null,
Ci.nsICommandLine.STATE_REMOTE_EXPLICIT
);
Assert.equal(
cmdLine.handleFlagWithParam("arg", false),
null,
`${JSON.stringify(args)} yields null for 'arg'`
);
}
}
});

Просмотреть файл

@ -3,14 +3,12 @@ http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
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 cmdLine = Cu.createCommandLine();
let fileByPath = cmdLine.resolveFile(EXISTING_FILE.path);
info("Resolved: " + fileByPath.path);
Assert.ok(EXISTING_FILE.equals(fileByPath), "Should find the same file");
@ -21,11 +19,7 @@ add_task(async function test_resolveFile() {
);
// Now create a commandline with a working dir:
cmdLine = Cu.createCommandLine(
[],
EXISTING_FILE.parent,
Ci.nsICommandLine.STATE_REMOTE_EXPLICIT
);
cmdLine = Cu.createCommandLine(EXISTING_FILE.parent);
let resolvedTxtFile = cmdLine.resolveFile("xpcshell.ini");
info("Resolved: " + resolvedTxtFile.path);

Просмотреть файл

@ -5,8 +5,6 @@ support-files =
data/test_bug410156.desktop
data/test_bug410156.url
[test_bug666224.js]
[test_classinfo.js]
[test_createCommandLine.js]
[test_handleFlagWithParam.js]
[test_bug666224.js]
[test_resolvefile.js]

Просмотреть файл

@ -3,11 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
function run_test() {
var commandLine = Cu.createCommandLine(
[],
null,
Ci.nsICommandLine.STATE_INITIAL_LAUNCH
);
var commandLine = Cu.createCommandLine();
var urlFile = do_get_file("../unit/data/test_bug410156.desktop");
var uri = commandLine.resolveURI(urlFile.path);
Assert.equal(uri.spec, "http://www.bug410156.com/");

Просмотреть файл

@ -3,11 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
function run_test() {
var commandLine = Cu.createCommandLine(
[],
null,
Ci.nsICommandLine.STATE_INITIAL_LAUNCH
);
var commandLine = Cu.createCommandLine();
var urlFile = do_get_file("../unit/data/test_bug410156.url");
var uri = commandLine.resolveURI(urlFile.path);
Assert.equal(uri.spec, "http://www.bug410156.com/");

Просмотреть файл

@ -164,11 +164,43 @@ add_task(async function test_protocolHandler() {
let cmdLineHandler = Cc["@mozilla.org/browser/final-clh;1"].getService(
Ci.nsICommandLineHandler
);
let fakeCmdLine = Cu.createCommandLine(
["-url", "ext+foo:cmdline"],
null,
Ci.nsICommandLine.STATE_REMOTE_EXPLICIT
);
let fakeCmdLine = {
length: 1,
_arg: "ext+foo:cmdline",
getArgument(index) {
if (index == 0) {
return this._arg;
}
throw Components.Exception("", Cr.NS_ERROR_INVALID_ARG);
},
findFlag() {
return -1;
},
handleFlagWithParam() {
if (this._argCount) {
this._argCount = 0;
return this._arg;
}
return "";
},
state: 2,
STATE_INITIAL_LAUNCH: 0,
STATE_REMOTE_AUTO: 1,
STATE_REMOTE_EXPLICIT: 2,
preventDefault: false,
resolveURI() {
return Services.io.newURI(this._arg);
},
QueryInterface: ChromeUtils.generateQI(["nsICommandLine"]),
};
cmdLineHandler.handle(fakeCmdLine);
});
query = await extension.awaitMessage("test-query");

Просмотреть файл

@ -52,11 +52,43 @@ function initTestHandlers() {
}
function makeCmdLineHelper(url) {
return Cu.createCommandLine(
["-url", url],
null,
Ci.nsICommandLine.STATE_REMOTE_EXPLICIT
);
return {
length: 1,
_arg: url,
getArgument(aIndex) {
if (aIndex == 0) {
return this._arg;
}
throw Components.Exception("", Cr.NS_ERROR_INVALID_ARG);
},
findFlag() {
return -1;
},
handleFlagWithParam() {
if (this._argCount) {
this._argCount = 0;
return this._arg;
}
return "";
},
state: 2,
STATE_INITIAL_LAUNCH: 0,
STATE_REMOTE_AUTO: 1,
STATE_REMOTE_EXPLICIT: 2,
preventDefault: false,
resolveURI() {
return Services.io.newURI(this._arg);
},
QueryInterface: ChromeUtils.generateQI(["nsICommandLine"]),
};
}
add_task(async function setup() {