From 5d986317cff139e0ec920d855ec1e71356d98c82 Mon Sep 17 00:00:00 2001 From: Dmitry Gozman Date: Mon, 20 Apr 2020 20:23:09 -0700 Subject: [PATCH] test: add a test for non-navigation downloads (#1895) --- test/download.spec.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/download.spec.js b/test/download.spec.js index da30d10d09..7078bc1a6a 100644 --- a/test/download.spec.js +++ b/test/download.spec.js @@ -51,6 +51,25 @@ describe('Download', function() { expect(fs.readFileSync(path).toString()).toBe('Hello world'); await page.close(); }); + it.fail(WEBKIT)('should report non-navigation downloads', async({browser, server}) => { + // Our WebKit embedder does not download in this case. + server.setRoute('/download', (req, res) => { + res.setHeader('Content-Type', 'application/octet-stream'); + res.end(`Hello world`); + }); + + const page = await browser.newPage({ acceptDownloads: true }); + await page.goto(server.EMPTY_PAGE); + await page.setContent(`download`); + const [ download ] = await Promise.all([ + page.waitForEvent('download'), + page.click('a') + ]); + const path = await download.path(); + expect(fs.existsSync(path)).toBeTruthy(); + expect(fs.readFileSync(path).toString()).toBe('Hello world'); + await page.close(); + }); it('should delete file', async({browser, server}) => { const page = await browser.newPage({ acceptDownloads: true }); await page.setContent(`download`);