fix: do not send favicon request to network when interception is on (#33639)
This commit is contained in:
parent
150092438f
commit
6d71805f4a
|
|
@ -296,7 +296,8 @@ export class FrameManager {
|
|||
if (request._documentId)
|
||||
frame.setPendingDocument({ documentId: request._documentId, request });
|
||||
if (request._isFavicon) {
|
||||
route?.continue({ isFallback: true }).catch(() => {});
|
||||
// Abort favicon requests to avoid network access in case of interception.
|
||||
route?.abort('aborted').catch(() => {});
|
||||
return;
|
||||
}
|
||||
this._page.emitOnContext(BrowserContext.Events.Request, request);
|
||||
|
|
|
|||
|
|
@ -318,3 +318,25 @@ it('request.postData is not null when fetching FormData with a Blob', {
|
|||
expect(postData).toContain('Content-Disposition: form-data; name="file"; filename="blob"');
|
||||
expect(postData).toContain('\r\nhello\r\n');
|
||||
});
|
||||
|
||||
it('should abort favicon requests if interception is enabled', async ({ page, server, browserName }) => {
|
||||
let requestCount = 0;
|
||||
server.setRoute('/favicon.ico', (req, res) => {
|
||||
++requestCount;
|
||||
res.setHeader('content-type', 'text/plain');
|
||||
res.end('my content');
|
||||
});
|
||||
// Intercept all requests.
|
||||
await page.route('**/*', async route => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
body: 'Hello, world!',
|
||||
});
|
||||
});
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
const response = await page.evaluate(() => fetch('/favicon.ico').then(r => r.text()).catch(e => 'load failed'));
|
||||
expect(response).toBe('load failed');
|
||||
// Browsers can send favicon requests in the background.
|
||||
await new Promise(f => setTimeout(f, 1000));
|
||||
expect(requestCount).toBe(0);
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue