fix(chromium): do not cancel downloads when intercepting (#27638)
Fixes #27575.
This commit is contained in:
parent
fd2fbe9d2f
commit
e8b4c03e54
|
|
@ -189,12 +189,8 @@ export class CRNetworkManager {
|
|||
_onRequestPaused(sessionInfo: SessionInfo, event: Protocol.Fetch.requestPausedPayload) {
|
||||
if (!event.networkId) {
|
||||
// Fetch without networkId means that request was not recognized by inspector, and
|
||||
// it will never receive Network.requestWillBeSent. Most likely, this is an internal request
|
||||
// that we can safely fail.
|
||||
this._session._sendMayFail('Fetch.failRequest', {
|
||||
requestId: event.requestId,
|
||||
errorReason: 'Aborted',
|
||||
});
|
||||
// it will never receive Network.requestWillBeSent. Continue the request to not affect it.
|
||||
this._session._sendMayFail('Fetch.continueRequest', { requestId: event.requestId });
|
||||
return;
|
||||
}
|
||||
if (event.request.url.startsWith('data:'))
|
||||
|
|
|
|||
|
|
@ -714,6 +714,21 @@ it('should download links with data url', async ({ page }) => {
|
|||
expect(download.suggestedFilename()).toBe('SomeFile.txt');
|
||||
});
|
||||
|
||||
it('should download successfully when routing', async ({ browser, server }) => {
|
||||
const page = await browser.newPage();
|
||||
await page.context().route('**/*', route => route.continue());
|
||||
await page.goto(server.PREFIX + '/empty.html');
|
||||
await page.setContent(`<a href="${server.PREFIX}/chromium-linux.zip" download="foo.zip">download</a>`);
|
||||
const [download] = await Promise.all([
|
||||
page.waitForEvent('download'),
|
||||
page.click('a')
|
||||
]);
|
||||
expect(download.suggestedFilename()).toBe('foo.zip');
|
||||
expect(download.url()).toBe(`${server.PREFIX}/chromium-linux.zip`);
|
||||
expect(await download.failure()).toBe(null);
|
||||
await page.close();
|
||||
});
|
||||
|
||||
async function assertDownloadToPDF(download: Download, filePath: string) {
|
||||
expect(download.suggestedFilename()).toBe(path.basename(filePath));
|
||||
const stream = await download.createReadStream();
|
||||
|
|
|
|||
Loading…
Reference in a new issue