From 7765131a1478038c1daf8b894582424189b385cc Mon Sep 17 00:00:00 2001 From: Pavel Feldman Date: Mon, 6 Dec 2021 09:25:24 -0800 Subject: [PATCH] feat(acceptDownload): revert acceptDownload (#10709) --- docs/src/api/class-download.md | 6 -- docs/src/api/class-page.md | 6 -- docs/src/api/params.md | 2 +- docs/src/downloads.md | 6 +- docs/src/test-configuration-js.md | 2 +- packages/playwright-core/src/cli/innerCli.ts | 3 - .../src/server/browserContext.ts | 2 + .../supplements/recorder/codeGenerator.ts | 4 -- packages/playwright-core/types/types.d.ts | 25 ++------ packages/playwright-test/types/test.d.ts | 2 +- tests/browsertype-connect.spec.ts | 4 +- tests/defaultbrowsercontext-1.spec.ts | 2 +- tests/download.spec.ts | 62 +++++++++---------- tests/downloads-path.spec.ts | 10 +-- tests/inspector/cli-codegen-2.spec.ts | 16 ++--- 15 files changed, 57 insertions(+), 95 deletions(-) diff --git a/docs/src/api/class-download.md b/docs/src/api/class-download.md index 5b5d0903f6..a6407bcc1a 100644 --- a/docs/src/api/class-download.md +++ b/docs/src/api/class-download.md @@ -56,12 +56,6 @@ var download = await page.RunAndWaitForDownloadAsync(async () => Console.WriteLine(await download.PathAsync()); ``` -:::note -Browser context **must** be created with the [`option: acceptDownloads`] set to `true` when user needs access to the -downloaded content. If [`option: acceptDownloads`] is not set, download events are emitted, but the actual download is -not performed and user has no access to the downloaded files. -::: - ## async method: Download.cancel Cancels a download. Will not fail if the download is already finished or canceled. diff --git a/docs/src/api/class-page.md b/docs/src/api/class-page.md index a8083ed60e..40b87c1d40 100644 --- a/docs/src/api/class-page.md +++ b/docs/src/api/class-page.md @@ -297,12 +297,6 @@ event is dispatched. Emitted when attachment download started. User can access basic file operations on downloaded content via the passed [Download] instance. -:::note -Browser context **must** be created with the [`option: acceptDownloads`] set to `true` when user needs access to the -downloaded content. If [`option: acceptDownloads`] is not set, download events are emitted, but the actual download is -not performed and user has no access to the downloaded files. -::: - ## event: Page.fileChooser - argument: <[FileChooser]> diff --git a/docs/src/api/params.md b/docs/src/api/params.md index f97cb57d1e..d311a3dda8 100644 --- a/docs/src/api/params.md +++ b/docs/src/api/params.md @@ -250,7 +250,7 @@ state is still returned, but won't be saved to the disk. ## context-option-acceptdownloads - `acceptDownloads` <[boolean]> -Whether to automatically download all the attachments. Defaults to `false` where all the downloads are canceled. +Whether to automatically download all the attachments. Defaults to `true` where all the downloads are accepted. ## context-option-ignorehttpserrors - `ignoreHTTPSErrors` <[boolean]> diff --git a/docs/src/downloads.md b/docs/src/downloads.md index 952305cb25..c1d8b19de5 100644 --- a/docs/src/downloads.md +++ b/docs/src/downloads.md @@ -7,9 +7,9 @@ title: "Downloads" For uploading files, see the [uploading files](./input.md#upload-files) section. ::: -For every attachment downloaded by the page, [`event: Page.download`] event is emitted. If you create a browser context -with the [`option: acceptDownloads`] set, all these attachments are going to be downloaded into a temporary folder. You -can obtain the download url, file system path and payload stream using the [Download] object from the event. +For every attachment downloaded by the page, [`event: Page.download`] event is emitted. All these attachments are going +to be downloaded into a temporary folder. You can obtain the download url, file system path and payload stream using +the [Download] object from the event. You can specify where to persist downloaded files using the [`option: downloadsPath`] option in [`method: BrowserType.launch`]. diff --git a/docs/src/test-configuration-js.md b/docs/src/test-configuration-js.md index 36b66b3b96..ad7cc38225 100644 --- a/docs/src/test-configuration-js.md +++ b/docs/src/test-configuration-js.md @@ -342,7 +342,7 @@ export default config; Available options to configure networking: -- `acceptDownloads` - Whether to automatically download all the attachments. [Learn more](./downloads.md) about working with downloads. +- `acceptDownloads` - Whether to automatically download all the attachments, defaults to `true`. [Learn more](./downloads.md) about working with downloads. - `extraHTTPHeaders` - An object containing additional HTTP headers to be sent with every request. All header values must be strings. - `httpCredentials` - Credentials for [HTTP authentication](./network.md#http-authentication). - `ignoreHTTPSErrors` - Whether to ignore HTTPS errors during navigation. diff --git a/packages/playwright-core/src/cli/innerCli.ts b/packages/playwright-core/src/cli/innerCli.ts index 3c25ebdb60..1912bf3aed 100644 --- a/packages/playwright-core/src/cli/innerCli.ts +++ b/packages/playwright-core/src/cli/innerCli.ts @@ -332,8 +332,6 @@ async function launchContext(options: Options, headless: boolean, executablePath if (contextOptions.isMobile && browserType.name() === 'firefox') contextOptions.isMobile = undefined; - contextOptions.acceptDownloads = true; - // Proxy if (options.proxyServer) { @@ -441,7 +439,6 @@ async function launchContext(options: Options, headless: boolean, executablePath delete launchOptions.headless; delete launchOptions.executablePath; delete contextOptions.deviceScaleFactor; - delete contextOptions.acceptDownloads; return { browser, browserName: browserType.name(), context, contextOptions, launchOptions }; } diff --git a/packages/playwright-core/src/server/browserContext.ts b/packages/playwright-core/src/server/browserContext.ts index 25828282dc..deab7c6f1e 100644 --- a/packages/playwright-core/src/server/browserContext.ts +++ b/packages/playwright-core/src/server/browserContext.ts @@ -402,6 +402,8 @@ export function validateBrowserContextOptions(options: types.BrowserContextOptio throw new Error(`"deviceScaleFactor" option is not supported with null "viewport"`); if (options.noDefaultViewport && options.isMobile !== undefined) throw new Error(`"isMobile" option is not supported with null "viewport"`); + if (options.acceptDownloads === undefined) + options.acceptDownloads = true; if (!options.viewport && !options.noDefaultViewport) options.viewport = { width: 1280, height: 720 }; if (options.recordVideo) { diff --git a/packages/playwright-core/src/server/supplements/recorder/codeGenerator.ts b/packages/playwright-core/src/server/supplements/recorder/codeGenerator.ts index afadc85dbf..99444c5b98 100644 --- a/packages/playwright-core/src/server/supplements/recorder/codeGenerator.ts +++ b/packages/playwright-core/src/server/supplements/recorder/codeGenerator.ts @@ -129,10 +129,6 @@ export class CodeGenerator extends EventEmitter { if (!this._enabled) return; - // We'll need to pass acceptDownloads for any generated downloads code to work. - if (signal.name === 'download') - this._options.contextOptions.acceptDownloads = true; - // Signal either arrives while action is being performed or shortly after. if (this._currentAction) { this._currentAction.action.signals.push(signal); diff --git a/packages/playwright-core/types/types.d.ts b/packages/playwright-core/types/types.d.ts index af43637aba..d3b1db2280 100644 --- a/packages/playwright-core/types/types.d.ts +++ b/packages/playwright-core/types/types.d.ts @@ -902,10 +902,6 @@ export interface Page { /** * Emitted when attachment download started. User can access basic file operations on downloaded content via the passed * [Download] instance. - * - * > NOTE: Browser context **must** be created with the `acceptDownloads` set to `true` when user needs access to the - * downloaded content. If `acceptDownloads` is not set, download events are emitted, but the actual download is not - * performed and user has no access to the downloaded files. */ on(event: 'download', listener: (download: Download) => void): this; @@ -1175,10 +1171,6 @@ export interface Page { /** * Emitted when attachment download started. User can access basic file operations on downloaded content via the passed * [Download] instance. - * - * > NOTE: Browser context **must** be created with the `acceptDownloads` set to `true` when user needs access to the - * downloaded content. If `acceptDownloads` is not set, download events are emitted, but the actual download is not - * performed and user has no access to the downloaded files. */ addListener(event: 'download', listener: (download: Download) => void): this; @@ -3525,10 +3517,6 @@ export interface Page { /** * Emitted when attachment download started. User can access basic file operations on downloaded content via the passed * [Download] instance. - * - * > NOTE: Browser context **must** be created with the `acceptDownloads` set to `true` when user needs access to the - * downloaded content. If `acceptDownloads` is not set, download events are emitted, but the actual download is not - * performed and user has no access to the downloaded files. */ waitForEvent(event: 'download', optionsOrPredicate?: { predicate?: (download: Download) => boolean | Promise, timeout?: number } | ((download: Download) => boolean | Promise)): Promise; @@ -9948,7 +9936,7 @@ export interface BrowserType { */ launchPersistentContext(userDataDir: string, options?: { /** - * Whether to automatically download all the attachments. Defaults to `false` where all the downloads are canceled. + * Whether to automatically download all the attachments. Defaults to `true` where all the downloads are accepted. */ acceptDownloads?: boolean; @@ -11176,7 +11164,7 @@ export interface AndroidDevice { */ launchBrowser(options?: { /** - * Whether to automatically download all the attachments. Defaults to `false` where all the downloads are canceled. + * Whether to automatically download all the attachments. Defaults to `true` where all the downloads are accepted. */ acceptDownloads?: boolean; @@ -12643,7 +12631,7 @@ export interface Browser extends EventEmitter { */ newPage(options?: { /** - * Whether to automatically download all the attachments. Defaults to `false` where all the downloads are canceled. + * Whether to automatically download all the attachments. Defaults to `true` where all the downloads are accepted. */ acceptDownloads?: boolean; @@ -13319,9 +13307,6 @@ export interface Dialog { * const path = await download.path(); * ``` * - * > NOTE: Browser context **must** be created with the `acceptDownloads` set to `true` when user needs access to the - * downloaded content. If `acceptDownloads` is not set, download events are emitted, but the actual download is not - * performed and user has no access to the downloaded files. */ export interface Download { /** @@ -13435,7 +13420,7 @@ export interface Electron { */ launch(options?: { /** - * Whether to automatically download all the attachments. Defaults to `false` where all the downloads are canceled. + * Whether to automatically download all the attachments. Defaults to `true` where all the downloads are accepted. */ acceptDownloads?: boolean; @@ -15037,7 +15022,7 @@ export interface WebSocket { export interface BrowserContextOptions { /** - * Whether to automatically download all the attachments. Defaults to `false` where all the downloads are canceled. + * Whether to automatically download all the attachments. Defaults to `true` where all the downloads are accepted. */ acceptDownloads?: boolean; diff --git a/packages/playwright-test/types/test.d.ts b/packages/playwright-test/types/test.d.ts index e57de54a23..b81bad1b4e 100644 --- a/packages/playwright-test/types/test.d.ts +++ b/packages/playwright-test/types/test.d.ts @@ -2776,7 +2776,7 @@ export type VideoMode = 'off' | 'on' | 'retain-on-failure' | 'on-first-retry'; */ export interface PlaywrightTestOptions { /** - * Whether to automatically download all the attachments. Defaults to `false` where all the downloads are canceled. + * Whether to automatically download all the attachments. Defaults to `true` where all the downloads are accepted. */ acceptDownloads: boolean | undefined; /** diff --git a/tests/browsertype-connect.spec.ts b/tests/browsertype-connect.spec.ts index 40db0bad03..aad6b14f6a 100644 --- a/tests/browsertype-connect.spec.ts +++ b/tests/browsertype-connect.spec.ts @@ -417,7 +417,7 @@ test('should save download', async ({ server, browserType, startRemoteServer }, const remoteServer = await startRemoteServer(); const browser = await browserType.connect({ wsEndpoint: remoteServer.wsEndpoint() }); - const page = await browser.newPage({ acceptDownloads: true }); + const page = await browser.newPage(); await page.setContent(`download`); const [ download ] = await Promise.all([ page.waitForEvent('download'), @@ -441,7 +441,7 @@ test('should error when saving download after deletion', async ({ server, browse const remoteServer = await startRemoteServer(); const browser = await browserType.connect({ wsEndpoint: remoteServer.wsEndpoint() }); - const page = await browser.newPage({ acceptDownloads: true }); + const page = await browser.newPage(); await page.setContent(`download`); const [ download ] = await Promise.all([ page.waitForEvent('download'), diff --git a/tests/defaultbrowsercontext-1.spec.ts b/tests/defaultbrowsercontext-1.spec.ts index d632a0a227..035490f6db 100644 --- a/tests/defaultbrowsercontext-1.spec.ts +++ b/tests/defaultbrowsercontext-1.spec.ts @@ -174,7 +174,7 @@ it('should support offline option', async ({ server, launchPersistent }) => { it('should support acceptDownloads option', async ({ server, launchPersistent, mode }) => { it.skip(mode === 'service', 'download.path() is not avaialble in remote mode'); - const { page } = await launchPersistent({ acceptDownloads: true }); + const { page } = await launchPersistent(); server.setRoute('/download', (req, res) => { res.setHeader('Content-Type', 'application/octet-stream'); res.setHeader('Content-Disposition', 'attachment'); diff --git a/tests/download.spec.ts b/tests/download.spec.ts index bab7d8612f..2e0d53e01f 100644 --- a/tests/download.spec.ts +++ b/tests/download.spec.ts @@ -51,7 +51,7 @@ it.describe('download event', () => { }); it('should report download when navigation turns into download', async ({ browser, server, browserName }) => { - const page = await browser.newPage({ acceptDownloads: true }); + const page = await browser.newPage(); const [ download, responseOrError ] = await Promise.all([ page.waitForEvent('download'), page.goto(server.PREFIX + '/download').catch(e => e) @@ -77,7 +77,7 @@ it.describe('download event', () => { }); it('should work with Cross-Origin-Opener-Policy', async ({ browser, server, browserName }) => { - const page = await browser.newPage({ acceptDownloads: true }); + const page = await browser.newPage(); const [ download, responseOrError ] = await Promise.all([ page.waitForEvent('download'), page.goto(server.PREFIX + '/downloadWithCOOP').catch(e => e) @@ -103,7 +103,7 @@ it.describe('download event', () => { }); it('should report downloads with acceptDownloads: false', async ({ browser, server }) => { - const page = await browser.newPage(); + const page = await browser.newPage({ acceptDownloads: false }); await page.setContent(`download`); const [ download ] = await Promise.all([ page.waitForEvent('download'), @@ -120,7 +120,7 @@ it.describe('download event', () => { }); it('should report downloads with acceptDownloads: true', async ({ browser, server }) => { - const page = await browser.newPage({ acceptDownloads: true }); + const page = await browser.newPage(); await page.setContent(`download`); const [ download ] = await Promise.all([ page.waitForEvent('download'), @@ -133,7 +133,7 @@ it.describe('download event', () => { }); it('should report proper download url when download is from download attribute', async ({ browser, server, browserName }) => { - const page = await browser.newPage({ acceptDownloads: true }); + const page = await browser.newPage(); await page.goto(server.PREFIX + '/empty.html'); await page.setContent(`download`); const [ download ] = await Promise.all([ @@ -145,7 +145,7 @@ it.describe('download event', () => { }); it('should report downloads for download attribute', async ({ browser, server }) => { - const page = await browser.newPage({ acceptDownloads: true }); + const page = await browser.newPage(); await page.goto(server.PREFIX + '/empty.html'); await page.setContent(`download`); const [ download ] = await Promise.all([ @@ -159,7 +159,7 @@ it.describe('download event', () => { }); it('should save to user-specified path without updating original path', async ({ browser, server }, testInfo) => { - const page = await browser.newPage({ acceptDownloads: true }); + const page = await browser.newPage(); await page.setContent(`download`); const [ download ] = await Promise.all([ page.waitForEvent('download'), @@ -177,7 +177,7 @@ it.describe('download event', () => { }); it('should save to two different paths with multiple saveAs calls', async ({ browser, server }, testInfo) => { - const page = await browser.newPage({ acceptDownloads: true }); + const page = await browser.newPage(); await page.setContent(`download`); const [ download ] = await Promise.all([ page.waitForEvent('download'), @@ -196,7 +196,7 @@ it.describe('download event', () => { }); it('should save to overwritten filepath', async ({ browser, server }, testInfo) => { - const page = await browser.newPage({ acceptDownloads: true }); + const page = await browser.newPage(); await page.setContent(`download`); const [ download ] = await Promise.all([ page.waitForEvent('download'), @@ -214,7 +214,7 @@ it.describe('download event', () => { }); it('should create subdirectories when saving to non-existent user-specified path', async ({ browser, server }, testInfo) => { - const page = await browser.newPage({ acceptDownloads: true }); + const page = await browser.newPage(); await page.setContent(`download`); const [ download ] = await Promise.all([ page.waitForEvent('download'), @@ -241,7 +241,7 @@ it.describe('download event', () => { }); it('should error when saving after deletion', async ({ browser, server }, testInfo) => { - const page = await browser.newPage({ acceptDownloads: true }); + const page = await browser.newPage(); await page.setContent(`download`); const [ download ] = await Promise.all([ page.waitForEvent('download'), @@ -261,7 +261,7 @@ it.describe('download event', () => { res.end(`Hello world`); }); - const page = await browser.newPage({ acceptDownloads: true }); + const page = await browser.newPage(); await page.goto(server.EMPTY_PAGE); await page.setContent(`download`); const [ download ] = await Promise.all([ @@ -276,7 +276,7 @@ it.describe('download event', () => { }); it(`should report download path within page.on('download', …) handler for Files`, async ({ browser, server }) => { - const page = await browser.newPage({ acceptDownloads: true }); + const page = await browser.newPage(); const onDownloadPath = new Promise(res => { page.on('download', dl => { dl.path().then(res); @@ -290,7 +290,7 @@ it.describe('download event', () => { }); it(`should report download path within page.on('download', …) handler for Blobs`, async ({ browser, server }) => { - const page = await browser.newPage({ acceptDownloads: true }); + const page = await browser.newPage(); const onDownloadPath = new Promise(res => { page.on('download', dl => { dl.path().then(res); @@ -313,7 +313,7 @@ it.describe('download event', () => { res.end(`Hello world`); }); - const page = await browser.newPage({ acceptDownloads: true }); + const page = await browser.newPage(); await page.goto(server.EMPTY_PAGE); await page.setContent(`download`); const [ download ] = await Promise.all([ @@ -327,7 +327,7 @@ it.describe('download event', () => { }); it('should report new window downloads', async ({ browser, server }) => { - const page = await browser.newPage({ acceptDownloads: true }); + const page = await browser.newPage(); await page.setContent(`download`); const [ download ] = await Promise.all([ page.waitForEvent('download'), @@ -339,7 +339,7 @@ it.describe('download event', () => { }); it('should delete file', async ({ browser, server }) => { - const page = await browser.newPage({ acceptDownloads: true }); + const page = await browser.newPage(); await page.setContent(`download`); const [ download ] = await Promise.all([ page.waitForEvent('download'), @@ -353,7 +353,7 @@ it.describe('download event', () => { }); it('should expose stream', async ({ browser, server }) => { - const page = await browser.newPage({ acceptDownloads: true }); + const page = await browser.newPage(); await page.setContent(`download`); const [ download ] = await Promise.all([ page.waitForEvent('download'), @@ -368,7 +368,7 @@ it.describe('download event', () => { }); it('should delete downloads on context destruction', async ({ browser, server }) => { - const page = await browser.newPage({ acceptDownloads: true }); + const page = await browser.newPage(); await page.setContent(`download`); const [ download1 ] = await Promise.all([ page.waitForEvent('download'), @@ -389,7 +389,7 @@ it.describe('download event', () => { it('should delete downloads on browser gone', async ({ server, browserType }) => { const browser = await browserType.launch(); - const page = await browser.newPage({ acceptDownloads: true }); + const page = await browser.newPage(); await page.setContent(`download`); const [ download1 ] = await Promise.all([ page.waitForEvent('download'), @@ -412,7 +412,7 @@ it.describe('download event', () => { it('should close the context without awaiting the failed download', async ({ browser, server, httpsServer, browserName, headless }, testInfo) => { it.skip(browserName !== 'chromium', 'Only Chromium downloads on alt-click'); - const page = await browser.newPage({ acceptDownloads: true }); + const page = await browser.newPage(); await page.goto(server.EMPTY_PAGE); await page.setContent(`click me`); const [download] = await Promise.all([ @@ -444,7 +444,7 @@ it.describe('download event', () => { res.write(`Hello world`); }); - const page = await browser.newPage({ acceptDownloads: true }); + const page = await browser.newPage(); await page.goto(server.EMPTY_PAGE); await page.setContent(`click me`); const [download] = await Promise.all([ @@ -476,7 +476,7 @@ it.describe('download event', () => { }); const browser = await browserType.launch(); - const page = await browser.newPage({ acceptDownloads: true }); + const page = await browser.newPage(); await page.setContent(`click me`); const [download] = await Promise.all([ page.waitForEvent('download'), @@ -498,7 +498,7 @@ it.describe('download event', () => { fs.writeFileSync(zipFile, content); server.setRoute('/binary.zip', (req, res) => server.serveFile(req, res, zipFile)); - const page = await browser.newPage({ acceptDownloads: true }); + const page = await browser.newPage(); await page.goto(server.PREFIX + '/empty.html'); await page.setContent(`download`); const [ download ] = await Promise.all([ @@ -525,7 +525,7 @@ it.describe('download event', () => { it('should be able to cancel pending downloads', async ({ browser, server, browserName, browserVersion }) => { // The exact upstream change is in b449b5c, which still does not appear in the first few 91.* tags until 91.0.4437.0. it.fixme(browserName === 'chromium' && Number(browserVersion.split('.')[0]) < 91, 'The upstream Browser.cancelDownload command is not available before Chrome 91'); - const page = await browser.newPage({ acceptDownloads: true }); + const page = await browser.newPage(); await page.setContent(`download`); const [ download ] = await Promise.all([ page.waitForEvent('download'), @@ -540,7 +540,7 @@ it.describe('download event', () => { it('should not fail explicitly to cancel a download even if that is already finished', async ({ browser, server, browserName, browserVersion }) => { // The exact upstream change is in b449b5c, which still does not appear in the first few 91.* tags until 91.0.4437.0. it.fixme(browserName === 'chromium' && Number(browserVersion.split('.')[0]) < 91, 'The upstream Browser.cancelDownload command is not available before Chrome 91'); - const page = await browser.newPage({ acceptDownloads: true }); + const page = await browser.newPage(); await page.setContent(`download`); const [ download ] = await Promise.all([ page.waitForEvent('download'), @@ -556,7 +556,7 @@ it.describe('download event', () => { }); it('should report downloads with interception', async ({ browser, server }) => { - const page = await browser.newPage({ acceptDownloads: true }); + const page = await browser.newPage(); await page.route(/.*/, r => r.continue()); await page.setContent(`download`); const [ download ] = await Promise.all([ @@ -570,7 +570,7 @@ it.describe('download event', () => { }); it('should emit download event from nested iframes', async ({ server, browser, browserName }, testInfo) => { - const page = await browser.newPage({ acceptDownloads: true }); + const page = await browser.newPage(); server.setRoute('/1', (req, res) => { res.setHeader('Content-Type', 'text/html'); res.end(``); @@ -600,7 +600,7 @@ it.describe('download event', () => { }); it('should be able to download a PDF file', async ({ browser, server, asset }) => { - const page = await browser.newPage({ acceptDownloads: true }); + const page = await browser.newPage(); await page.goto(server.EMPTY_PAGE); await page.setContent(` download @@ -615,7 +615,7 @@ it('should be able to download a PDF file', async ({ browser, server, asset }) = it('should be able to download a inline PDF file', async ({ browser, server, asset, browserName }) => { it.fixme(browserName === 'webkit'); - const page = await browser.newPage({ acceptDownloads: true }); + const page = await browser.newPage(); await page.goto(server.EMPTY_PAGE); await page.route('**/empty.pdf', async route => { const response = await page.context().request.fetch(route.request()); @@ -645,7 +645,7 @@ it('should save to user-specified path', async ({ browser, server, mode }, testI res.end(`Hello world`); }); - const page = await browser.newPage({ acceptDownloads: true }); + const page = await browser.newPage(); await page.setContent(`download`); const [ download ] = await Promise.all([ page.waitForEvent('download'), diff --git a/tests/downloads-path.spec.ts b/tests/downloads-path.spec.ts index 240d72c843..5983113831 100644 --- a/tests/downloads-path.spec.ts +++ b/tests/downloads-path.spec.ts @@ -47,7 +47,7 @@ it.describe('downloads path', () => { it('should delete downloads when context closes', async ({ browserType, server }, testInfo) => { const downloadsBrowser = await browserType.launch({ downloadsPath: testInfo.outputPath('') }); - const page = await downloadsBrowser.newPage({ acceptDownloads: true }); + const page = await downloadsBrowser.newPage(); await page.setContent(`download`); const [ download ] = await Promise.all([ page.waitForEvent('download'), @@ -62,7 +62,7 @@ it.describe('downloads path', () => { it('should report downloads in downloadsPath folder', async ({ browserType, server }, testInfo) => { const downloadsBrowser = await browserType.launch({ downloadsPath: testInfo.outputPath('') }); - const page = await downloadsBrowser.newPage({ acceptDownloads: true }); + const page = await downloadsBrowser.newPage(); await page.setContent(`download`); const [ download ] = await Promise.all([ page.waitForEvent('download'), @@ -76,7 +76,7 @@ it.describe('downloads path', () => { it('should report downloads in downloadsPath folder with a relative path', async ({ browserType, server }, testInfo) => { const downloadsBrowser = await browserType.launch({ downloadsPath: path.relative(process.cwd(), testInfo.outputPath('')) }); - const page = await downloadsBrowser.newPage({ acceptDownloads: true }); + const page = await downloadsBrowser.newPage(); await page.setContent(`download`); const [ download ] = await Promise.all([ page.waitForEvent('download'), @@ -89,7 +89,7 @@ it.describe('downloads path', () => { }); it('should accept downloads in persistent context', async ({ launchPersistent, server }, testInfo) => { - const { context, page } = await launchPersistent({ acceptDownloads: true, downloadsPath: testInfo.outputPath('') }); + const { context, page } = await launchPersistent({ downloadsPath: testInfo.outputPath('') }); await page.setContent(`download`); const [ download ] = await Promise.all([ page.waitForEvent('download'), @@ -103,7 +103,7 @@ it.describe('downloads path', () => { }); it('should delete downloads when persistent context closes', async ({ launchPersistent, server }, testInfo) => { - const { context, page } = await launchPersistent({ acceptDownloads: true, downloadsPath: testInfo.outputPath('') }); + const { context, page } = await launchPersistent({ downloadsPath: testInfo.outputPath('') }); await page.setContent(`download`); const [ download ] = await Promise.all([ page.waitForEvent('download'), diff --git a/tests/inspector/cli-codegen-2.spec.ts b/tests/inspector/cli-codegen-2.spec.ts index 2b44c67065..c59b2a126f 100644 --- a/tests/inspector/cli-codegen-2.spec.ts +++ b/tests/inspector/cli-codegen-2.spec.ts @@ -252,9 +252,7 @@ test.describe('cli codegen', () => { const sources = await recorder.waitForOutput('JavaScript', 'waitForEvent'); expect(sources.get('JavaScript').text).toContain(` - const context = await browser.newContext({ - acceptDownloads: true - });`); + const context = await browser.newContext();`); expect(sources.get('JavaScript').text).toContain(` // Click text=Download const [download] = await Promise.all([ @@ -263,8 +261,7 @@ test.describe('cli codegen', () => { ]);`); expect(sources.get('Java').text).toContain(` - BrowserContext context = browser.newContext(new Browser.NewContextOptions() - .setAcceptDownloads(true));`); + BrowserContext context = browser.newContext();`); expect(sources.get('Java').text).toContain(` // Click text=Download Download download = page.waitForDownload(() -> { @@ -272,7 +269,7 @@ test.describe('cli codegen', () => { });`); expect(sources.get('Python').text).toContain(` - context = browser.new_context(accept_downloads=True)`); + context = browser.new_context()`); expect(sources.get('Python').text).toContain(` # Click text=Download with page.expect_download() as download_info: @@ -280,7 +277,7 @@ test.describe('cli codegen', () => { download = download_info.value`); expect(sources.get('Python Async').text).toContain(` - context = await browser.new_context(accept_downloads=True)`); + context = await browser.new_context()`); expect(sources.get('Python Async').text).toContain(` # Click text=Download async with page.expect_download() as download_info: @@ -288,10 +285,7 @@ test.describe('cli codegen', () => { download = await download_info.value`); expect(sources.get('C#').text).toContain(` - var context = await browser.NewContextAsync(new BrowserNewContextOptions - { - AcceptDownloads = true, - });`); + var context = await browser.NewContextAsync();`); expect(sources.get('C#').text).toContain(` // Click text=Download var download1 = await page.RunAndWaitForDownloadAsync(async () =>