Bug 797639 - Part 3: Fix Marionette client / server loading and parsing. r=jgriffin

This commit is contained in:
J. Ryan Stinnett 2014-05-14 14:30:02 -05:00
parent 64ce7860dd
commit f0e7ce6951
5 changed files with 8 additions and 5 deletions

View File

@ -538,7 +538,7 @@ window.addEventListener('mozbrowserloadend', function loaded(aEvent) {
sock.connect(('localhost', self.marionette_port))
data = sock.recv(16)
sock.close()
if '"from"' in data:
if ':' in data:
return True
except:
import traceback

View File

@ -586,7 +586,7 @@ class Marionette(object):
sock.connect((self.host, self.port))
data = sock.recv(16)
sock.close()
if '"from"' in data:
if ':' in data:
time.sleep(5)
return True
except socket.error:

View File

@ -6,6 +6,7 @@ this.CC = Components.Constructor;
this.Cc = Components.classes;
this.Ci = Components.interfaces;
this.Cu = Components.utils;
this.Cr = Components.results;
const MARIONETTE_CONTRACTID = "@mozilla.org/marionette;1";
const MARIONETTE_CID = Components.ID("{786a1369-dca5-4adc-8486-33d23c88010a}");

View File

@ -38,7 +38,7 @@ let appName = Services.appinfo.name;
let { devtools } = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
let DevToolsUtils = devtools.require("devtools/toolkit/DevToolsUtils.js");
this.DevToolsUtils = DevToolsUtils;
loader.loadSubScript("resource://gre/modules/devtools/server/transport.js");
loader.loadSubScript("resource://gre/modules/devtools/transport/transport.js");
let bypassOffline = false;
let qemu = "0";
@ -202,7 +202,7 @@ MarionetteServerConnection.prototype = {
*/
sendAsync: function MDA_sendAsync(name, values, commandId, ignoreFailure) {
let success = true;
if (values instanceof Object && commandId) {
if (commandId) {
values.command_id = commandId;
}
if (this.curBrowser.frameManager.currentRemoteFrame !== null) {

View File

@ -45,11 +45,13 @@ class MarionetteTransport(object):
"""
assert(self.sock)
response = self.sock.recv(10)
initial_size = len(response)
sep = response.find(':')
length = response[0:sep]
if length != '':
response = response[sep + 1:]
response += self._recv_n_bytes(int(length) + 1 + len(length) - 10)
remaining_size = int(length) + 1 + len(length) - initial_size
response += self._recv_n_bytes(remaining_size)
return json.loads(response)
else:
raise IOError(self.connection_lost_msg)