Bumping manifests a=b2g-bump
[gecko.git] / dom / animation / test / testcommon.js
blobbeb4c8a40c1e7ec51f5f966d2a2b4bf8506757f8
1 /* Any copyright is dedicated to the Public Domain.
2  * http://creativecommons.org/publicdomain/zero/1.0/ */
4 /**
5  * Appends a div to the document body.
6  *
7  * @param t  The testharness.js Test object. If provided, this will be used
8  *           to register a cleanup callback to remove the div when the test
9  *           finishes.
10  */
11 function addDiv(t) {
12   var div = document.createElement('div');
13   document.body.appendChild(div);
14   if (t && typeof t.add_cleanup === 'function') {
15     t.add_cleanup(function() { div.remove(); });
16   }
17   return div;
20 /**
21  * Promise wrapper for requestAnimationFrame.
22  */
23 function waitForFrame() {
24   return new Promise(function(resolve, reject) {
25     window.requestAnimationFrame(resolve);
26   });
29 /**
30  * Wrapper that takes a sequence of N players and returns:
31  *
32  *   Promise.all([players[0].ready, players[1].ready, ... players[N-1].ready]);
33  */
34 function waitForAllPlayers(players) {
35   return Promise.all(players.map(function(player) { return player.ready; }));