Bug 494397 - SimpleTest.js |window.onerror| calls |SimpleTest.finish()| while test is still running; (Av1) Tabs cleanup, Improve+Add error messages, Use executeSoon(); r=rcampbell

This commit is contained in:
Serge Gautherie 2009-06-19 20:10:20 +02:00
Родитель 0215b1d90f
Коммит 4364915d15
1 изменённых файлов: 23 добавлений и 16 удалений

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

@ -180,9 +180,9 @@ SimpleTest.showReport = function() {
toggleTodo.onclick = partial(SimpleTest.toggleByClass, 'test_todo');
var body = document.body; // Handles HTML documents
if (!body) {
// Do the XML thing
// Do the XML thing.
body = document.getElementsByTagNameNS("http://www.w3.org/1999/xhtml",
"body")[0]
"body")[0];
}
var firstChild = body.childNodes[0];
var addNode;
@ -464,17 +464,24 @@ var todo = SimpleTest.todo;
var todo_is = SimpleTest.todo_is;
var todo_isnot = SimpleTest.todo_isnot;
var isDeeply = SimpleTest.isDeeply;
var oldOnError = window.onerror;
const oldOnError = window.onerror;
window.onerror = function (ev) {
is(0, 1, "Error thrown during test: " + ev);
// Log the error.
ok(false, "[SimpleTest/SimpleTest.js, window.onerror] An error occurred: [ " + ev + " ]");
// Call previous handler.
if (oldOnError) {
try {
oldOnError(ev);
} catch (e) {
// Log the exception.
ok(false, "[SimpleTest/SimpleTest.js, window.onerror] Exception thrown by oldOnError(): [ " + e + " ]");
}
}
if (SimpleTest._stopOnLoad == false) {
// Need to finish() manually here
SimpleTest.finish();
if (!SimpleTest._stopOnLoad) {
// Need to finish() manually here, yet let the test actually end first.
SimpleTest.executeSoon(SimpleTest.finish);
}
}