diff --git a/testing/mochitest/Makefile.in b/testing/mochitest/Makefile.in index 7bb3ba48312c..86b73957d85d 100644 --- a/testing/mochitest/Makefile.in +++ b/testing/mochitest/Makefile.in @@ -100,6 +100,7 @@ _SERV_FILES = \ $(topsrcdir)/netwerk/test/httpserver/httpd.js \ mozprefs.js \ pywebsocket_wrapper.py \ + plain-loop.html \ $(NULL) _PYWEBSOCKET_FILES = \ diff --git a/testing/mochitest/browser-test.js b/testing/mochitest/browser-test.js index 6ccc5d0b99ff..d305825eef17 100644 --- a/testing/mochitest/browser-test.js +++ b/testing/mochitest/browser-test.js @@ -58,6 +58,7 @@ Tester.prototype = { EventUtils: {}, SimpleTest: {}, + loops: 0, checker: null, currentTestIndex: -1, lastStartTime: null, @@ -69,6 +70,10 @@ Tester.prototype = { }, start: function Tester_start() { + //if testOnLoad was not called, then gConfig is not defined + if(!gConfig) + gConfig = readConfig(); + this.loops = gConfig.loops; this.dumper.dump("*** Start BrowserChrome Test Results ***\n"); this._cs.registerListener(this); @@ -124,33 +129,40 @@ Tester.prototype = { }, finish: function Tester_finish(aSkipSummary) { - this._cs.unregisterListener(this); - - this.dumper.dump("\nINFO TEST-START | Shutdown\n"); - if (this.tests.length) { - this.dumper.dump("Browser Chrome Test Summary\n"); - - function sum(a,b) a+b; - var passCount = this.tests.map(function (f) f.passCount).reduce(sum); - var failCount = this.tests.map(function (f) f.failCount).reduce(sum); - var todoCount = this.tests.map(function (f) f.todoCount).reduce(sum); - - this.dumper.dump("\tPassed: " + passCount + "\n" + - "\tFailed: " + failCount + "\n" + - "\tTodo: " + todoCount + "\n"); - } else { - this.dumper.dump("TEST-UNEXPECTED-FAIL | (browser-test.js) | " + - "No tests to run. Did you pass an invalid --test-path?"); + if(this.loops > 0){ + --this.loops; + this.currentTestIndex = -1; + this.nextTest(); + } + else{ + this._cs.unregisterListener(this); + + this.dumper.dump("\nINFO TEST-START | Shutdown\n"); + if (this.tests.length) { + this.dumper.dump("Browser Chrome Test Summary\n"); + + function sum(a,b) a+b; + var passCount = this.tests.map(function (f) f.passCount).reduce(sum); + var failCount = this.tests.map(function (f) f.failCount).reduce(sum); + var todoCount = this.tests.map(function (f) f.todoCount).reduce(sum); + + this.dumper.dump("\tPassed: " + passCount + "\n" + + "\tFailed: " + failCount + "\n" + + "\tTodo: " + todoCount + "\n"); + } else { + this.dumper.dump("TEST-UNEXPECTED-FAIL | (browser-test.js) | " + + "No tests to run. Did you pass an invalid --test-path?"); + } + + this.dumper.dump("\n*** End BrowserChrome Test Results ***\n"); + + this.dumper.done(); + + // Tests complete, notify the callback and return + this.callback(this.tests); + this.callback = null; + this.tests = null; } - - this.dumper.dump("\n*** End BrowserChrome Test Results ***\n"); - - this.dumper.done(); - - // Tests complete, notify the callback and return - this.callback(this.tests); - this.callback = null; - this.tests = null; }, observe: function Tester_observe(aConsoleMessage) { diff --git a/testing/mochitest/harness-overlay.xul b/testing/mochitest/harness-overlay.xul index 7683fda13825..5df9c4af0686 100644 --- a/testing/mochitest/harness-overlay.xul +++ b/testing/mochitest/harness-overlay.xul @@ -32,7 +32,7 @@ function loadTests() { window.removeEventListener("load", loadTests, false); [links, singleTestPath] = getTestList(); - + // load server.js in so we can share template functions var scriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"]. getService(Ci.mozIJSSubScriptLoader); @@ -49,10 +49,13 @@ function loadTests() } gTestList = eval(srvScope.jsonArrayOfTestFiles(links)); populate(); - hookup(); - if (singleTestPath) - window.location.href = singleTestPath; + if (singleTestPath) { + TestRunner.loopTest(singleTestPath); + } else { + hookup(); + } + } window.addEventListener("load", loadTests, false); @@ -63,6 +66,7 @@ function loadTests()