Skip to content

Commit

Permalink
Bug 1274408: Remove emulator support from Marionette in Gecko r=ato
Browse files Browse the repository at this point in the history
The emulator code was originally hacks to allow us to instrument the emulator
from JavaScript in the B2G world. Since we no longer support this it is being
removed.

MozReview-Commit-ID: 3XDk21SFfUc

--HG--
extra : rebase_source : 63bc081c3ab37894b97b873fe142ee068b609318
  • Loading branch information
David Burns committed May 24, 2016
1 parent 685a7e3 commit 20c4d3e
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 231 deletions.
32 changes: 6 additions & 26 deletions testing/marionette/dispatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ Cu.import("resource://gre/modules/Preferences.jsm");
Cu.import("resource://gre/modules/Task.jsm");

Cu.import("chrome://marionette/content/driver.js");
Cu.import("chrome://marionette/content/emulator.js");
Cu.import("chrome://marionette/content/error.js");
Cu.import("chrome://marionette/content/message.js");

Expand All @@ -29,9 +28,8 @@ const logger = Log.repository.getLogger("Marionette");
* Unique identifier of the connection this dispatcher should handle.
* @param {DebuggerTransport} transport
* Debugger transport connection to the client.
* @param {function(EmulatorService): GeckoDriver} driverFactory
* A factory function that takes an EmulatorService and produces
* a GeckoDriver.
* @param {function(): GeckoDriver} driverFactory
* A factory function that produces a GeckoDriver.
*/
this.Dispatcher = function(connId, transport, driverFactory) {
this.connId = connId;
Expand All @@ -47,8 +45,7 @@ this.Dispatcher = function(connId, transport, driverFactory) {
// last received/sent message ID
this.lastId = 0;

this.emulator = new emulator.EmulatorService(this.sendEmulator.bind(this));
this.driver = driverFactory(this.emulator);
this.driver = driverFactory();

// lookup of commands sent by server to client by message ID
this.commands_ = new Map();
Expand Down Expand Up @@ -159,23 +156,16 @@ Dispatcher.prototype.sayHello = function() {
this.sendRaw(whatHo);
};

Dispatcher.prototype.sendEmulator = function(name, params, resCb, errCb) {
let cmd = new Command(++this.lastId, name, params);
cmd.onresult = resCb;
cmd.onerror = errCb;
this.send(cmd);
};

/**
* Delegates message to client or emulator based on the provided
* {@code cmdId}. The message is sent over the debugger transport socket.
* Delegates message to client based on the provided {@code cmdId}.
* The message is sent over the debugger transport socket.
*
* The command ID is a unique identifier assigned to the client's request
* that is used to distinguish the asynchronous responses.
*
* Whilst responses to commands are synchronous and must be sent in the
* correct order, emulator callbacks are more transparent and can be sent
* at any time. These callbacks won't change the current command state.
* correct order.
*
* @param {Command,Response} msg
* The command or response to send.
Expand All @@ -192,16 +182,6 @@ Dispatcher.prototype.send = function(msg) {

// Low-level methods:

/**
* Send command to emulator over the debugger transport socket.
*
* @param {Command} cmd
* The command to issue to the emulator.
*/
Dispatcher.prototype.sendToEmulator = function(cmd) {
this.sendMessage(cmd);
};

/**
* Send given response to the client over the debugger transport socket.
*
Expand Down
10 changes: 1 addition & 9 deletions testing/marionette/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ Cu.import("chrome://marionette/content/action.js");
Cu.import("chrome://marionette/content/atom.js");
Cu.import("chrome://marionette/content/browser.js");
Cu.import("chrome://marionette/content/element.js");
Cu.import("chrome://marionette/content/emulator.js");
Cu.import("chrome://marionette/content/error.js");
Cu.import("chrome://marionette/content/evaluate.js");
Cu.import("chrome://marionette/content/event.js");
Expand Down Expand Up @@ -86,16 +85,10 @@ this.Context.fromString = function(s) {
* Device this driver should assume.
* @param {function()} stopSignal
* Signal to stop the Marionette server.
* @param {EmulatorService=} emulator
* Interface that allows instructing the emulator connected to the
* client to run commands and perform shell invocations.
*/
this.GeckoDriver = function(appName, device, stopSignal, emulator) {
this.GeckoDriver = function(appName, device, stopSignal) {
this.appName = appName;
this.stopSignal_ = stopSignal;
this.emulator = emulator;
// TODO(ato): hack
this.emulator.sendToListener = this.sendAsync.bind(this);

this.sessionId = null;
this.wins = new browser.Windows();
Expand Down Expand Up @@ -872,7 +865,6 @@ GeckoDriver.prototype.execute_ = function(script, args, timeout, opts = {}) {
if (opts.sandboxName) {
sb = sandbox.augment(sb, new logging.Adapter(this.marionetteLog));
sb = sandbox.augment(sb, {global: sb});
sb = sandbox.augment(sb, new emulator.Adapter(this.emulator));
}

opts.timeout = timeout;
Expand Down
166 changes: 0 additions & 166 deletions testing/marionette/emulator.js

This file was deleted.

4 changes: 0 additions & 4 deletions testing/marionette/frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,6 @@ frame.Manager = class {
mm.addWeakMessageListener("Marionette:error", this.driver);
mm.addWeakMessageListener("Marionette:emitTouchEvent", this.driver);
mm.addWeakMessageListener("Marionette:log", this.driver);
mm.addWeakMessageListener("Marionette:runEmulatorCmd", this.driver.emulator);
mm.addWeakMessageListener("Marionette:runEmulatorShell", this.driver.emulator);
mm.addWeakMessageListener("Marionette:shareData", this.driver);
mm.addWeakMessageListener("Marionette:switchToModalOrigin", this.driver);
mm.addWeakMessageListener("Marionette:switchedToFrame", this.driver);
Expand Down Expand Up @@ -249,8 +247,6 @@ frame.Manager = class {
mm.removeWeakMessageListener("Marionette:error", this.driver);
mm.removeWeakMessageListener("Marionette:log", this.driver);
mm.removeWeakMessageListener("Marionette:shareData", this.driver);
mm.removeWeakMessageListener("Marionette:runEmulatorCmd", this.driver.emulator);
mm.removeWeakMessageListener("Marionette:runEmulatorShell", this.driver.emulator);
mm.removeWeakMessageListener("Marionette:switchedToFrame", this.driver);
mm.removeWeakMessageListener("Marionette:getVisibleCookies", this.driver);
mm.removeWeakMessageListener("Marionette:getImportedScripts", this.driver.importedScripts);
Expand Down
1 change: 0 additions & 1 deletion testing/marionette/jar.mn
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ marionette.jar:
content/error.js (error.js)
content/message.js (message.js)
content/dispatcher.js (dispatcher.js)
content/emulator.js (emulator.js)
content/modal.js (modal.js)
content/proxy.js (proxy.js)
content/capture.js (capture.js)
Expand Down
3 changes: 0 additions & 3 deletions testing/marionette/listener.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ Cu.import("chrome://marionette/content/atom.js");
Cu.import("chrome://marionette/content/capture.js");
Cu.import("chrome://marionette/content/cookies.js");
Cu.import("chrome://marionette/content/element.js");
Cu.import("chrome://marionette/content/emulator.js");
Cu.import("chrome://marionette/content/error.js");
Cu.import("chrome://marionette/content/evaluate.js");
Cu.import("chrome://marionette/content/event.js");
Expand Down Expand Up @@ -528,8 +527,6 @@ function* executeInSandbox(script, args, timeout, opts) {
if (opts.sandboxName) {
sb = sandbox.augment(sb, {global: sb});
sb = sandbox.augment(sb, new logging.Adapter(contentLog));
let emulatorClient = new emulator.EmulatorServiceClient(asyncChrome);
sb = sandbox.augment(sb, new emulator.Adapter(emulatorClient));
}

let wargs = elementManager.convertWrappedArguments(args, curContainer);
Expand Down
30 changes: 8 additions & 22 deletions testing/marionette/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,48 +50,34 @@ this.MarionetteServer = function(port, forceLocal) {
};

/**
* Function that takes an Emulator and produces a GeckoDriver.
* Function produces a GeckoDriver.
*
* Determines application name and device type to initialise the driver
* with. Also bypasses offline status if the device is a qemu or panda
* type device.
* with.
*
* @return {GeckoDriver}
* A driver instance.
*/
MarionetteServer.prototype.driverFactory = function(emulator) {
MarionetteServer.prototype.driverFactory = function() {
let appName = isMulet() ? "B2G" : Services.appinfo.name;
let qemu = "0";
let device = null;
let bypassOffline = false;

try {
Cu.import("resource://gre/modules/systemlibs.js");
qemu = libcutils.property_get("ro.kernel.qemu");
logger.debug("B2G emulator: " + (qemu == "1" ? "yes" : "no"));
device = libcutils.property_get("ro.product.device");
logger.debug("Device detected is " + device);
bypassOffline = (qemu == "1" || device == "panda");
} catch (e) {}

if (qemu == "1") {
device = "qemu";
}
if (!device) {
device = "desktop";
}

Preferences.set(CONTENT_LISTENER_PREF, false);

if (bypassOffline) {
logger.debug("Bypassing offline status");
Preferences.set(MANAGE_OFFLINE_STATUS_PREF, false);
Services.io.manageOfflineStatus = false;
Services.io.offline = false;
logger.debug("Bypassing offline status");
Preferences.set(MANAGE_OFFLINE_STATUS_PREF, false);
Services.io.manageOfflineStatus = false;
Services.io.offline = false;
}

let stopSignal = () => this.stop();
return new GeckoDriver(appName, device, stopSignal, emulator);
return new GeckoDriver(appName, device, stopSignal);
};

MarionetteServer.prototype.start = function() {
Expand Down

0 comments on commit 20c4d3e

Please sign in to comment.