Created
July 4, 2012 18:31
-
-
Save joewalker/3048788 to your computer and use it in GitHub Desktop.
Bug 767900 - GCLI needs a command to enable execution of XUL Commands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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