(win, count, opt_timeout)
| 493 | * @return {!Promise} |
| 494 | */ |
| 495 | export function pollForLayout(win, count, opt_timeout) { |
| 496 | const getCount = () => { |
| 497 | return win.document.querySelectorAll('.i-amphtml-layout,.i-amphtml-error') |
| 498 | .length; |
| 499 | }; |
| 500 | return poll( |
| 501 | 'Waiting for elements to layout: ' + count, |
| 502 | () => { |
| 503 | return getCount() >= count; |
| 504 | }, |
| 505 | () => { |
| 506 | return new Error( |
| 507 | 'Failed to find elements with layout.' + |
| 508 | ' Current count: ' + |
| 509 | getCount() + |
| 510 | ' HTML:\n' + |
| 511 | win.document.documentElement./*TEST*/ innerHTML |
| 512 | ); |
| 513 | }, |
| 514 | opt_timeout |
| 515 | ); |
| 516 | } |
| 517 | |
| 518 | /** |
| 519 | * @param {!Window} win |
no test coverage detected