Created
July 31, 2013 20:58
-
-
Save joewalker/6126097 to your computer and use it in GitHub Desktop.
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
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