1 /* Any copyright is dedicated to the Public Domain.
2 * http://creativecommons.org/publicdomain/zero/1.0/ */
5 * Appends a div to the document body.
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
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(); });
21 * Promise wrapper for requestAnimationFrame.
23 function waitForFrame() {
24 return new Promise(function(resolve, reject) {
25 window.requestAnimationFrame(resolve);
30 * Wrapper that takes a sequence of N players and returns:
32 * Promise.all([players[0].ready, players[1].ready, ... players[N-1].ready]);
34 function waitForAllPlayers(players) {
35 return Promise.all(players.map(function(player) { return player.ready; }));