Bug 1202707: Remove emulator commands from simpletest harness
authorAndreas Tolfsen <ato@mozilla.com>
Tue, 08 Sep 2015 17:12:18 +0100
changeset 294156 bebf1050fa4d4c22de26165680b89e2955d18405
parent 294155 76bf911689697c10ff7ed92a343bd2c9d4008c48
child 294157 3ded49bb78d735b442f7965b215de9532f80e787
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1202707
milestone43.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 1202707: Remove emulator commands from simpletest harness We attach the emulator commands outside of the simpletest harness. Removing this makes testing/marionette/simpletest.js less dependent on Marionette. r=dburns
testing/marionette/driver.js
testing/marionette/listener.js
testing/marionette/simpletest.js
--- a/testing/marionette/driver.js
+++ b/testing/marionette/driver.js
@@ -903,17 +903,16 @@ GeckoDriver.prototype.execute = function
     };
   }
 
   let win = this.getCurrentWindow();
   if (newSandbox ||
       !(sandboxName in this.sandboxes) ||
       (this.sandboxes[sandboxName].proto != win)) {
     let marionette = new Marionette(
-        this,
         win,
         "chrome",
         this.marionetteLog,
         scriptTimeout,
         this.heartbeatCallback,
         this.testName);
     this.createExecuteSandbox(
         win,
@@ -1107,17 +1106,16 @@ GeckoDriver.prototype.executeWithCallbac
 
     let chromeAsyncError = function(e, func, file, line, script) {
       let err = new JavaScriptError(e, func, file, line, script);
       chromeAsyncReturnFunc(err);
     };
 
     if (newSandbox || !(sandboxName in this.sandboxes)) {
       let marionette = new Marionette(
-          this,
           win,
           "chrome",
           this.marionetteLog,
           scriptTimeout,
           this.heartbeatCallback,
           this.testName);
       this.createExecuteSandbox(win, marionette, sandboxName);
     }
--- a/testing/marionette/listener.js
+++ b/testing/marionette/listener.js
@@ -471,30 +471,26 @@ function checkForInterrupted() {
  * Marionette Methods
  */
 
 /**
  * Returns a content sandbox that can be used by the execute_foo functions.
  */
 function createExecuteContentSandbox(win, timeout) {
   let mn = new Marionette(
-      this,
       win,
       "content",
       marionetteLogObj,
       timeout,
       heartbeatCallback,
       marionetteTestName);
-  mn.runEmulatorCmd = (cmd, cb) => this.runEmulatorCmd(cmd, cb);
-  mn.runEmulatorShell = (args, cb) => this.runEmulatorShell(args, cb);
 
   let principal = win;
-  if (sandboxName == 'system') {
-    principal = Cc["@mozilla.org/systemprincipal;1"].
-                createInstance(Ci.nsIPrincipal);
+  if (sandboxName == "system") {
+    principal = Cc["@mozilla.org/systemprincipal;1"].createInstance(Ci.nsIPrincipal);
   }
   let sandbox = new Cu.Sandbox(principal, {sandboxPrototype: win});
   sandbox.global = sandbox;
   sandbox.window = win;
   sandbox.document = sandbox.window.document;
   sandbox.navigator = sandbox.window.navigator;
   sandbox.testUtils = utils;
   sandbox.asyncTestCommandId = asyncTestCommandId;
@@ -502,16 +498,18 @@ function createExecuteContentSandbox(win
 
   mn.exports.forEach(fn => {
     if (typeof mn[fn] == "function") {
       sandbox[fn] = mn[fn].bind(mn);
     } else {
       sandbox[fn] = mn[fn];
     }
   });
+  sandbox.runEmulatorCmd = (cmd, cb) => this.runEmulatorCmd(cmd, cb);
+  sandbox.runEmulatorShell = (args, cb) => this.runEmulatorShell(args, cb);
 
   sandbox.asyncComplete = (obj, id) => {
     if (id == asyncTestCommandId) {
       curContainer.frame.removeEventListener("unload", onunload, false);
       curContainer.frame.clearTimeout(asyncTestTimeoutId);
 
       if (inactivityTimeoutId != null) {
         curContainer.frame.clearTimeout(inactivityTimeoutId);
--- a/testing/marionette/simpletest.js
+++ b/testing/marionette/simpletest.js
@@ -6,19 +6,18 @@ let {utils: Cu} = Components;
 
 Cu.import("chrome://marionette/content/error.js");
 
 this.EXPORTED_SYMBOLS = ["Marionette"];
 
 /*
  * The Marionette object, passed to the script context.
  */
-this.Marionette = function(scope, window, context, logObj, timeout,
-                           heartbeatCallback, testName) {
-  this.scope = scope;
+this.Marionette = function(window, context, logObj, timeout,
+    heartbeatCallback, testName) {
   this.window = window;
   this.tests = [];
   this.logObj = logObj;
   this.context = context;
   this.timeout = timeout;
   this.heartbeatCallback = heartbeatCallback;
   this.testName = testName;
   this.TEST_UNEXPECTED_FAIL = "TEST-UNEXPECTED-FAIL";
@@ -32,26 +31,23 @@ Marionette.prototype = {
     "ok",
     "is",
     "isnot",
     "todo",
     "log",
     "getLogs",
     "generate_results",
     "waitFor",
-    "runEmulatorCmd",
-    "runEmulatorShell",
     "TEST_PASS",
     "TEST_KNOWN_FAIL",
     "TEST_UNEXPECTED_FAIL",
     "TEST_UNEXPECTED_PASS"
   ],
 
   addTest: function Marionette__addTest(condition, name, passString, failString, diag, state) {
-
     let test = {'result': !!condition, 'name': name, 'diag': diag, 'state': state};
     this.logResult(test,
                    typeof(passString) == "undefined" ? this.TEST_PASS : passString,
                    typeof(failString) == "undefined" ? this.TEST_UNEXPECTED_FAIL : failString);
     this.tests.push(test);
   },
 
   ok: function Marionette__ok(condition, name, passString, failString) {
@@ -198,19 +194,9 @@ Marionette.prototype = {
       if (deadline <= now) {
         dump("waitFor timeout: " + test.toString() + "\n");
         // the script will timeout here, so no need to raise a separate
         // timeout exception
         return;
       }
       this.window.setTimeout(this.waitFor.bind(this), 100, callback, test, deadline);
   },
-
-  runEmulatorCmd: function runEmulatorCmd(cmd, callback) {
-    this.heartbeatCallback();
-    this.scope.runEmulatorCmd(cmd, callback);
-  },
-
-  runEmulatorShell: function runEmulatorShell(args, callback) {
-    this.heartbeatCallback();
-    this.scope.runEmulatorShell(args, callback);
-  },
 };