Bug 1107706: Part 14: Fix quitApplication
☠☠ backed out by 4c2c50594967 ☠ ☠
authorAndreas Tolfsen <ato@mozilla.com>
Fri, 20 Mar 2015 20:44:17 +0000
changeset 265686 71eba829a8b4d009ad6c34018b6d9467f6acb866
parent 265685 3ca5a996676e64c796d6190b5d7b99edd2378266
child 265687 bb481b2d170ac58f77b9c6e43b3b47063fec4160
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1107706
milestone39.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1107706: Part 14: Fix quitApplication
testing/marionette/dispatcher.js
testing/marionette/server.js
--- a/testing/marionette/dispatcher.js
+++ b/testing/marionette/dispatcher.js
@@ -26,18 +26,20 @@ const uuidGen = Cc["@mozilla.org/uuid-ge
  *
  * @param {number} connId
  *     Unique identifier of the connection this dispatcher should handle.
  * @param {DebuggerTransport} transport
  *     Debugger transport connection to the client.
  * @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;
 
   // Marionette uses a protocol based on the debugger server, which
   // requires passing back actor ID's with responses.  Unlike the debugger
   // server, we don't actually have multiple actors, so just use a dummy
   // value of "0".
   this.actorId = "0";
@@ -47,16 +49,18 @@ this.Dispatcher = function(connId, trans
 
   // transport hooks are Dispatcher.prototype.onPacket
   // and Dispatcher.prototype.onClosed
   this.conn.hooks = this;
 
   this.emulator = new Emulator(msg => this.sendResponse(msg, -1));
   this.driver = driverFactory(this.emulator);
   this.commandProcessor = new CommandProcessor(this.driver);
+
+  this.stopSignal_ = stopSignal;
 };
 
 /**
  * Debugger transport callback that dispatches the request.
  * Request handlers defined in this.requests take presedence
  * over those defined in this.driver.commands.
  */
 Dispatcher.prototype.onPacket = function(packet) {
@@ -120,16 +124,19 @@ Dispatcher.prototype.quitApplication = f
     return;
   }
 
   let flags = Ci.nsIAppStartup.eAttemptQuit;
   for (let k of msg.parameters.flags) {
     flags |= Ci.nsIAppStartup[k];
   }
 
+  this.stopSignal_();
+  this.sendOk(id);
+
   this.driver.sessionTearDown();
   Services.startup.quit(flags);
 };
 
 // Convenience methods:
 
 Dispatcher.prototype.sayHello = function() {
   let id = this.beginNewCommand();
--- a/testing/marionette/server.js
+++ b/testing/marionette/server.js
@@ -140,17 +140,18 @@ MarionetteServer.prototype.closeListener
 
 MarionetteServer.prototype.onSocketAccepted = function(
     serverSocket, clientSocket) {
   let input = clientSocket.openInputStream(0, 0, 0);
   let output = clientSocket.openOutputStream(0, 0, 0);
   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;
 
   logger.info(`Accepted connection ${connId} from ${clientSocket.host}:${clientSocket.port}`);
 
   // Create a root actor for the connection and send the hello packet
   dispatcher.sayHello();
   transport.ready();