Bug 771271 - Get mochitest-metro-chrome tests running in immersive mode. r=jmaher
authorJim Mathies <jmathies@mozilla.com>
Tue, 12 Feb 2013 14:51:24 -0600
changeset 131486 e86fce88995eb3469e4b4ae7d5da6376daab0d9f
parent 131485 db5d55b48b3f2888bf0e512b00350dd21f600243
child 131487 246c76621b80fcabc8847650902eef509bbf6572
push id2323
push userbbajaj@mozilla.com
push dateMon, 01 Apr 2013 19:47:02 +0000
treeherdermozilla-beta@7712be144d91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmaher
bugs771271
milestone21.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 771271 - Get mochitest-metro-chrome tests running in immersive mode. r=jmaher
browser/build.mk
testing/mochitest/browser-harness.xul
testing/mochitest/browser-test.js
testing/mochitest/runtests.py
--- a/browser/build.mk
+++ b/browser/build.mk
@@ -79,9 +79,15 @@ ifdef ENABLE_TESTS
 
 mochitest-browser-chrome:
 	$(RUN_MOCHITEST) --browser-chrome
 	$(CHECK_TEST_ERROR)
 
 mochitest:: mochitest-browser-chrome
 
 .PHONY: mochitest-browser-chrome
+
+mochitest-metro-chrome:
+	$(RUN_MOCHITEST) --metro-immersive --browser-chrome
+	$(CHECK_TEST_ERROR)
+
+
 endif
--- a/testing/mochitest/browser-harness.xul
+++ b/testing/mochitest/browser-harness.xul
@@ -184,16 +184,17 @@
     function setStatus(aStatusString) {
       document.getElementById("status").value = aStatusString;
     }
 
     function runTests() {
       var windowMediator = Cc['@mozilla.org/appshell/window-mediator;1'].
                              getService(Ci.nsIWindowMediator);
       var winType = gConfig.testRoot == "browser" ? "navigator:browser" :
+                    gConfig.testRoot == "metro" ? "navigator:browser" :
                     gConfig.testRoot == "webapprtChrome" ? "webapprt:webapp" :
                     null;
       if (!winType) {
         throw new Error("Unrecognized gConfig.testRoot: " + gConfig.testRoot);
       }
       var testWin = windowMediator.getMostRecentWindow(winType);
 
       setStatus("Running...");
--- a/testing/mochitest/browser-test.js
+++ b/testing/mochitest/browser-test.js
@@ -14,17 +14,19 @@ XPCOMUtils.defineLazyModuleGetter(this, 
   "resource://gre/modules/Services.jsm");
 
 window.addEventListener("load", testOnLoad, false);
 
 function testOnLoad() {
   window.removeEventListener("load", testOnLoad, false);
 
   gConfig = readConfig();
-  if (gConfig.testRoot == "browser" || gConfig.testRoot == "webapprtChrome") {
+  if (gConfig.testRoot == "browser" ||
+      gConfig.testRoot == "metro" ||
+      gConfig.testRoot == "webapprtChrome") {
     // Make sure to launch the test harness for the first opened window only
     var prefs = Services.prefs;
     if (prefs.prefHasUserValue("testing.browserTestHarness.running"))
       return;
 
     prefs.setBoolPref("testing.browserTestHarness.running", true);
 
     var sstring = Cc["@mozilla.org/supports-string;1"].
--- a/testing/mochitest/runtests.py
+++ b/testing/mochitest/runtests.py
@@ -246,16 +246,21 @@ class MochitestOptions(optparse.OptionPa
                     help = "Filename of the output file where we can store a .json list of failures to be run in the future with --run-only-tests.")
     defaults["failureFile"] = None
 
     self.add_option("--run-slower",
                     action = "store_true", dest = "runSlower",
                     help = "Delay execution between test files.")
     defaults["runSlower"] = False
 
+    self.add_option("--metro-immersive",
+                    action = "store_true", dest = "immersiveMode",
+                    help = "launches tests in immersive browser")
+    defaults["immersiveMode"] = False
+
     # -h, --help are automatically handled by OptionParser
 
     self.set_defaults(**defaults)
 
     usage = """\
 Usage instructions for runtests.py.
 All arguments are optional.
 If --chrome is specified, chrome tests will be run instead of web content tests.
@@ -358,16 +363,25 @@ See <http://mochikit.com/doc/html/MochiK
       if not os.path.isdir(options.testingModulesDir):
         self.error('--testing-modules-dir not a directory: %s' %
           options.testingModulesDir)
 
       options.testingModulesDir = options.testingModulesDir.replace('\\', '/')
       if options.testingModulesDir[-1] != '/':
         options.testingModulesDir += '/'
 
+    if options.immersiveMode:
+      if not self._automation.IS_WIN32:
+        self.error("immersive is only supported on Windows 8 and up.")
+      mochitest.immersiveHelperPath = os.path.join(
+        options.utilityPath, "metrotestharness.exe")
+      if not os.path.exists(mochitest.immersiveHelperPath):
+        self.error("%s not found, cannot launch immersive tests." %
+                   mochitest.immersiveHelperPath)
+
     return options
 
 
 #######################
 # HTTP SERVER SUPPORT #
 #######################
 
 class MochitestServer:
@@ -713,16 +727,19 @@ class Mochitest(object):
     self.buildURLOptions(options, browserEnv)
     if len(self.urlOpts) > 0:
       testURL += "?" + "&".join(self.urlOpts)
 
     if options.webapprtContent:
       options.browserArgs.extend(('-test-mode', testURL))
       testURL = None
 
+    if options.immersiveMode:
+      options.app = self.immersiveHelperPath
+
     # 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
@@ -793,17 +810,20 @@ class Mochitest(object):
       else:
         print "unknown type: %s: %s" % (opt, val)
         sys.exit(1)
 
     options.logFile = options.logFile.replace("\\", "\\\\")
     options.testPath = options.testPath.replace("\\", "\\\\")
     testRoot = 'chrome'
     if (options.browserChrome):
-      testRoot = 'browser'
+      if (options.immersiveMode):
+        testRoot = 'metro'
+      else:
+        testRoot = 'browser'
     elif (options.a11y):
       testRoot = 'a11y'
     elif (options.webapprtChrome):
       testRoot = 'webapprtChrome'
 
     if "MOZ_HIDE_RESULTS_TABLE" in os.environ and os.environ["MOZ_HIDE_RESULTS_TABLE"] == "1":
       options.hideResultsTable = True