(method, timeoutMs = 10000)
| 376 | } |
| 377 | |
| 378 | waitFor(method, timeoutMs = 10000) { |
| 379 | return new Promise((resolvePromise, rejectPromise) => { |
| 380 | const timer = setTimeout(() => { |
| 381 | rejectPromise(new Error(`Timed out waiting for CDP event ${method}`)) |
| 382 | }, timeoutMs) |
| 383 | this.on(method, (params) => { |
| 384 | clearTimeout(timer) |
| 385 | resolvePromise(params) |
| 386 | }) |
| 387 | }) |
| 388 | } |
| 389 | |
| 390 | close() { |
| 391 | this.socket?.terminate?.() |