From ef06d5263521a12c297fcc8970e9650d2f84d307 Mon Sep 17 00:00:00 2001 From: Andreas Tolfsen Date: Fri, 20 Mar 2015 20:44:17 +0000 Subject: [PATCH] Bug 1107706: Part 14: Fix quitApplication --- testing/marionette/dispatcher.js | 9 ++++++++- testing/marionette/server.js | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-) 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;