diff --git a/common/content/events.js b/common/content/events.js index ff6aaebf..a1393e60 100644 --- a/common/content/events.js +++ b/common/content/events.js @@ -916,7 +916,7 @@ var Events = Module("events", { let start = Date.now(); let end = start + (maxWaitTime * 1000); - util.waitFor(function () !events.feedingKeys || buffer.loaded || Date.now() > end); + util.waitFor(function () !events.feedingKeys || buffer.loaded, this, maxWaitTime); commandline.clear(); if (!buffer.loaded) diff --git a/common/modules/completion.jsm b/common/modules/completion.jsm index 9f291f02..afd866ac 100644 --- a/common/modules/completion.jsm +++ b/common/modules/completion.jsm @@ -804,9 +804,7 @@ var CompletionContext = Class("CompletionContext", { * If 0 or null, wait indefinitely. */ wait: function wait(interruptable, timeout) { - let end = Date.now() + timeout; - util.waitFor(function () !this.incomplete || (this.timeout && Date.now() > end), - this); + util.waitFor(function () !this.incomplete, this, timeout); return this.incomplete; } }, { diff --git a/common/modules/util.jsm b/common/modules/util.jsm index 01fce1ae..4459f597 100644 --- a/common/modules/util.jsm +++ b/common/modules/util.jsm @@ -1526,8 +1526,9 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), this.yielders--; } }, - waitFor: function waitFor(test, self, interruptable) { - while (!test.call(self)) + waitFor: function waitFor(test, self, timeout, interruptable) { + let end = timeout && Date.now() + timeout; + while ((!end || Date.now() < end) && !test.call(self)) this.threadYield(false, interruptable); },