imported patch mdas_loops.patch
☠☠ backed out by 77e5f71a78e4 ☠ ☠
authorJoel Maher <jmaher@mozilla.com>
Thu, 25 Aug 2011 14:20:51 -0400
changeset 75904 7918fee254ae94490f11f9996fdda7742e13f886
parent 75903 d4003f345b2418211b0327d757c6ac1268162115
child 75905 1b09c80c46c31d300beee7a8fc78963b37d3e18f
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
milestone9.0a1
imported patch mdas_loops.patch
testing/mochitest/plain-loop.html
testing/mochitest/runtests.py
testing/mochitest/tests/SimpleTest/TestRunner.js
--- a/testing/mochitest/plain-loop.html
+++ b/testing/mochitest/plain-loop.html
@@ -1,14 +1,15 @@
 <html>
 <head>
   <link rel="stylesheet" type="text/css" href="/static/harness.css" />
   <script type="text/javascript" src="/tests/SimpleTest/LogController.js"></script>        
   <script type="text/javascript" src="/tests/SimpleTest/TestRunner.js"></script>        
   <script type="text/javascript" src="/tests/SimpleTest/MozillaFileLogger.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/quit.js"></script>
   <script type="text/javascript" src="/tests/SimpleTest/setup.js"></script>
   </head>
   <script type="text/javascript">
 
 function loadTests()
 {
   var links = {};
   var params = {};
--- a/testing/mochitest/runtests.py
+++ b/testing/mochitest/runtests.py
@@ -405,19 +405,19 @@ class WebSocketServer(object):
       sys.exit(2)
     self._automation.log.info("INFO | runtests.py | Websocket server pid: %d", pid)
 
   def stop(self):
     self._process.kill()
 
 class Mochitest(object):
   # Path to the test script on the server
-  TEST_PATH = "/tests/"
-  CHROME_PATH = "/redirect.html";
-  PLAIN_LOOP_PATH = "/plain-loop.html";
+  TEST_PATH = "tests"
+  CHROME_PATH = "redirect.html"
+  PLAIN_LOOP_PATH = "plain-loop.html"
   urlOpts = []
   runSSLTunnel = True
   vmwareHelper = None
 
   oldcwd = os.getcwd()
 
   def __init__(self, automation):
     self.automation = automation
@@ -435,25 +435,25 @@ class Mochitest(object):
 
   def getFullPath(self, path):
     " Get an absolute path relative to self.oldcwd."
     return os.path.normpath(os.path.join(self.oldcwd, os.path.expanduser(path)))
 
   def buildTestPath(self, options):
     """ Build the url path to the specific test harness and test file or directory """
     testHost = "http://mochi.test:8888"
-    testURL = testHost + self.TEST_PATH + options.testPath
-    if os.path.isfile(self.oldcwd + self.TEST_PATH + options.testPath) and options.loops > 0:
-       testURL = testHost + self.PLAIN_LOOP_PATH
+    testURL = ("/").join([testHost, self.TEST_PATH, options.testPath])
+    if os.path.isfile(os.path.join(self.oldcwd, os.path.dirname(__file__), self.TEST_PATH, options.testPath)) and options.loops > 0:
+       testURL = ("/").join([testHost, self.PLAIN_LOOP_PATH])
     if options.chrome or options.a11y:
-       testURL = testHost + self.CHROME_PATH
+       testURL = ("/").join([testHost, self.CHROME_PATH])
     elif options.browserChrome:
       testURL = "about:blank"
     elif options.ipcplugins:
-      testURL = testHost + self.TEST_PATH + "dom/plugins/test"
+      testURL = ("/").join([testHost, self.TEST_PATH, "dom/plugins/test"])
     return testURL
 
   def startWebSocketServer(self, options, debuggerInfo):
     """ Launch the websocket server """
     if options.webServer != '127.0.0.1':
       return
 
     self.wsserver = WebSocketServer(self.automation, options,
@@ -574,18 +574,18 @@ class Mochitest(object):
       if options.chunkByDir:
         self.urlOpts.append("chunkByDir=%d" % options.chunkByDir)
       if options.shuffle:
         self.urlOpts.append("shuffle=1")
       if "MOZ_HIDE_RESULTS_TABLE" in env and env["MOZ_HIDE_RESULTS_TABLE"] == "1":
         self.urlOpts.append("hideResultsTable=1")
       if options.loops:
         self.urlOpts.append("loops=%d" % options.loops)
-      if os.path.isfile(self.oldcwd + self.TEST_PATH + options.testPath) and options.loops > 0:
-        self.urlOpts.append("testname=%s" % (self.TEST_PATH + options.testPath))
+      if os.path.isfile(os.path.join(self.oldcwd, os.path.dirname(__file__), self.TEST_PATH, options.testPath)) and options.loops > 0:
+        self.urlOpts.append("testname=%s" % ("/").join([self.TEST_PATH, options.testPath]))
 
   def cleanup(self, manifest, options):
     """ remove temporary files and profile """
     os.remove(manifest)
     shutil.rmtree(options.profilePath)
 
   def startVMwareRecording(self, options):
     """ starts recording inside VMware VM using the recording helper dll """
--- a/testing/mochitest/tests/SimpleTest/TestRunner.js
+++ b/testing/mochitest/tests/SimpleTest/TestRunner.js
@@ -238,38 +238,47 @@ TestRunner.resetTests = function(listURL
   window.focus();
   $('testframe').focus();
   TestRunner.runNextTest();
 }
 
 /*
  * Used to run a single test in a loop and update the UI with the results
  */
-TestRunner.loopTest = function(testPath){
- var numLoops = TestRunner.loops;
-  while(numLoops >= 0){
-    //must set the following line so that TestHarness.updateUI finds the right div to update
-    $("current-test-path").innerHTML = testPath;
-    function checkComplete() {
-      var testWindow = window.open(testPath, 'test window');
-      if (testWindow.document.readyState == "complete") {
-        TestRunner.currentTestURL = testPath;
-        TestRunner.updateUI(testWindow.SimpleTest._tests);
-        testWindow.close();
-      } else {
-        setTimeout(checkComplete, 1000);
+TestRunner.loopTest = function(testPath) {
+  //must set the following line so that TestHarness.updateUI finds the right div to update
+  document.getElementById("current-test-path").innerHTML = testPath;
+  var numLoops = TestRunner.loops;
+  var completed = 0; // keep track of how many tests have finished
+
+  // function to kick off the test and to check when the test is complete
+  function checkComplete() {
+    var testWindow = window.open(testPath, 'test window'); // kick off the test or find the active window
+    if (testWindow.document.readyState == "complete") {
+      // the test is complete -> mark as complete
+      TestRunner.currentTestURL = testPath;
+      TestRunner.updateUI(testWindow.SimpleTest._tests);
+      testWindow.close();
+      if (TestRunner.loops == completed  && TestRunner.onComplete) {
+        TestRunner.onComplete();
       }
+      completed++;
     }
+    else {
+      // wait and check later
+      setTimeout(checkComplete, 1000);
+    }
+  }
+  while (numLoops >= 0) {
     checkComplete();
     numLoops--;
   }
 }
 
 /**
-/**
  * Run the next test. If no test remains, calls onComplete().
  **/
 TestRunner._haltTests = false;
 TestRunner.runNextTest = function() {
     if (TestRunner._currentTest < TestRunner._urls.length &&
         !TestRunner._haltTests)
     {
         var url = TestRunner._urls[TestRunner._currentTest];