Skip to content
This repository has been archived by the owner on Aug 20, 2018. It is now read-only.

Bug 665410 - waitFor callback has to return a boolean value. r=ctalbert #35

Merged
merged 1 commit into from
May 23, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion mozmill/mozmill/extension/resource/stdlib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,13 @@ function waitFor(callback, message, timeout, interval, thisObject) {
var thread = Cc["@mozilla.org/thread-manager;1"]
.getService().currentThread;

while ((self.result != true) && (self.counter < timeout)) {
while (true) {
if (typeof(self.result) !== 'boolean')
throw TypeError("waitFor() callback has to return a boolean value.");

if (self.result === true || self.counter >= timeout)
break;

thread.processNextEvent(true);
}

Expand Down
29 changes: 29 additions & 0 deletions mutt/mutt/tests/js/test_waitFor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
var setupModule = function () {
controller = mozmill.getBrowserController();
}

var testWaitForCallback = function () {
expect.doesNotThrow(function () {
controller.waitFor(function () {
return true;
});
}, "TypeError", "Return type 'boolean' in callback is supported.");

expect.throws(function () {
controller.waitFor(function () {
return 4;
});
}, "TypeError", "Return type 'number' in callback is not supported.");

expect.throws(function () {
controller.waitFor(function () {
return "true";
});
}, "TypeError", "Return type 'string' in callback is not supported.");

expect.throws(function () {
controller.waitFor(function () {
return new Object();
});
}, "TypeError", "Return type 'Object' in callback is not supported.");
}