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 2008-12-08 21:47:34 -08:00
Родитель 69d4429beb
Коммит a0ba5c886d
2 изменённых файлов: 24 добавлений и 26 удалений

Просмотреть файл

@ -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(SimpleTest._tests);
} else {
SimpleTest.showReport();
}
};

Просмотреть файл

@ -148,13 +148,13 @@ TestRunner.runNextTest = function() {
/**
* This stub is called by SimpleTest when a test is finished.
**/
TestRunner.testFinished = function(doc) {
TestRunner.testFinished = function(tests) {
var finishedURL = TestRunner._urls[TestRunner._currentTest];
if (TestRunner.logEnabled)
TestRunner.logger.debug("SimpleTest finished " + finishedURL);
TestRunner.updateUI();
TestRunner.updateUI(tests);
TestRunner._currentTest++;
TestRunner.runNextTest();
};
@ -162,21 +162,25 @@ 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(tests) {
var nOK = 0;
var nNotOK = 0;
var nTodo = 0;
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);
TestRunner.updateUI = function(tests) {
var results = TestRunner.countResults(tests);
var passCount = parseInt($("pass-count").innerHTML) + results.OK;
var failCount = parseInt($("fail-count").innerHTML) + results.notOK;
var todoCount = parseInt($("todo-count").innerHTML) + results.todo;