Bug 1120630 - Add --e10s to turn on electrolysis for marionette tests.;r=jgriffin
authorChris Manchester <cmanchester@mozilla.com>
Tue, 13 Jan 2015 21:27:25 -0500
changeset 223679 340b2907b368f195d5bbfc3a081e4cfe9eb9959a
parent 223678 906a97d224d6ec663c39e8e7192647f5dd80e732
child 223680 e3b9dcef0c711050db12338fa848fea859e5221a
push id53987
push usercmanchester@mozilla.com
push dateWed, 14 Jan 2015 02:27:31 +0000
treeherdermozilla-inbound@e3b9dcef0c71 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgriffin
bugs1120630
milestone38.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 1120630 - Add --e10s to turn on electrolysis for marionette tests.;r=jgriffin
testing/marionette/client/marionette/geckoinstance.py
testing/marionette/client/marionette/marionette.py
testing/marionette/client/marionette/marionette_test.py
testing/marionette/client/marionette/runner/base.py
testing/marionette/mach_commands.py
--- a/testing/marionette/client/marionette/geckoinstance.py
+++ b/testing/marionette/client/marionette/geckoinstance.py
@@ -26,27 +26,30 @@ class GeckoInstance(object):
                       "browser.displayedE10SPrompt.1": 5,
                       "browser.displayedE10SPrompt.2": 5,
                       "browser.displayedE10SPrompt.3": 5,
                       "browser.displayedE10SPrompt.4": 5,
                       "browser.tabs.remote.autostart.1": False,
                       "browser.tabs.remote.autostart.2": False}
 
     def __init__(self, host, port, bin, profile=None, app_args=None, symbols_path=None,
-                  gecko_log=None, prefs=None, ):
+                  gecko_log=None, prefs=None):
         self.marionette_host = host
         self.marionette_port = port
         self.bin = bin
         # Check if it is a Profile object or a path to profile
         self.profile = None
         if isinstance(profile, Profile):
             self.profile = profile
         else:
             self.profile_path = profile
         self.prefs = prefs
+        self.required_prefs = deepcopy(GeckoInstance.required_prefs)
+        if prefs:
+            self.required_prefs.update(prefs)
         self.app_args = app_args or []
         self.runner = None
         self.symbols_path = symbols_path
         self.gecko_log = gecko_log
 
     def start(self):
         profile_args = {"preferences": deepcopy(self.required_prefs)}
         profile_args["preferences"]["marionette.defaultPrefs.port"] = self.marionette_port
--- a/testing/marionette/client/marionette/marionette.py
+++ b/testing/marionette/client/marionette/marionette.py
@@ -467,17 +467,17 @@ class Marionette(object):
     TIMEOUT_PAGE = 'page load'
 
     def __init__(self, host='localhost', port=2828, app=None, app_args=None, bin=None,
                  profile=None, emulator=None, sdcard=None, emulator_img=None,
                  emulator_binary=None, emulator_res=None, connect_to_running_emulator=False,
                  gecko_log=None, homedir=None, baseurl=None, no_window=False, logdir=None,
                  busybox=None, symbols_path=None, timeout=None, socket_timeout=360,
                  device_serial=None, adb_path=None, process_args=None,
-                 adb_host=None, adb_port=None):
+                 adb_host=None, adb_port=None, prefs=None):
         self.host = host
         self.port = self.local_port = port
         self.bin = bin
         self.profile = profile
         self.instance = None
         self.session = None
         self.session_id = None
         self.window = None
@@ -514,17 +514,17 @@ class Marionette(object):
                     instance_class = geckoinstance.apps[app.lower()]
                 except (ConfigParser.NoOptionError,
                         ConfigParser.NoSectionError,
                         KeyError):
                     instance_class = geckoinstance.GeckoInstance
             self.instance = instance_class(host=self.host, port=self.port,
                                            bin=self.bin, profile=self.profile,
                                            app_args=app_args, symbols_path=symbols_path,
-                                           gecko_log=gecko_log)
+                                           gecko_log=gecko_log, prefs=prefs)
             self.instance.start()
             assert(self.wait_for_port()), "Timed out waiting for port!"
 
         if emulator:
             self.runner = B2GEmulatorRunner(b2g_home=homedir,
                                             no_window=self.no_window,
                                             logdir=logdir,
                                             arch=emulator,
--- a/testing/marionette/client/marionette/marionette_test.py
+++ b/testing/marionette/client/marionette/marionette_test.py
@@ -83,16 +83,31 @@ def expectedFailure(func):
 def skip_if_b2g(target):
     def wrapper(self, *args, **kwargs):
         if self.marionette.session_capabilities.get('b2g') == True:
             raise SkipTest('skipping due to b2g')
         return target(self, *args, **kwargs)
 
     return wrapper
 
+def skip_if_e10s(target):
+    def wrapper(self, *args, **kwargs):
+        with self.marionette.using_context('chrome'):
+            multi_process_browser = self.marionette.execute_script("""
+            try {
+              return Services.appinfo.browserTabsRemoteAutostart;
+            } catch (e) {
+              return false;
+            }""")
+
+        if multi_process_browser:
+            raise SkipTest('skipping due to e10s')
+        return target(self, *args, **kwargs)
+    return wrapper
+
 def parameterized(func_suffix, *args, **kwargs):
     """
     A decorator that can generate methods given a base method and some data.
 
     **func_suffix** is used as a suffix for the new created method and must be
     unique given a base method. if **func_suffix** countains characters that
     are not allowed in normal python function name, these characters will be
     replaced with "_".
--- a/testing/marionette/client/marionette/runner/base.py
+++ b/testing/marionette/client/marionette/runner/base.py
@@ -390,16 +390,21 @@ class BaseMarionetteOptions(OptionParser
                         action='store',
                         default='Marionette-based Tests',
                         help='Define the name to associate with the logger used')
         self.add_option('--jsdebugger',
                         dest='jsdebugger',
                         action='store_true',
                         default=False,
                         help='Enable the jsdebugger for marionette javascript.')
+        self.add_option('--e10s',
+                        dest='e10s',
+                        action='store_true',
+                        default=False,
+                        help='Enable e10s when running marionette tests.')
 
     def parse_args(self, args=None, values=None):
         options, tests = OptionParser.parse_args(self, args, values)
         for handler in self.parse_args_handlers:
             handler(options, tests, args, values)
 
         return (options, tests)
 
@@ -442,16 +447,21 @@ class BaseMarionetteOptions(OptionParser
             if not 1 <= options.total_chunks:
                 self.error('Total chunks must be greater than 1.')
             if not 1 <= options.this_chunk <= options.total_chunks:
                 self.error('Chunk to run must be between 1 and %s.' % options.total_chunks)
 
         if options.jsdebugger:
             options.app_args.append('-jsdebugger')
 
+        if options.e10s:
+            options.prefs = {
+                'browser.tabs.remote.autostart': True
+            }
+
         for handler in self.verify_usage_handlers:
             handler(options, tests)
 
         return (options, tests)
 
 
 class BaseMarionetteTestRunner(object):
 
@@ -461,17 +471,17 @@ class BaseMarionetteTestRunner(object):
                  emulator_img=None, emulator_res='480x800', homedir=None,
                  app=None, app_args=None, binary=None, profile=None,
                  logger=None, no_window=False, logdir=None, logcat_stdout=False,
                  xml_output=None, repeat=0, testvars=None, tree=None, type=None,
                  device_serial=None, symbols_path=None, timeout=None,
                  shuffle=False, shuffle_seed=random.randint(0, sys.maxint),
                  sdcard=None, this_chunk=1, total_chunks=1, sources=None,
                  server_root=None, gecko_log=None, result_callbacks=None,
-                 adb_host=None, adb_port=None, **kwargs):
+                 adb_host=None, adb_port=None, prefs=None, **kwargs):
         self.address = address
         self.emulator = emulator
         self.emulator_binary = emulator_binary
         self.emulator_img = emulator_img
         self.emulator_res = emulator_res
         self.homedir = homedir
         self.app = app
         self.app_args = app_args or []
@@ -503,16 +513,17 @@ class BaseMarionetteTestRunner(object):
         self.total_chunks = total_chunks
         self.gecko_log = gecko_log
         self.mixin_run_tests = []
         self.manifest_skipped_tests = []
         self.tests = []
         self.result_callbacks = result_callbacks if result_callbacks is not None else []
         self._adb_host = adb_host
         self._adb_port = adb_port
+        self.prefs = prefs
 
         def gather_debug(test, status):
             rv = {}
             marionette = test._marionette_weakref()
 
             # In the event we're gathering debug without starting a session, skip marionette commands
             if marionette.session is not None:
                 try:
@@ -615,16 +626,17 @@ class BaseMarionetteTestRunner(object):
 
     def _build_kwargs(self):
         kwargs = {
             'device_serial': self.device_serial,
             'symbols_path': self.symbols_path,
             'timeout': self.timeout,
             'adb_host': self._adb_host,
             'adb_port': self._adb_port,
+            'prefs': self.prefs,
         }
         if self.bin:
             kwargs.update({
                 'host': 'localhost',
                 'port': 2828,
                 'app': self.app,
                 'app_args': self.app_args,
                 'bin': self.bin,
--- a/testing/marionette/mach_commands.py
+++ b/testing/marionette/mach_commands.py
@@ -127,13 +127,15 @@ class MachCommands(MachCommandBase):
         default='browser',
         help='Test type, usually one of: browser, b2g, b2g-qemu.')
     @CommandArgument('--profile',
         help='Path to gecko profile to use.')
     @CommandArgument('--gecko-log',
         help='Path to gecko log file, or "-" for stdout.')
     @CommandArgument('--jsdebugger', action='store_true',
         help='Enable the jsdebugger for marionette javascript.')
+    @CommandArgument('--e10s', action='store_true',
+        help='Enable electrolysis for marionette tests (desktop only).')
     @CommandArgument('tests', nargs='*', metavar='TESTS',
         help='Path to test(s) to run.')
     def run_marionette_test(self, tests, **kwargs):
         binary = self.get_binary_path('app')
         return run_marionette(tests, binary=binary, topsrcdir=self.topsrcdir, **kwargs)