mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 773347 - GCLI hidden commands don't execute properly; r=harth
This commit is contained in:
parent
8f31a4fa6e
commit
ff781144b2
@ -20,6 +20,8 @@ XPCOMUtils.defineLazyModuleGetter(this, "NetUtil",
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "console",
|
||||
"resource:///modules/devtools/Console.jsm");
|
||||
|
||||
const PREF_DIR = "devtools.commands.dir";
|
||||
|
||||
/**
|
||||
* A place to store the names of the commands that we have added as a result of
|
||||
* calling refreshAutoCommands(). Used by refreshAutoCommands to remove the
|
||||
@ -43,8 +45,8 @@ let CmdCommands = {
|
||||
gcli.removeCommand(name);
|
||||
});
|
||||
|
||||
let dirName = prefBranch.getComplexValue("devtools.commands.dir",
|
||||
Ci.nsISupportsString).data;
|
||||
let dirName = prefBranch.getComplexValue(PREF_DIR,
|
||||
Ci.nsISupportsString).data.trim();
|
||||
if (dirName == "") {
|
||||
return;
|
||||
}
|
||||
@ -109,8 +111,8 @@ function loadCommandFile(aFile, aSandboxPrincipal) {
|
||||
*/
|
||||
gcli.addCommand({
|
||||
name: "cmd",
|
||||
description: gcli.lookup("cmdDesc"),
|
||||
hidden: true
|
||||
get hidden() { return !prefBranch.prefHasUserValue(PREF_DIR); },
|
||||
description: gcli.lookup("cmdDesc")
|
||||
});
|
||||
|
||||
/**
|
||||
@ -119,8 +121,9 @@ gcli.addCommand({
|
||||
gcli.addCommand({
|
||||
name: "cmd refresh",
|
||||
description: gcli.lookup("cmdRefreshDesc"),
|
||||
hidden: true,
|
||||
get hidden() { return !prefBranch.prefHasUserValue(PREF_DIR); },
|
||||
exec: function Command_cmdRefresh(args, context) {
|
||||
GcliCmdCommands.refreshAutoCommands(context.environment.chromeDocument.defaultView);
|
||||
let chromeWindow = context.environment.chromeDocument.defaultView;
|
||||
GcliCommands.refreshAutoCommands(chromeWindow);
|
||||
}
|
||||
});
|
||||
|
@ -1797,11 +1797,22 @@ SelectionType.prototype._findPredictions = function(arg) {
|
||||
}
|
||||
}
|
||||
|
||||
// Exact hidden matches. If 'hidden: true' then we only allow exact matches
|
||||
// All the tests after here check that !option.value.hidden
|
||||
for (i = 0; i < lookup.length && predictions.length < maxPredictions; i++) {
|
||||
option = lookup[i];
|
||||
if (option.name === arg.text) {
|
||||
this._addToPredictions(predictions, option, arg);
|
||||
}
|
||||
}
|
||||
|
||||
// Start with prefix matching
|
||||
for (i = 0; i < lookup.length && predictions.length < maxPredictions; i++) {
|
||||
option = lookup[i];
|
||||
if (option._gcliLowerName.indexOf(match) === 0) {
|
||||
this._addToPredictions(predictions, option, arg);
|
||||
if (option._gcliLowerName.indexOf(match) === 0 && !option.value.hidden) {
|
||||
if (predictions.indexOf(option) === -1) {
|
||||
this._addToPredictions(predictions, option, arg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1809,7 +1820,7 @@ SelectionType.prototype._findPredictions = function(arg) {
|
||||
if (predictions.length < (maxPredictions / 2)) {
|
||||
for (i = 0; i < lookup.length && predictions.length < maxPredictions; i++) {
|
||||
option = lookup[i];
|
||||
if (option._gcliLowerName.indexOf(match) !== -1) {
|
||||
if (option._gcliLowerName.indexOf(match) !== -1 && !option.value.hidden) {
|
||||
if (predictions.indexOf(option) === -1) {
|
||||
this._addToPredictions(predictions, option, arg);
|
||||
}
|
||||
@ -2191,9 +2202,6 @@ CommandType.prototype.lookup = function() {
|
||||
* Add an option to our list of predicted options
|
||||
*/
|
||||
CommandType.prototype._addToPredictions = function(predictions, option, arg) {
|
||||
if (option.value.hidden) {
|
||||
return;
|
||||
}
|
||||
// The command type needs to exclude sub-commands when the CLI
|
||||
// is blank, but include them when we're filtering. This hack
|
||||
// excludes matches when the filter text is '' and when the
|
||||
@ -2509,6 +2517,16 @@ Object.defineProperty(Parameter.prototype, 'isDataRequired', {
|
||||
enumerable: true
|
||||
});
|
||||
|
||||
/**
|
||||
* Reflect the paramSpec 'hidden' property (dynamically so it can change)
|
||||
*/
|
||||
Object.defineProperty(Parameter.prototype, 'hidden', {
|
||||
get: function() {
|
||||
return this.paramSpec.hidden;
|
||||
},
|
||||
enumerable: true
|
||||
});
|
||||
|
||||
/**
|
||||
* Are we allowed to assign data to this parameter using positional
|
||||
* parameters?
|
||||
|
@ -13,13 +13,11 @@ function test() {
|
||||
}
|
||||
|
||||
function testEcho() {
|
||||
/*
|
||||
DeveloperToolbarTest.exec({
|
||||
typed: "echo message",
|
||||
args: { message: "message" },
|
||||
outputMatch: /^message$/,
|
||||
});
|
||||
*/
|
||||
}
|
||||
|
||||
function testConsole(browser, tab) {
|
||||
|
@ -7,7 +7,7 @@ const TEST_URI = "http://example.com/browser/browser/devtools/commandline/" +
|
||||
"test/browser_cmd_jsb_script.jsi";
|
||||
|
||||
function test() {
|
||||
DeveloperToolbarTest.test("about:blank", [ /*GJT_test*/ ]);
|
||||
DeveloperToolbarTest.test("about:blank", [ GJT_test ]);
|
||||
}
|
||||
|
||||
function GJT_test() {
|
||||
|
@ -1733,6 +1733,7 @@ exports.setup = function() {
|
||||
canon.addCommand(exports.tselarr);
|
||||
canon.addCommand(exports.tsm);
|
||||
canon.addCommand(exports.tsg);
|
||||
canon.addCommand(exports.tshidden);
|
||||
canon.addCommand(exports.tscook);
|
||||
};
|
||||
|
||||
@ -1757,6 +1758,7 @@ exports.shutdown = function() {
|
||||
canon.removeCommand(exports.tselarr);
|
||||
canon.removeCommand(exports.tsm);
|
||||
canon.removeCommand(exports.tsg);
|
||||
canon.removeCommand(exports.tshidden);
|
||||
canon.removeCommand(exports.tscook);
|
||||
|
||||
types.deregisterType(exports.optionType);
|
||||
@ -1911,6 +1913,38 @@ exports.tsnDeepDownNestedCmd = {
|
||||
exec: createExec('tsnDeepDownNestedCmd')
|
||||
};
|
||||
|
||||
exports.tshidden = {
|
||||
name: 'tshidden',
|
||||
hidden: true,
|
||||
params: [
|
||||
{
|
||||
group: 'Options',
|
||||
params: [
|
||||
{
|
||||
name: 'visible',
|
||||
type: 'string',
|
||||
defaultValue: null,
|
||||
description: 'visible'
|
||||
},
|
||||
{
|
||||
name: 'invisiblestring',
|
||||
type: 'string',
|
||||
description: 'invisiblestring',
|
||||
defaultValue: null,
|
||||
hidden: true
|
||||
},
|
||||
{
|
||||
name: 'invisibleboolean',
|
||||
type: 'boolean',
|
||||
description: 'invisibleboolean',
|
||||
hidden: true
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
exec: createExec('tshidden')
|
||||
};
|
||||
|
||||
exports.tselarr = {
|
||||
name: 'tselarr',
|
||||
params: [
|
||||
@ -3010,6 +3044,122 @@ exports.testIncomplete = function(options) {
|
||||
'unassigned.isIncompleteName: tsg -');
|
||||
};
|
||||
|
||||
exports.testHidden = function(options) {
|
||||
helpers.setInput('tshidde');
|
||||
helpers.check({
|
||||
input: 'tshidde',
|
||||
markup: 'EEEEEEE',
|
||||
directTabText: '',
|
||||
arrowTabText: '',
|
||||
status: 'ERROR',
|
||||
emptyParameters: [ ],
|
||||
});
|
||||
|
||||
helpers.setInput('tshidden');
|
||||
helpers.check({
|
||||
input: 'tshidden',
|
||||
markup: 'VVVVVVVV',
|
||||
directTabText: '',
|
||||
arrowTabText: '',
|
||||
status: 'VALID',
|
||||
emptyParameters: [ ],
|
||||
args: {
|
||||
visible: { value: undefined, status: 'VALID' },
|
||||
invisiblestring: { value: undefined, status: 'VALID' },
|
||||
invisibleboolean: { value: undefined, status: 'VALID' }
|
||||
}
|
||||
});
|
||||
|
||||
helpers.setInput('tshidden --vis');
|
||||
helpers.check({
|
||||
input: 'tshidden --vis',
|
||||
markup: 'VVVVVVVVVIIIII',
|
||||
directTabText: 'ible',
|
||||
arrowTabText: '',
|
||||
status: 'ERROR',
|
||||
emptyParameters: [ ],
|
||||
args: {
|
||||
visible: { value: undefined, status: 'VALID' },
|
||||
invisiblestring: { value: undefined, status: 'VALID' },
|
||||
invisibleboolean: { value: undefined, status: 'VALID' }
|
||||
}
|
||||
});
|
||||
|
||||
helpers.setInput('tshidden --invisiblestrin');
|
||||
helpers.check({
|
||||
input: 'tshidden --invisiblestrin',
|
||||
markup: 'VVVVVVVVVEEEEEEEEEEEEEEEE',
|
||||
directTabText: '',
|
||||
arrowTabText: '',
|
||||
status: 'ERROR',
|
||||
emptyParameters: [ ],
|
||||
args: {
|
||||
visible: { value: undefined, status: 'VALID' },
|
||||
invisiblestring: { value: undefined, status: 'VALID' },
|
||||
invisibleboolean: { value: undefined, status: 'VALID' }
|
||||
}
|
||||
});
|
||||
|
||||
helpers.setInput('tshidden --invisiblestring');
|
||||
helpers.check({
|
||||
input: 'tshidden --invisiblestring',
|
||||
markup: 'VVVVVVVVVIIIIIIIIIIIIIIIII',
|
||||
directTabText: '',
|
||||
arrowTabText: '',
|
||||
status: 'ERROR',
|
||||
emptyParameters: [ ],
|
||||
args: {
|
||||
visible: { value: undefined, status: 'VALID' },
|
||||
invisiblestring: { value: undefined, status: 'INCOMPLETE' },
|
||||
invisibleboolean: { value: undefined, status: 'VALID' }
|
||||
}
|
||||
});
|
||||
|
||||
helpers.setInput('tshidden --invisiblestring x');
|
||||
helpers.check({
|
||||
input: 'tshidden --invisiblestring x',
|
||||
markup: 'VVVVVVVVVVVVVVVVVVVVVVVVVVVV',
|
||||
directTabText: '',
|
||||
arrowTabText: '',
|
||||
status: 'VALID',
|
||||
emptyParameters: [ ],
|
||||
args: {
|
||||
visible: { value: undefined, status: 'VALID' },
|
||||
invisiblestring: { value: 'x', status: 'VALID' },
|
||||
invisibleboolean: { value: undefined, status: 'VALID' }
|
||||
}
|
||||
});
|
||||
|
||||
helpers.setInput('tshidden --invisibleboolea');
|
||||
helpers.check({
|
||||
input: 'tshidden --invisibleboolea',
|
||||
markup: 'VVVVVVVVVEEEEEEEEEEEEEEEEE',
|
||||
directTabText: '',
|
||||
arrowTabText: '',
|
||||
status: 'ERROR',
|
||||
emptyParameters: [ ],
|
||||
args: {
|
||||
visible: { value: undefined, status: 'VALID' },
|
||||
invisiblestring: { value: undefined, status: 'VALID' },
|
||||
invisibleboolean: { value: undefined, status: 'VALID' }
|
||||
}
|
||||
});
|
||||
|
||||
helpers.setInput('tshidden --invisibleboolean');
|
||||
helpers.check({
|
||||
input: 'tshidden --invisibleboolean',
|
||||
markup: 'VVVVVVVVVVVVVVVVVVVVVVVVVVV',
|
||||
directTabText: '',
|
||||
arrowTabText: '',
|
||||
status: 'VALID',
|
||||
emptyParameters: [ ],
|
||||
args: {
|
||||
visible: { value: undefined, status: 'VALID' },
|
||||
invisiblestring: { value: undefined, status: 'VALID' },
|
||||
invisibleboolean: { value: true, status: 'VALID' }
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
});
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user