fix(webkit): 204 response is not a failure (#32768)

The login being changed was added in
https://github.com/microsoft/playwright/pull/1260 and is supposed to
only work for navigation requests.

Reference: https://github.com/microsoft/playwright/issues/32752
This commit is contained in:
Yury Semikhatsky 2024-09-23 14:30:40 -07:00 committed by GitHub
parent 26dc8955d3
commit c9a26e60f5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 1 deletions

View file

@ -1116,7 +1116,7 @@ export class WKPage implements PageDelegate {
const response = request.createResponse(event.response);
this._page._frameManager.requestReceivedResponse(response);
if (response.status() === 204) {
if (response.status() === 204 && request.request.isNavigationRequest()) {
this._onLoadingFailed(session, {
requestId: event.requestId,
errorText: 'Aborted: 204 No Content',

View file

@ -241,3 +241,20 @@ it('main resource xhr should have type xhr', async ({ page, server }) => {
expect(request.isNavigationRequest()).toBe(false);
expect(request.resourceType()).toBe('xhr');
});
it('should finish 204 request', {
annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright/issues/32752' }
}, async ({ page, server, browserName }) => {
it.fixme(browserName === 'chromium');
server.setRoute('/204', (req, res) => {
res.writeHead(204, { 'Content-type': 'text/plain' });
res.end();
});
await page.goto(server.EMPTY_PAGE);
const reqPromise = Promise.race([
page.waitForEvent('requestfailed', r => r.url().endsWith('/204')).then(() => 'requestfailed'),
page.waitForEvent('requestfinished', r => r.url().endsWith('/204')).then(() => 'requestfinished'),
]);
page.evaluate(async url => { await fetch(url); }, server.PREFIX + '/204').catch(() => {});
expect(await reqPromise).toBe('requestfinished');
});