| 253 | const $bar = $('<progress>'); |
| 254 | let barLastUpdate = Date.now(); |
| 255 | const incrementBar = async (amount = 1) => { |
| 256 | $bar.attr('value', Number.parseInt($bar.attr('value')) + 1); |
| 257 | // Give the browser an opportunity to draw the progress bar's new length. `await |
| 258 | // Promise.resolve()` isn't enough, so a timeout is used. Sleeping every increment (even 0ms) |
| 259 | // unnecessarily slows down spec loading so the sleep is occasional. |
| 260 | if (Date.now() - barLastUpdate > 100) { |
| 261 | await new Promise((resolve) => setTimeout(resolve, 0)); |
| 262 | barLastUpdate = Date.now(); |
| 263 | } |
| 264 | }; |
| 265 | const $progressArea = $('<div>') |
| 266 | .css({'display': 'flex', 'flex-direction': 'column', 'height': '100%'}) |
| 267 | .append($('<div>').css({flex: '1 0 0'})) |