( func: () => Promise<void>, timeout: number, )
| 533 | } |
| 534 | |
| 535 | export async function waitExecutionFor( |
| 536 | func: () => Promise<void>, |
| 537 | timeout: number, |
| 538 | ): Promise<void> { |
| 539 | const start = Date.now(); |
| 540 | while (Date.now() - start < 10000) { |
| 541 | try { |
| 542 | await func(); |
| 543 | return; |
| 544 | } catch { |
| 545 | await new Promise(resolve => setTimeout(resolve, 100)); // wait and retry |
| 546 | } |
| 547 | } |
| 548 | |
| 549 | throw new Error(`Timeout of ${timeout} reached.`); |
| 550 | } |
| 551 | |
| 552 | export function createTempDir( |
| 553 | prefix = 'chrome-devtools-test-', |
no outgoing calls