diff --git a/testing/marionette/dispatcher.js b/testing/marionette/dispatcher.js index 50b85b62727..7da393d1588 100644 --- a/testing/marionette/dispatcher.js +++ b/testing/marionette/dispatcher.js @@ -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); }; diff --git a/testing/marionette/server.js b/testing/marionette/server.js index 06d7671931b..ffe4dae539f 100644 --- a/testing/marionette/server.js +++ b/testing/marionette/server.js @@ -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;