Bug 1256439 - Run implicit wait callback once before start polling. r=automatedtester

By using a timer the first invocation of the callback is happening after the specified interval.
That means by a default of 100ms we loose that time on every call of implicit wait, and it will
slow-down the test execution drastically. To prevent this lets manually invoke the callback
before starting the timer.

MozReview-Commit-ID: Ayy1GPEaY92

--HG--
extra : rebase_source : 2fac7b5578ec42af5050fad21ca9c3d5cfdca3e1
This commit is contained in:
Henrik Skupin 2016-03-15 14:38:32 +01:00
Родитель a2d3f7bd81
Коммит 4438ee04e1
1 изменённых файлов: 6 добавлений и 2 удалений

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

@ -672,7 +672,7 @@ function implicitlyWaitFor(func, timeout, interval = 100) {
let startTime = new Date().getTime();
let endTime = startTime + timeout;
let observer = function() {
let onTimer = function() {
let res;
try {
res = func();
@ -692,7 +692,11 @@ function implicitlyWaitFor(func, timeout, interval = 100) {
}
};
timer.init(observer, interval, Ci.nsITimer.TYPE_REPEATING_SLACK);
// Run a check immediately so we do not cause a delay in execution
// due to the set timer interval.
onTimer();
timer.init(onTimer, interval, Ci.nsITimer.TYPE_REPEATING_SLACK);
// cancel timer and return result for yielding
}).then(res => {