Bug 997909 - Make waitFor actually terminate if condition is never true, r=mdas

This commit is contained in:
Jonathan Griffin 2014-10-02 10:09:33 -07:00
Родитель 0fac57585a
Коммит f7fb5ca1d2
1 изменённых файлов: 6 добавлений и 5 удалений

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

@ -170,18 +170,19 @@ Marionette.prototype = {
waitFor: function test_waitFor(callback, test, timeout) {
this.heartbeatCallback();
if (test()) {
callback();
return;
callback();
return;
}
var now = Date.now();
var deadline = now + (typeof(timeout) == "undefined" ? this.timeout : timeout);
var now = new Date();
var deadline = (timeout instanceof Date) ? timeout :
new Date(now.valueOf + (typeof(timeout) == "undefined" ? this.timeout : timeout))
if (deadline <= now) {
dump("waitFor timeout: " + test.toString() + "\n");
// the script will timeout here, so no need to raise a separate
// timeout exception
return;
}
this.window.setTimeout(this.waitFor.bind(this), 100, callback, test, deadline - now);
this.window.setTimeout(this.waitFor.bind(this), 100, callback, test, deadline);
},
runEmulatorCmd: function runEmulatorCmd(cmd, callback) {