(client, expression)
| 136 | throw new Error(`no CDP page: ${lastErr?.message ?? 'timeout'}`) |
| 137 | } |
| 138 | async function evaluate(client, expression) { |
| 139 | const r = await client.send('Runtime.evaluate', { expression, awaitPromise: true, returnByValue: true }) |
| 140 | if (r.exceptionDetails) throw new Error(r.exceptionDetails.exception?.description ?? r.exceptionDetails.text) |
| 141 | return r.result?.value |
| 142 | } |
| 143 | /** Poll an evaluated expression until it returns truthy (or time out → null). */ |
| 144 | async function until(client, expression, timeoutMs = 4000, intervalMs = 80) { |
| 145 | const deadline = Date.now() + timeoutMs |
no test coverage detected