Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
fix(chromium): do not cancel downloads when intercepting (#27638)
Dmitry Gozmane8b4c03e54f1
diff --git a/packages/playwright-core/src/server/chromium/crNetworkManager.ts b/packages/playwright-core/src/server/chromium/crNetworkManager.tsindex c59d919f8d..dbc6b08701 100644--- a/packages/playwright-core/src/server/chromium/crNetworkManager.ts+++ b/packages/playwright-core/src/server/chromium/crNetworkManager.ts@@ -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:'))diff --git a/tests/library/download.spec.ts b/tests/library/download.spec.tsindex 0e27bfa2f3..893631c263 100644--- a/tests/library/download.spec.ts+++ b/tests/library/download.spec.ts@@ -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();