Skip to content

Instantly share code, notes, and snippets.

@joewalker
Created July 4, 2012 18:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joewalker/3048788 to your computer and use it in GitHub Desktop.
Save joewalker/3048788 to your computer and use it in GitHub Desktop.
Bug 767900 - GCLI needs a command to enable execution of XUL Commands
Components.utils.import("resource:///modules/devtools/gcli.jsm");
gcli.addCommand({
name: 'xulcommand',
description: 'Run a XUL Command',
params: [
{
name: 'command',
type: {
name: 'selection',
lookup: function() {
var items = [];
var nodes = window.document.querySelectorAll('command');
Array.prototype.forEach.call(nodes, function(command) {
if (!command.disabled) {
items.push({ name: command.id, value: command });
}
});
items.sort(function(item1, item2) {
return item1.name.localeCompare(item2.name);
});
return items;
}
},
description: 'Command to run',
}
],
exec: function(args, context) {
try {
return args.command.doCommand();
}
catch (ex) {
throw new Error("An error occurred executing " + args.command.id + " (" + ex + ")");
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment