Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -520,8 +520,9 @@ export class CRNetworkManager {
request.request.setRawRequestHeaders(null);
}
this._deleteRequest(request);
// Chromium aborts 204 responses, other browsers finish them.
if (response?.status() === 204) {
// Chromium aborts 204 subresource responses, other browsers finish them.
// A 204 navigation never commits, so it must fail to abort the pending navigation.
if (response?.status() === 204 && !request.request.isNavigationRequest()) {
(this._page?.frameManager || this._serviceWorker)!.reportRequestFinished(request.request, response);
return;
}
Expand Down
13 changes: 13 additions & 0 deletions tests/page/page-click.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,19 @@ it('should click links which cause navigation', async ({ page, server }) => {
await page.click('a');
});

it('should not wait for navigation after clicking a link answered with 204', {
annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright/issues/43279' },
}, async ({ page, server }) => {
server.setRoute('/204', (req, res) => {
res.statusCode = 204;
res.end();
});
await page.goto(server.EMPTY_PAGE);
await page.setContent(`<a href="${server.PREFIX}/204">link</a>`);
await page.click('a', { timeout: 5000 });
expect(page.url()).toBe(server.EMPTY_PAGE);
});

it('should click the button inside an iframe', async ({ page, server }) => {
await page.goto(server.EMPTY_PAGE);
await page.setContent('<div style="width:100px;height:100px">spacer</div>');
Expand Down
17 changes: 17 additions & 0 deletions tests/page/page-event-request.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,23 @@ it('should finish 204 request', {
expect(await reqPromise).toBe('requestfinished');
});

it('should fail 204 navigation request', {
annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright/issues/43279' },
}, async ({ page, server }) => {
server.setRoute('/204', (req, res) => {
res.statusCode = 204;
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'),
]);
await page.setContent(`<a href="${server.PREFIX}/204">link</a>`);
await page.click('a', { noWaitAfter: true });
expect(await reqPromise).toBe('requestfailed');
});

it('<picture> resource should have type image', async ({ page }) => {
it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/33148' });
const [request] = await Promise.all([
Expand Down
Loading