mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 11:25:00 +00:00
Bug 1142404 - Fix marionette's restarts to keep from attempting to reconnect to the browser as it's shutting down.;r=dburns
This commit is contained in:
parent
f4ba405552
commit
45c8205d96
@ -677,8 +677,7 @@ class Marionette(object):
|
||||
timeout=timeout)
|
||||
|
||||
@do_crash_check
|
||||
def _send_message(self, command, response_key="ok", ignore_response=False,
|
||||
**kwargs):
|
||||
def _send_message(self, command, response_key="ok", **kwargs):
|
||||
if not self.session_id and command != "newSession":
|
||||
raise errors.MarionetteException("Please start a session")
|
||||
|
||||
@ -689,7 +688,7 @@ class Marionette(object):
|
||||
message["parameters"] = kwargs
|
||||
|
||||
try:
|
||||
response = self.client.send(message, ignore_response=ignore_response)
|
||||
response = self.client.send(message)
|
||||
except socket.timeout:
|
||||
self.session = None
|
||||
self.window = None
|
||||
@ -909,7 +908,7 @@ class Marionette(object):
|
||||
"eForceQuit",
|
||||
"eRestart",
|
||||
]
|
||||
self._send_message('quitApplication', flags=restart_flags, ignore_response=True)
|
||||
self._send_message('quitApplication', flags=restart_flags)
|
||||
self.client.close()
|
||||
else:
|
||||
self.delete_session()
|
||||
|
@ -189,6 +189,7 @@ function MarionetteServerConnection(aPrefix, aTransport, aServer)
|
||||
|
||||
this.observing = null;
|
||||
this._browserIds = new WeakMap();
|
||||
this.quitFlags = null;
|
||||
}
|
||||
|
||||
MarionetteServerConnection.prototype = {
|
||||
@ -228,6 +229,12 @@ MarionetteServerConnection.prototype = {
|
||||
onClosed: function MSC_onClosed(aStatus) {
|
||||
this.server._connectionClosed(this);
|
||||
this.sessionTearDown();
|
||||
|
||||
if (this.quitFlags !== null) {
|
||||
let flags = this.quitFlags;
|
||||
this.quitFlags = null;
|
||||
Services.startup.quit(flags);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@ -2637,7 +2644,7 @@ MarionetteServerConnection.prototype = {
|
||||
* current session.
|
||||
*/
|
||||
quitApplication: function MDA_quitApplication (aRequest) {
|
||||
let command_id = this.getCommandId();
|
||||
let command_id = this.command_id = this.getCommandId();
|
||||
if (appName != "Firefox") {
|
||||
this.sendError("In app initiated quit only supported on Firefox", 500, null, command_id);
|
||||
}
|
||||
@ -2648,8 +2655,13 @@ MarionetteServerConnection.prototype = {
|
||||
flags |= Ci.nsIAppStartup[k];
|
||||
}
|
||||
|
||||
this.sessionTearDown();
|
||||
Services.startup.quit(flags);
|
||||
// Close the listener so we can't re-connect until after the restart.
|
||||
this.server.closeListener();
|
||||
this.quitFlags = flags;
|
||||
|
||||
// This notifies the client it's safe to begin attempting to reconnect.
|
||||
// The actual quit will happen when the current socket connection is closed.
|
||||
this.sendOk(command_id);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -80,10 +80,8 @@ class MarionetteTransport(object):
|
||||
response = self.send({'to': 'root', 'name': 'getMarionetteID'})
|
||||
self.actor = response['id']
|
||||
|
||||
def send(self, msg, ignore_response=False):
|
||||
def send(self, msg):
|
||||
""" Send a message on the socket, prepending it with len(msg) + ':'.
|
||||
The ignore_response parameter indicates no response is expected from
|
||||
the remote end, for instance when the client requests a quit.
|
||||
"""
|
||||
if not self.sock:
|
||||
self.connect()
|
||||
@ -102,10 +100,7 @@ class MarionetteTransport(object):
|
||||
else:
|
||||
raise e
|
||||
|
||||
if not ignore_response:
|
||||
response = self.receive()
|
||||
else:
|
||||
response = {'ok': True}
|
||||
response = self.receive()
|
||||
return response
|
||||
|
||||
def close(self):
|
||||
|
Loading…
Reference in New Issue
Block a user