Bug 1384137 - use mozprofile instead of marionette to install webextensions r+ahal draft
authorTarek Ziadé <tarek@mozilla.com>
Thu, 27 Jul 2017 13:42:37 +0200
changeset 618311 a4f45af5799ea9e765326eb1a5731a5714adc531
parent 616205 f1693d664f8e8ee4c79801630c181c28095cad56
child 640034 e6044e2c3a54b4faf63861f32baa79b9c851f095
push id71295
push usertziade@mozilla.com
push dateMon, 31 Jul 2017 07:44:11 +0000
bugs1384137
milestone56.0a1
Bug 1384137 - use mozprofile instead of marionette to install webextensions r+ahal MozReview-Commit-ID: 7lfrn6Nv79o
testing/talos/requirements.txt
testing/talos/talos/ffsetup.py
--- a/testing/talos/requirements.txt
+++ b/testing/talos/requirements.txt
@@ -2,10 +2,9 @@ mozlog>=3.1
 mozcrash>=0.15
 mozfile>=1.2
 mozhttpd>=0.7
 mozinfo>=0.8
 mozprocess>=0.22
 mozversion>=1.3
 mozprofile>=0.25
 psutil>=3.1.1
-marionette_driver>=1.4.0
 simplejson>=2.1.1
--- a/testing/talos/talos/ffsetup.py
+++ b/testing/talos/talos/ffsetup.py
@@ -9,18 +9,16 @@ Set up a browser environment before runn
 import os
 import tempfile
 import mozfile
 import mozinfo
 import mozrunner
 
 from mozprocess import ProcessHandlerMixin
 from mozprofile.profile import Profile
-from marionette_driver.marionette import Marionette
-from marionette_driver.addons import Addons
 from mozlog import get_proxy_logger
 
 from talos import utils
 from talos.utils import TalosError
 from talos.gecko_profile import GeckoProfile
 
 
 LOG = get_proxy_logger()
@@ -100,85 +98,59 @@ class FFSetup(object):
             extensions = [os.path.dirname(i) for i in extensions]
 
         profile = Profile.clone(
             os.path.normpath(self.test_config['profile_path']),
             self.profile_dir,
             restore=False)
 
         profile.set_preferences(preferences)
+
+        # installing addons
         profile.addon_manager.install_addons(extensions)
 
+        # installing webextensions
+        webextensions = self.test_config.get('webextensions', None)
+        if isinstance(webextensions, basestring):
+            webextensions = [webextensions]
+
+        if webextensions is not None:
+            for webext in webextensions:
+                filename = utils.interpolate(webext)
+                if mozinfo.os == 'win':
+                    filename = filename.replace('/', '\\')
+                if not filename.endswith('.xpi'):
+                    continue
+                if not os.path.exists(filename):
+                    continue
+
+                profile.addon_manager.install_from_path(filename)
+
     def _run_profile(self):
         runner_cls = mozrunner.runners.get(
             mozinfo.info.get(
                 'appname',
                 'firefox'),
             mozrunner.Runner)
-
-        if self.test_config.get('webextensions', None):
-            # bug 1272255 - marionette doesn't work with MOZ_DISABLE_NONLOCAL_CONNECTIONS
-            self.env['MOZ_DISABLE_NONLOCAL_CONNECTIONS'] = '0'
-
-            args = [self.browser_config["extra_args"], "-marionette"]
-            runner = runner_cls(profile=self.profile_dir,
-                                binary=self.browser_config["browser_path"],
-                                cmdargs=args,
-                                env=self.env,
-                                process_class=ProcessHandlerMixin,
-                                process_args={})
-
-            runner.start(outputTimeout=30)
-            proc = runner.process_handler
-            LOG.process_start(proc.pid, "%s %s" % (self.browser_config["browser_path"],
-                                                   ' '.join(args)))
-
-            try:
-                client = Marionette(host='localhost', port=2828)
-                client.start_session()
-                addons = Addons(client)
-            except Exception, e:
-                print e
-                raise TalosError("Failed to initialize Talos profile with Marionette")
+        args = [self.browser_config["extra_args"], self.browser_config["init_url"]]
+        runner = runner_cls(profile=self.profile_dir,
+                            binary=self.browser_config["browser_path"],
+                            cmdargs=args,
+                            env=self.env,
+                            process_class=ProcessHandlerMixin,
+                            process_args={})
 
-            extensions = self.test_config.get('webextensions', None)
-            if isinstance(extensions, str):
-                extensions = [self.test_config.get('webextensions', None)]
-            for ext in extensions:
-                filename = utils.interpolate(ext)
-                if mozinfo.os == 'win':
-                    filename = filename.replace('/', '\\')
-
-                if not filename.endswith('.xpi'):
-                    continue
-                if not os.path.exists(filename):
-                    continue
-
-                addons.install(filename)
-
-            # browse to init_url which will close the browser
-            client.navigate(self.browser_config["init_url"])
-            client.close()
-        else:
-            args = [self.browser_config["extra_args"], self.browser_config["init_url"]]
-            runner = runner_cls(profile=self.profile_dir,
-                                binary=self.browser_config["browser_path"],
-                                cmdargs=args,
-                                env=self.env,
-                                process_class=ProcessHandlerMixin,
-                                process_args={})
-
-            runner.start(outputTimeout=30)
-            proc = runner.process_handler
-            LOG.process_start(proc.pid, "%s %s" % (self.browser_config["browser_path"],
-                                                   ' '.join(args)))
+        runner.start(outputTimeout=30)
+        proc = runner.process_handler
+        LOG.process_start(proc.pid, "%s %s" % (self.browser_config["browser_path"],
+                                               ' '.join(args)))
 
         try:
             exit_code = proc.wait()
-        except Exception, e:
+        except Exception:
             proc.kill()
             raise TalosError("Browser Failed to close properly during warmup")
 
         LOG.process_exit(proc.pid, exit_code)
 
     def _init_gecko_profile(self):
         upload_dir = os.getenv('MOZ_UPLOAD_DIR')
         if self.test_config.get('gecko_profile') and not upload_dir: