Bug 1137966 - Wait for the last auto-refresh to finish before ending the test. r=pbro

This commit is contained in:
Sami Jaktholm 2015-08-28 13:23:05 +03:00
Родитель 5b662cbb9a
Коммит 568b089f22
2 изменённых файлов: 18 добавлений и 2 удалений

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

@ -483,7 +483,17 @@ let AnimationPlayerFront = FrontClass(AnimationPlayerActor, {
return;
}
this.autoRefreshTimer = setInterval(this.refreshState.bind(this), interval);
this.autoRefreshTimer = setInterval(() => {
// Save the refresh promise for tests. The tests need to detect when the
// last request completes or they might finish too early.
// Storing the latest Promise is enough to know that there is no pending
// requests left as p.js guarantees the last request will get the reply
// last.
this.pendingRefreshStatePromise = this.refreshState();
this.pendingRefreshStatePromise.then(() => {
this.pendingRefreshStatePromise = null;
});
}, interval);
},
/**

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

@ -45,7 +45,13 @@ add_task(function*() {
info("Stop the auto-refresh");
player.stopAutoRefresh();
resolve();
if (player.pendingRefreshStatePromise) {
// A new request was fired before we had chance to stop it. Wait for
// it to complete.
player.pendingRefreshStatePromise.then(resolve);
} else {
resolve();
}
}
};
player.on(player.AUTO_REFRESH_EVENT, onNewState);