diff --git a/src/server/chromium/crNetworkManager.ts b/src/server/chromium/crNetworkManager.ts index 08657f2376..edd3b8ecbd 100644 --- a/src/server/chromium/crNetworkManager.ts +++ b/src/server/chromium/crNetworkManager.ts @@ -487,7 +487,8 @@ class RouteImpl implements network.RouteDelegate { return null; const event = await this._responseInterceptedPromise; this._interceptionId = event.requestId; - return new network.InterceptedResponse(request, event.responseStatusCode!, event.responseErrorReason!, event.responseHeaders!); + // FIXME: plumb status text from browser + return new network.InterceptedResponse(request, event.responseStatusCode!, '', event.responseHeaders!); } async fulfill(response: types.NormalizedFulfillResponse) { diff --git a/tests/page/page-request-intercept.spec.ts b/tests/page/page-request-intercept.spec.ts index 1a03cf61f5..a4fcae2eea 100644 --- a/tests/page/page-request-intercept.spec.ts +++ b/tests/page/page-request-intercept.spec.ts @@ -113,7 +113,7 @@ it('should give access to the intercepted response', async ({page, server}) => { const routePromise = new Promise(f => routeCallback = f); await page.route('**/title.html', routeCallback); - const evalPromise = page.evaluate(url => fetch(url), server.PREFIX + '/title.html').catch(console.log); + const evalPromise = page.evaluate(url => fetch(url), server.PREFIX + '/title.html'); const route = await routePromise; // @ts-expect-error @@ -127,6 +127,29 @@ it('should give access to the intercepted response', async ({page, server}) => { await Promise.all([route.fulfill(), evalPromise]); }); +it('should give access to the intercepted response status text', async ({page, server, browserName}) => { + it.fail(browserName === 'chromium', 'Status line is not reported for intercepted responses'); + await page.goto(server.EMPTY_PAGE); + server.setRoute('/title.html', (req, res) => { + res.statusCode = 200; + res.statusMessage = 'You are awesome'; + res.setHeader('Content-Type', 'text/plain'); + res.end(); + }); + let routeCallback; + const routePromise = new Promise(f => routeCallback = f); + await page.route('**/title.html', routeCallback); + const evalPromise = page.evaluate(url => fetch(url), server.PREFIX + '/title.html'); + const route = await routePromise; + // @ts-expect-error + const response = await route._intercept(); + + expect(response.statusText()).toBe('You are awesome'); + expect(response.url()).toBe(server.PREFIX + '/title.html'); + + await Promise.all([route.fulfill(), evalPromise]); +}); + it('should give access to the intercepted response body', async ({page, server}) => { await page.goto(server.EMPTY_PAGE);