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(downloads): fix `acceptDownloads` complaint (#1777) (#1923)
Ross Wollman53c78a8a2905
diff --git a/src/download.ts b/src/download.tsindex 4f03fb60a7..b666812527 100644--- a/src/download.ts+++ b/src/download.ts@@ -39,9 +39,9 @@ export class Download {this._url = url;this._finishedCallback = () => {};this._finishedPromise = new Promise(f => this._finishedCallback = f);- this._page.emit(Events.Page.Download, this);page._browserContext._downloads.add(this);this._acceptDownloads = !!this._page._browserContext._options.acceptDownloads;+ this._page.emit(Events.Page.Download, this);}url(): string {diff --git a/test/download.spec.js b/test/download.spec.jsindex bc79ae47e0..995b3c5961 100644--- a/test/download.spec.js+++ b/test/download.spec.js@@ -70,6 +70,19 @@ describe('Download', function() {expect(fs.readFileSync(path).toString()).toBe('Hello world');await page.close();});+ it(`should report download path within page.on('download', …) handler`, async({browser, server}) => {+ const page = await browser.newPage({ acceptDownloads: true });+ const onDownloadPathPath = new Promise((res) => {+ page.on('download', dl => {+ dl.path().then(res);+ });+ });+ await page.setContent(`<a href="${server.PREFIX}/download">download</a>`);+ await page.click('a');+ const path = await onDownloadPathPath;+ expect(fs.readFileSync(path).toString()).toBe('Hello world');+ await page.close();+ })it.skip(FFOX).fail(CHROMIUM || WEBKIT)('should report alt-click downloads', async({browser, server}) => {// Firefox does not download on alt-click by default.// Our WebKit embedder does not download on alt-click, although Safari does.