(method, timeoutMs = 10000)
| 347 | } |
| 348 | |
| 349 | waitFor(method, timeoutMs = 10000) { |
| 350 | return new Promise((resolvePromise, rejectPromise) => { |
| 351 | const timer = setTimeout(() => { |
| 352 | rejectPromise(new Error(`Timed out waiting for CDP event ${method}`)) |
| 353 | }, timeoutMs) |
| 354 | this.on(method, (params) => { |
| 355 | clearTimeout(timer) |
| 356 | resolvePromise(params) |
| 357 | }) |
| 358 | }) |
| 359 | } |
| 360 | |
| 361 | close() { |
| 362 | this.socket?.terminate?.() |