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

This commit is contained in:
L. David Baron 2008-11-25 13:27:54 -08:00
parent dc119e5622
commit 5be1b4ba70
2 changed files with 22 additions and 23 deletions

View File

@ -216,23 +216,17 @@ SimpleTest.executeSoon = function(aFunc) {
}, Components.interfaces.nsIThread.DISPATCH_NORMAL);
}
/**
* 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
* SimpleTest.waitForExplicitFinish() has been invoked.
**/
SimpleTest.finish = function () {
SimpleTest.showReport();
SimpleTest.talkToRunner();
if (parentRunner) {
/* We're running in an iframe, and the parent has a TestRunner */
parentRunner.testFinished(document);
} else {
SimpleTest.showReport();
}
};

View File

@ -162,21 +162,26 @@ TestRunner.testFinished = function(doc) {
/**
* Get the results.
*/
TestRunner.countResults = function(doc) {
var nOK = withDocument(doc,
partial(getElementsByTagAndClassName, 'div', 'test_ok')
).length;
var nNotOK = withDocument(doc,
partial(getElementsByTagAndClassName, 'div', 'test_not_ok')
).length;
var nTodo = withDocument(doc,
partial(getElementsByTagAndClassName, 'div', 'test_todo')
).length;
TestRunner.countResults = function(win) {
var nOK = 0;
var nNotOK = 0;
var nTodo = 0;
var tests = win.SimpleTest._tests;
for (var i = 0; i < tests.length; ++i) {
var test = tests[i];
if (test.todo && !test.result) {
nTodo++;
} else if (test.result && !test.todo) {
nOK++;
} else {
nNotOK++;
}
}
return {"OK": nOK, "notOK": nNotOK, "todo": nTodo};
}
TestRunner.updateUI = function() {
var results = TestRunner.countResults($('testframe').contentDocument);
var results = TestRunner.countResults($('testframe').contentWindow);
var passCount = parseInt($("pass-count").innerHTML) + results.OK;
var failCount = parseInt($("fail-count").innerHTML) + results.notOK;
var todoCount = parseInt($("todo-count").innerHTML) + results.todo;