( func: () => Promise<void>, timeout: number, )
| 590 | } |
| 591 | |
| 592 | export async function waitExecutionFor( |
| 593 | func: () => Promise<void>, |
| 594 | timeout: number, |
| 595 | ): Promise<void> { |
| 596 | const start = Date.now(); |
| 597 | while (Date.now() - start < 10000) { |
| 598 | try { |
| 599 | await func(); |
| 600 | return; |
| 601 | } catch { |
| 602 | await new Promise(resolve => setTimeout(resolve, 100)); // wait and retry |
| 603 | } |
| 604 | } |
| 605 | |
| 606 | throw new Error(`Timeout of ${timeout} reached.`); |
| 607 | } |
| 608 | |
| 609 | export function createTempDir( |
| 610 | prefix = 'chrome-devtools-test-', |
no outgoing calls