Bug 1107706: Part 14: Fix quitApplication

This commit is contained in:
Andreas Tolfsen 2015-03-20 20:44:17 +00:00
parent a3c22d4b07
commit 40da952834
2 changed files with 10 additions and 2 deletions

View File

@ -31,8 +31,10 @@ const uuidGen = Cc["@mozilla.org/uuid-generator;1"].getService(Ci.nsIUUIDGenerat
* @param {function(Emulator): GeckoDriver} driverFactory
* A factory function that takes an Emulator as argument and produces
* a GeckoDriver.
* @param {function()} stopSignal
* Signal to stop the Marionette server.
*/
this.Dispatcher = function(connId, transport, driverFactory) {
this.Dispatcher = function(connId, transport, driverFactory, stopSignal) {
this.id = connId;
this.conn = transport;
@ -52,6 +54,8 @@ this.Dispatcher = function(connId, transport, driverFactory) {
this.emulator = new Emulator(msg => this.sendResponse(msg, -1));
this.driver = driverFactory(this.emulator);
this.commandProcessor = new CommandProcessor(this.driver);
this.stopSignal_ = stopSignal;
};
/**
@ -125,6 +129,9 @@ Dispatcher.prototype.quitApplication = function(msg) {
flags |= Ci.nsIAppStartup[k];
}
this.stopSignal_();
this.sendOk(id);
this.driver.sessionTearDown();
Services.startup.quit(flags);
};

View File

@ -145,7 +145,8 @@ MarionetteServer.prototype.onSocketAccepted = function(
let transport = new DebuggerTransport(input, output);
let connId = "conn" + this.nextConnId++;
let dispatcher = new Dispatcher(connId, transport, this.driverFactory);
let stopSignal = () => this.stop();
let dispatcher = new Dispatcher(connId, transport, this.driverFactory, stopSignal);
dispatcher.onclose = this.onConnectionClosed.bind(this);
this.conns[connId] = dispatcher;