Bug 1282800 - Remove device capability from Marionette; r?automatedtester draft
authorAndreas Tolfsen <ato@mozilla.com>
Tue, 28 Jun 2016 15:26:49 +0100
changeset 382028 5ef0cae167fde28438c131d40e72718bbb1cf745
parent 381966 e45890951ce77c3df05575bd54072b9f300d77b0
child 524074 f6a0528cce80f1799c0d3653b04bc17a43be325e
push id21598
push userbmo:ato@mozilla.com
push dateTue, 28 Jun 2016 18:04:04 +0000
reviewersautomatedtester
bugs1282800
milestone50.0a1
Bug 1282800 - Remove device capability from Marionette; r?automatedtester MozReview-Commit-ID: 4ZlojpuwpUN
testing/marionette/driver.js
testing/marionette/harness/marionette/runner/base.py
testing/marionette/harness/marionette/tests/unit/test_capabilities.py
testing/marionette/harness/marionette/tests/unit/test_session.py
testing/marionette/server.js
--- a/testing/marionette/driver.js
+++ b/testing/marionette/driver.js
@@ -86,22 +86,20 @@ this.Context.fromString = function(s) {
  * browsing context's content frame message listener via ListenerProxy.
  *
  * Throughout this prototype, functions with the argument {@code cmd}'s
  * documentation refers to the contents of the {@code cmd.parameters}
  * object.
  *
  * @param {string} appName
  *     Description of the product, for example "B2G" or "Firefox".
- * @param {string} device
- *     Device this driver should assume.
  * @param {function()} stopSignal
  *     Signal to stop the Marionette server.
  */
-this.GeckoDriver = function(appName, device, stopSignal) {
+this.GeckoDriver = function(appName, stopSignal) {
   this.appName = appName;
   this.stopSignal_ = stopSignal;
 
   this.sessionId = null;
   this.wins = new browser.Windows();
   this.browsers = {};
   // points to current browser
   this.curBrowser = null;
@@ -145,17 +143,16 @@ this.GeckoDriver = function(appName, dev
     "proxy": {},
 
     // Selenium 2 compat
     "platform": Services.sysinfo.getProperty("name").toUpperCase(),
 
     // proprietary extensions
     "XULappId" : Services.appinfo.ID,
     "appBuildId" : Services.appinfo.appBuildID,
-    "device": device,
     "processId" : Services.appinfo.processID,
     "version": Services.appinfo.version,
   };
 
   this.mm = globalMessageManager;
   this.listener = proxy.toListener(() => this.mm, this.sendAsync.bind(this));
 
   // always keep weak reference to current dialogue
--- a/testing/marionette/harness/marionette/runner/base.py
+++ b/testing/marionette/harness/marionette/runner/base.py
@@ -753,28 +753,16 @@ setReq.onerror = function() {
             traceback.print_exc()
         return crash
 
     def _initialize_test_run(self, tests):
         assert len(tests) > 0
         assert len(self.test_handlers) > 0
         self.reset_test_stats()
 
-    def _start_marionette(self):
-        need_external_ip = True
-        if not self.marionette:
-            self.marionette = self.driverclass(**self._build_kwargs())
-            # if we're working against a desktop version, we usually don't need
-            # an external ip
-            if self.capabilities['device'] == "desktop":
-                need_external_ip = False
-        self.logger.info('Initial Profile Destination is '
-                         '"{}"'.format(self.marionette.profile_path))
-        return need_external_ip
-
     def _set_baseurl(self, need_external_ip):
         # Gaia sets server_root and that means we shouldn't spin up our own httpd
         if not self.httpd:
             if self.server_root is None or os.path.isdir(self.server_root):
                 self.logger.info("starting httpd")
                 self.start_httpd(need_external_ip)
                 self.marionette.baseurl = self.httpd.get_url()
                 self.logger.info("running httpd on %s" % self.marionette.baseurl)
@@ -804,19 +792,28 @@ setReq.onerror = function() {
             self.logger.test_end(name,
                                  'SKIP',
                                  message=test['disabled'])
             self.todo += 1
 
     def run_tests(self, tests):
         start_time = time.time()
         self._initialize_test_run(tests)
+        self.marionette = self.driverclass(**self._build_kwargs())
 
-        need_external_ip = self._start_marionette()
+        # Determine if we need to bind the HTTPD to an external IP.
+        # We typically only need to do so if the remote is running
+        # on an emulated system, like Android (Fennec).
+        if self.capabilities["browserName"] == "Fennec":
+            need_external_ip = True
+        else:
+            need_external_ip = False
+
         self._set_baseurl(need_external_ip)
+        self.logger.info("Initial profile destination is %s" % self.marionette.profile_path)
 
         self._add_tests(tests)
 
         self.logger.info("running with e10s: {}".format(self.e10s))
         version_info = mozversion.get_version(binary=self.bin,
                                               sources=self.sources,
                                               dm_type=os.environ.get('DM_TRANS', 'adb') )
 
--- a/testing/marionette/harness/marionette/tests/unit/test_capabilities.py
+++ b/testing/marionette/harness/marionette/tests/unit/test_capabilities.py
@@ -49,17 +49,16 @@ class TestCapabilities(MarionetteTestCas
 
     def test_selenium2_compat(self):
         self.assertIn("platform", self.caps)
         self.assertEqual(self.caps["platform"], self.caps["platformName"].upper())
 
     def test_extensions(self):
         self.assertIn("XULappId", self.caps)
         self.assertIn("appBuildId", self.caps)
-        self.assertIn("device", self.caps)
         self.assertIn("version", self.caps)
 
         self.assertEqual(self.caps["XULappId"], self.appinfo["ID"])
         self.assertEqual(self.caps["appBuildId"], self.appinfo["appBuildID"])
         self.assertEqual(self.caps["version"], self.appinfo["version"])
 
     def test_we_can_pass_in_capabilities_on_session_start(self):
         self.marionette.delete_session()
--- a/testing/marionette/harness/marionette/tests/unit/test_session.py
+++ b/testing/marionette/harness/marionette/tests/unit/test_session.py
@@ -19,17 +19,16 @@ class TestSession(MarionetteTestCase):
         self.assertIsNotNone(self.marionette.session)
 
         # Required capabilities mandated by WebDriver spec
         self.assertIn("browserName", caps)
         self.assertIn("platformName", caps)
         self.assertIn("platformVersion", caps)
 
         # Optional capabilities we want Marionette to support
-        self.assertIn("device", caps)
         self.assertIn("rotatable", caps)
         self.assertIn("takesScreenshot", caps)
         self.assertIn("version", caps)
 
     def test_we_can_get_the_session_id(self):
         # Sends newSession
         self.marionette.start_session()
 
--- a/testing/marionette/server.js
+++ b/testing/marionette/server.js
@@ -47,42 +47,36 @@ this.MarionetteServer = function(port, f
   this.conns = {};
   this.nextConnId = 0;
   this.alive = false;
 };
 
 /**
  * Function produces a GeckoDriver.
  *
- * Determines application name and device type to initialise the driver
- * with.
+ * Determines application nameto initialise the driver with.
  *
  * @return {GeckoDriver}
  *     A driver instance.
  */
 MarionetteServer.prototype.driverFactory = function() {
   let appName = isMulet() ? "B2G" : Services.appinfo.name;
-  let device = null;
   let bypassOffline = false;
 
-  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;
   }
 
   let stopSignal = () => this.stop();
-  return new GeckoDriver(appName, device, stopSignal);
+  return new GeckoDriver(appName, stopSignal);
 };
 
 MarionetteServer.prototype.start = function() {
   if (this.alive) {
     return;
   }
   let flags = Ci.nsIServerSocket.KeepWhenOffline;
   if (this.forceLocal) {