diff --git a/testing/mochitest/tests/SimpleTest/SimpleTest.js b/testing/mochitest/tests/SimpleTest/SimpleTest.js index 192d31c072ef..bb0e99c5c0d4 100644 --- a/testing/mochitest/tests/SimpleTest/SimpleTest.js +++ b/testing/mochitest/tests/SimpleTest/SimpleTest.js @@ -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(); + } }; diff --git a/testing/mochitest/tests/SimpleTest/TestRunner.js b/testing/mochitest/tests/SimpleTest/TestRunner.js index 66bccb15fe85..7a993ce26980 100644 --- a/testing/mochitest/tests/SimpleTest/TestRunner.js +++ b/testing/mochitest/tests/SimpleTest/TestRunner.js @@ -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;