Bug 1529516 - [marionette] Use Promise instead of TimedPromise for Sleep(). r=ato

"Sleep()" currently uses the TimedPromise class and as such logs
a warning message each time. To not massively clutter the log files
with those entries Sleep should just use a plain Promise.

Depends on D20637

Differential Revision: https://phabricator.services.mozilla.com/D20638

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Henrik Skupin 2019-02-21 13:11:11 +00:00
parent 8116bbe8f7
commit 65837e9068

View File

@ -262,7 +262,14 @@ 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.initWithCallback({notify: resolve}, timeout, TYPE_ONE_SHOT);
});
}
/**