Bug 452706 - Avoid the confusion of indistinguishable failure reasons. r=sayrer a=tests

This commit is contained in:
Hiroyuki Ikezoe 2011-01-21 12:36:59 +01:00
parent 6c238d87c8
commit 3efec02adc
2 changed files with 39 additions and 17 deletions

View File

@ -215,11 +215,13 @@ Test.Unit.Runner = Class.create({
var test = this.tests[this.currentTest], actions;
if (!test) return this.finish();
if (test.timerID > 0) test.timerID = -1;
if (!test.isWaiting) this.logger.start(test.name);
test.run();
if (test.isWaiting) {
this.logger.message("Waiting for " + test.timeToWait + "ms");
setTimeout(this.runTests.bind(this), test.timeToWait || 1000);
test.runner = this;
test.timerID = setTimeout(this.runTests.bind(this), test.timeToWait || 1000);
return;
}
@ -487,6 +489,8 @@ Test.Unit.Testcase = Class.create(Test.Unit.Assertions, {
isWaiting: false,
timeToWait: 1000,
timerID: -1,
runner: null,
assertions: 0,
failures: 0,
errors: 0,
@ -498,6 +502,17 @@ Test.Unit.Testcase = Class.create(Test.Unit.Assertions, {
this.timeToWait = time;
},
cancelWait: function() {
if (this.timerID > 0) {
clearTimeout(this.timerID);
this.timerID = -1;
this.test = function(){};
// continue test
if (this.runner)
this.runner.runTests();
}
},
run: function(rethrow) {
try {
try {

View File

@ -49,23 +49,30 @@ new Test.Unit.Runner({
testUpdater: function() {
this.assertEqual("", $("content").innerHTML);
new Ajax.Updater("content", "../fixtures/content.html", { method:'get' });
new Ajax.Updater("content", "../fixtures/content.html", { method:'get', onComplete: function() {
this.assertEqual(sentence, $("content").innerHTML.strip().toLowerCase());
$('content').update('');
this.assertEqual("", $("content").innerHTML);
new Ajax.Updater({ success:"content", failure:"content2" },
"../fixtures/content.html",
{ method:'get', parameters:{ pet:'monkey' }, onComplete: function() {
this.assertEqual(sentence, $("content").innerHTML.strip().toLowerCase());
this.assertEqual("", $("content2").innerHTML);
$('content').update('');
this.assertEqual("", $("content").innerHTML);
new Ajax.Updater("", "../fixtures/content.html",
{ method:'get', parameters:"pet=monkey", onComplete: function() {
this.assertEqual("", $("content").innerHTML);
this.cancelWait();
}.bind(this)
});
}.bind(this)
});
}.bind(this)
});
this.wait(1000, function() {
this.assertEqual(sentence, $("content").innerHTML.strip().toLowerCase());
$('content').update('');
this.assertEqual("", $("content").innerHTML);
new Ajax.Updater({ success:"content", failure:"content2" },
"../fixtures/content.html", { method:'get', parameters:{ pet:'monkey' } });
new Ajax.Updater("", "../fixtures/content.html", { method:'get', parameters:"pet=monkey" });
this.wait(1000, function() {
// bug 452706 this.assertEqual(sentence, $("content").innerHTML.strip().toLowerCase());
this.assertEqual("", $("content2").innerHTML);
});
this.flunk("The request was timeouted.");
});
},