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
Родитель 238beaa031
Коммит 71f1e1e1ec
2 изменённых файлов: 24 добавлений и 28 удалений

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

@ -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
* 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();
}
};

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

@ -180,12 +180,12 @@ TestRunner.runNextTest = function() {
/**
* This stub is called by SimpleTest when a test is finished.
**/
TestRunner.testFinished = function(doc) {
TestRunner.testFinished = function(tests) {
if (TestRunner.logEnabled)
TestRunner.logger.debug("SimpleTest finished " +
TestRunner._urls[TestRunner._currentTest]);
TestRunner.updateUI();
TestRunner.updateUI(tests);
TestRunner._currentTest++;
TestRunner.runNextTest();
};
@ -193,23 +193,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 testFrame = $('testframe');
var results = TestRunner.countResults(testFrame.contentDocument ||
testFrame.contentWindow.document);
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;