Files
stack/packages/webui/tests/tester-browser-fixture.mjs
jason.woltje 7247d80c7a row 196: human boundary on peer credentials, interpreter receipt and the Console tester socket (#1694)
Candidate 527b9a1e6 (gander/row196-r6-prd19, base f48725cfc), the 39 manifest paths of CANDIDATE.sha256 537d30aef70b6cd1 at ec1e7fad8. Duckworth approved round 1 outside B1/B2 (rev 2973, comment 30145) and round 2 merge-scoped (rev 2986, comment 30156). Gate gander-0066 on grant sage-2145: 2334 pass, 0 fail, 1 skip; mutants 38/38 killed. BUILD-LOG lines and Duckworth's C1 DEFERRED entry follow as a doc-only append.
2026-10-21 15:55:39 -05:00

27 lines
1.5 KiB
JavaScript

// UI QA only: CDP fulfills this browser's synthetic-origin requests from a scratch Unix
// listener. No TCP listener, proxy, installed endpoint or reusable relay is created.
import { request } from 'node:http';
import { browser } from './browser.mjs';
import { TESTER_ORIGIN } from '../src/tester-socket.mjs';
export async function testerBrowser(server) {
const b = await browser();
b.on('Fetch.requestPaused', ({requestId,request:incoming}) => {
const url = new URL(incoming.url);
const q = request({socketPath:server.address(),path:url.pathname+url.search,method:incoming.method,
headers:{...incoming.headers,host:new URL(TESTER_ORIGIN).host,origin:TESTER_ORIGIN,'sec-fetch-site':'same-origin'}}, res => {
const parts=[];
res.on('data',part=>parts.push(part));
res.on('end',()=>{
const responseHeaders=Object.entries(res.headers).filter(([name])=>!['connection','keep-alive','transfer-encoding'].includes(name))
.flatMap(([name,value])=>(Array.isArray(value)?value:[value]).map(value=>({name,value:String(value)})));
b.call('Fetch.fulfillRequest',{requestId,responseCode:res.statusCode,responseHeaders,body:Buffer.concat(parts).toString('base64')}).catch(()=>{});
});
});
q.on('error',()=>b.call('Fetch.failRequest',{requestId,errorReason:'Failed'}).catch(()=>{}));
q.end(incoming.postData);
});
await b.call('Fetch.enable',{patterns:[{urlPattern:TESTER_ORIGIN+'/*',requestStage:'Request'}]});
return b;
}