Commit 58f0c289 authored by Henrik Skupin's avatar Henrik Skupin
Browse files

Bug 1606637 - [marionette] Use plain Promise instead of TimedPromise for Sleep. r=maja_zf, a=RyanVM

TimedPromise logs a warning if the timeout exceeded and not error
should be raised. Given that Sleep always runs into that condition
a lot of inappropriate log entries are made that also causes
confusion for our users when commands (especially actions) don't
work as expected.

Differential Revision: https://phabricator.services.mozilla.com/D89354
parent 6dd48967
......@@ -280,7 +280,22 @@ function Sleep(timeout) {
if (typeof timeout != "number") {
throw new TypeError();
}
return new TimedPromise(() => {}, { timeout, throws: null });
if (!Number.isInteger(timeout) || timeout < 0) {
throw new RangeError();
}
return new Promise(resolve => {
const timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
timer.init(
() => {
// Bug 1663880 - Explicitely cancel the timer for now to prevent a hang
timer.cancel();
resolve();
},
timeout,
TYPE_ONE_SHOT
);
});
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment