From 208b570e6c7668b3ff9240da818e698f4e16b811 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 --HG-- extra : rebase_source : a2fb0d0d8e64cfa6e3801f454858cdfa45d05b2d --- 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 50b85b627274..7da393d1588e 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 06d7671931b9..ffe4dae539ff 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;