Bug 895471 - part 1: allow passing the flag to mochitest-browser, r=ted
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Mon, 21 Oct 2013 18:12:12 +0200
changeset 151922 00a2a5ad182e
parent 151921 9f6f1acf4290
child 151923 b50aa73e2a16
push id3192
push usergijskruitbosch@gmail.com
push dateThu, 24 Oct 2013 08:35:05 +0000
treeherderfx-team@00a2a5ad182e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted
bugs895471
milestone27.0a1
Bug 895471 - part 1: allow passing the flag to mochitest-browser, r=ted
testing/mochitest/mach_commands.py
testing/mochitest/mochitest_options.py
testing/mochitest/runtests.py
--- a/testing/mochitest/mach_commands.py
+++ b/testing/mochitest/mach_commands.py
@@ -180,17 +180,17 @@ class MochitestRunner(MozbuildObject):
         options.logcat_dir = self.mochitest_dir
         options.httpdPath = self.mochitest_dir
         options.xrePath = xre_path
         return mochitest.run_remote_mochitests(parser, options)
 
     def run_desktop_test(self, suite=None, test_file=None, debugger=None,
         debugger_args=None, shuffle=False, keep_open=False, rerun_failures=False,
         no_autorun=False, repeat=0, run_until_failure=False, slow=False,
-        chunk_by_dir=0, total_chunks=None, this_chunk=None):
+        chunk_by_dir=0, total_chunks=None, this_chunk=None, jsdebugger=False):
         """Runs a mochitest.
 
         test_file is a path to a test file. It can be a relative path from the
         top source directory, an absolute filename, or a directory containing
         test files.
 
         suite is the type of mochitest to run. It can be one of ('plain',
         'chrome', 'browser', 'metro', 'a11y').
@@ -280,16 +280,17 @@ class MochitestRunner(MozbuildObject):
         options.runUntilFailure = run_until_failure
         options.runSlower = slow
         options.testingModulesDir = os.path.join(self.tests_dir, 'modules')
         options.extraProfileFiles.append(os.path.join(self.distdir, 'plugins'))
         options.symbolsPath = os.path.join(self.distdir, 'crashreporter-symbols')
         options.chunkByDir = chunk_by_dir
         options.totalChunks = total_chunks
         options.thisChunk = this_chunk
+        options.jsdebugger = jsdebugger
 
         options.failureFile = failure_file_path
 
         if test_path:
             test_root = runner.getTestRoot(options)
             test_root_file = mozpack.path.join(self.mochitest_dir, test_root, test_path)
             if not os.path.exists(test_root_file):
                 print('Specified test path does not exist: %s' % test_root_file)
@@ -399,16 +400,20 @@ def MochitestCommand(func):
     chunk_total = CommandArgument('--total-chunks', type=int,
         help='Total number of chunks to split tests into.')
     func = chunk_total(func)
 
     this_chunk = CommandArgument('--this-chunk', type=int,
         help='If running tests by chunks, the number of the chunk to run.')
     func = this_chunk(func)
 
+    jsdebugger = CommandArgument('--jsdebugger', action='store_true',
+        help='Start the browser JS debugger before running the test. Implies --no-autorun.')
+    func = jsdebugger(func)
+
     path = CommandArgument('test_file', default=None, nargs='?',
         metavar='TEST',
         help='Test to run. Can be specified as a single file, a ' \
             'directory, or omitted. If omitted, the entire test suite is ' \
             'executed.')
     func = path(func)
 
     return func
--- a/testing/mochitest/mochitest_options.py
+++ b/testing/mochitest/mochitest_options.py
@@ -315,16 +315,22 @@ class MochitestOptions(optparse.OptionPa
         [["--setpref"],
         { "action": "append",
           "type": "string",
           "default": [],
           "dest": "extraPrefs",
           "metavar": "PREF=VALUE",
           "help": "defines an extra user preference",
         }],
+        [["--jsdebugger"],
+        { "action": "store_true",
+          "default": False,
+          "dest": "jsdebugger",
+          "help": "open the browser debugger",
+        }],
     ]
 
     def __init__(self, **kwargs):
 
         optparse.OptionParser.__init__(self, **kwargs)
         for option, value in self.mochitest_options:
             self.add_option(*option, **value)
         addCommonOptions(self)
@@ -408,16 +414,25 @@ class MochitestOptions(optparse.OptionPa
             options.runOnlyTests = None
 
         if options.manifestFile and options.testManifest:
             self.error("Unable to support both --manifest and --test-manifest/--run-only-tests at the same time")
 
         if options.webapprtContent and options.webapprtChrome:
             self.error("Only one of --webapprt-content and --webapprt-chrome may be given.")
 
+        if options.jsdebugger:
+            options.extraPrefs += [
+                "devtools.debugger.remote-enabled=true",
+                "devtools.debugger.chrome-enabled=true",
+                "devtools.chrome.enabled=true",
+                "devtools.debugger.prompt-connection=false"
+            ]
+            options.autorun = False
+
         # Try to guess the testing modules directory.
         # This somewhat grotesque hack allows the buildbot machines to find the
         # modules directory without having to configure the buildbot hosts. This
         # code should never be executed in local runs because the build system
         # should always set the flag that populates this variable. If buildbot ever
         # passes this argument, this code can be deleted.
         if options.testingModulesDir is None:
             possible = os.path.join(os.getcwd(), os.path.pardir, 'modules')
--- a/testing/mochitest/runtests.py
+++ b/testing/mochitest/runtests.py
@@ -970,16 +970,19 @@ class Mochitest(MochitestUtilsMixin):
     if options.webapprtContent:
       options.browserArgs.extend(('-test-mode', testURL))
       testURL = None
 
     if options.immersiveMode:
       options.browserArgs.extend(('-firefoxpath', options.app))
       options.app = self.immersiveHelperPath
 
+    if options.jsdebugger:
+      options.browserArgs.extend(['-jsdebugger'])
+
     # Remove the leak detection file so it can't "leak" to the tests run.
     # The file is not there if leak logging was not enabled in the application build.
     if os.path.exists(self.leak_report_file):
       os.remove(self.leak_report_file)
 
     # then again to actually run mochitest
     if options.timeout:
       timeout = options.timeout + 30