Skip to content

Instantly share code, notes, and snippets.

@joewalker
Created July 31, 2013 20:58
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/6126097 to your computer and use it in GitHub Desktop.
Save joewalker/6126097 to your computer and use it in GitHub Desktop.
XPCOMUtils.defineLazyGetter(this, "require", function() {
let { require } = Cu.import("resource://gre/modules/devtools/Require.jsm", {});
Cu.import("resource://gre/modules/devtools/gcli.jsm", {});
return require;
});
XPCOMUtils.defineLazyGetter(this, "Requisition", () => require("gcli/cli").Requisition);
function execGcliCommand(command) {
let windowMediator = Cc["@mozilla.org/appshell/window-mediator;1"]
.getService(Ci.nsIWindowMediator);
let chromeWindow = windowMediator.getMostRecentWindow("navigator:browser");
let contentWindow = chromeWindow.gBrowser.selectedTab.linkedBrowser.contentWindow;
let environment = CommandUtils.createEnvironment(chromeWindow.document,
contentWindow.document);
// cache this
let requisition = new Requisition(environment);
requisition.updateExec(command).then(output => {
return output.promise.then(() => {
this.connection.send({
from: this.actorID,
requestId: request.requestId,
data: output.data,
type: output.type,
error: output.error
});
});
}).then(null, console.error);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment