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:
parent
26dc8955d3
commit
c9a26e60f5
|
|
@ -1116,7 +1116,7 @@ export class WKPage implements PageDelegate {
|
||||||
const response = request.createResponse(event.response);
|
const response = request.createResponse(event.response);
|
||||||
this._page._frameManager.requestReceivedResponse(response);
|
this._page._frameManager.requestReceivedResponse(response);
|
||||||
|
|
||||||
if (response.status() === 204) {
|
if (response.status() === 204 && request.request.isNavigationRequest()) {
|
||||||
this._onLoadingFailed(session, {
|
this._onLoadingFailed(session, {
|
||||||
requestId: event.requestId,
|
requestId: event.requestId,
|
||||||
errorText: 'Aborted: 204 No Content',
|
errorText: 'Aborted: 204 No Content',
|
||||||
|
|
|
||||||
|
|
@ -241,3 +241,20 @@ it('main resource xhr should have type xhr', async ({ page, server }) => {
|
||||||
expect(request.isNavigationRequest()).toBe(false);
|
expect(request.isNavigationRequest()).toBe(false);
|
||||||
expect(request.resourceType()).toBe('xhr');
|
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');
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue