(chromeProcess)
| 861 | } |
| 862 | |
| 863 | async function stopChrome(chromeProcess) { |
| 864 | if (chromeProcess.exitCode !== null || chromeProcess.signalCode !== null) { |
| 865 | return; |
| 866 | } |
| 867 | chromeProcess.kill("SIGTERM"); |
| 868 | const exited = await Promise.race([ |
| 869 | new Promise((resolve) => chromeProcess.once("exit", () => resolve(true))), |
| 870 | sleep(1500).then(() => false), |
| 871 | ]); |
| 872 | if ( |
| 873 | exited || |
| 874 | chromeProcess.exitCode !== null || |
| 875 | chromeProcess.signalCode !== null |
| 876 | ) { |
| 877 | return; |
| 878 | } |
| 879 | chromeProcess.kill("SIGKILL"); |
| 880 | await Promise.race([ |
| 881 | new Promise((resolve) => chromeProcess.once("exit", resolve)), |
| 882 | sleep(1500), |
| 883 | ]); |
| 884 | } |
| 885 | |
| 886 | async function waitForValue(cdp, expression, predicate, timeoutMs) { |
| 887 | const startedAt = Date.now(); |
no test coverage detected