Make mochitests not build and search the results table when run inside the harness. (Bug 466104) r=sayrer

This commit is contained in:
L. David Baron 2010-04-04 20:48:59 -07:00
parent 238beaa031
commit 71f1e1e1ec
2 changed files with 24 additions and 28 deletions

View file

@ -340,23 +340,17 @@ SimpleTest.executeSoon = function(aFunc) {
} }
} }
/**
* Talks to the TestRunner if being ran on a iframe and the parent has a
* TestRunner object.
**/
SimpleTest.talkToRunner = function () {
if (parentRunner) {
parentRunner.testFinished(document);
}
};
/** /**
* Finishes the tests. This is automatically called, except when * Finishes the tests. This is automatically called, except when
* SimpleTest.waitForExplicitFinish() has been invoked. * SimpleTest.waitForExplicitFinish() has been invoked.
**/ **/
SimpleTest.finish = function () { SimpleTest.finish = function () {
SimpleTest.showReport(); if (parentRunner) {
SimpleTest.talkToRunner(); /* We're running in an iframe, and the parent has a TestRunner */
parentRunner.testFinished(SimpleTest._tests);
} else {
SimpleTest.showReport();
}
}; };

View file

@ -180,12 +180,12 @@ TestRunner.runNextTest = function() {
/** /**
* This stub is called by SimpleTest when a test is finished. * This stub is called by SimpleTest when a test is finished.
**/ **/
TestRunner.testFinished = function(doc) { TestRunner.testFinished = function(tests) {
if (TestRunner.logEnabled) if (TestRunner.logEnabled)
TestRunner.logger.debug("SimpleTest finished " + TestRunner.logger.debug("SimpleTest finished " +
TestRunner._urls[TestRunner._currentTest]); TestRunner._urls[TestRunner._currentTest]);
TestRunner.updateUI(); TestRunner.updateUI(tests);
TestRunner._currentTest++; TestRunner._currentTest++;
TestRunner.runNextTest(); TestRunner.runNextTest();
}; };
@ -193,23 +193,25 @@ TestRunner.testFinished = function(doc) {
/** /**
* Get the results. * Get the results.
*/ */
TestRunner.countResults = function(doc) { TestRunner.countResults = function(tests) {
var nOK = withDocument(doc, var nOK = 0;
partial(getElementsByTagAndClassName, 'div', 'test_ok') var nNotOK = 0;
).length; var nTodo = 0;
var nNotOK = withDocument(doc, for (var i = 0; i < tests.length; ++i) {
partial(getElementsByTagAndClassName, 'div', 'test_not_ok') var test = tests[i];
).length; if (test.todo && !test.result) {
var nTodo = withDocument(doc, nTodo++;
partial(getElementsByTagAndClassName, 'div', 'test_todo') } else if (test.result && !test.todo) {
).length; nOK++;
} else {
nNotOK++;
}
}
return {"OK": nOK, "notOK": nNotOK, "todo": nTodo}; return {"OK": nOK, "notOK": nNotOK, "todo": nTodo};
} }
TestRunner.updateUI = function() { TestRunner.updateUI = function(tests) {
var testFrame = $('testframe'); var results = TestRunner.countResults(tests);
var results = TestRunner.countResults(testFrame.contentDocument ||
testFrame.contentWindow.document);
var passCount = parseInt($("pass-count").innerHTML) + results.OK; var passCount = parseInt($("pass-count").innerHTML) + results.OK;
var failCount = parseInt($("fail-count").innerHTML) + results.notOK; var failCount = parseInt($("fail-count").innerHTML) + results.notOK;
var todoCount = parseInt($("todo-count").innerHTML) + results.todo; var todoCount = parseInt($("todo-count").innerHTML) + results.todo;