* Spawn ``javascript_browser_harness.py`` to serve the bundle on a * loopback port. Returns once the harness has written its URL to the * url-file; that's our handshake that the listener is up.
(serveDir, logFile, urlFile)
| 175 | * url-file; that's our handshake that the listener is up. |
| 176 | */ |
| 177 | async function startHarness(serveDir, logFile, urlFile) { |
| 178 | fs.writeFileSync(urlFile, ''); |
| 179 | const child = spawn('python3', [ |
| 180 | HARNESS_PY, |
| 181 | '--serve-dir', serveDir, |
| 182 | '--log-file', logFile, |
| 183 | '--url-file', urlFile |
| 184 | ], { stdio: ['ignore', 'pipe', 'pipe'] }); |
| 185 | child.stdout.on('data', () => {}); |
| 186 | child.stderr.on('data', () => {}); |
| 187 | for (let i = 0; i < 100; i++) { |
| 188 | if (fs.statSync(urlFile).size > 0) { |
| 189 | const url = fs.readFileSync(urlFile, 'utf8').trim(); |
| 190 | if (url) { |
| 191 | return { child, url }; |
| 192 | } |
| 193 | } |
| 194 | await new Promise(r => setTimeout(r, 50)); |
| 195 | } |
| 196 | child.kill('SIGTERM'); |
| 197 | throw new Error('Harness did not announce a URL within 5 seconds'); |
| 198 | } |
| 199 | |
| 200 | /** |
| 201 | * Append parparDiag=1 and cn1DisableEventForwarding=1 (mirrors the |