Skip to content

Commit 5d98631

Browse files
authored
test: add a test for non-navigation downloads (#1895)
1 parent 47c3841 commit 5d98631

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

test/download.spec.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,25 @@ describe('Download', function() {
5151
expect(fs.readFileSync(path).toString()).toBe('Hello world');
5252
await page.close();
5353
});
54+
it.fail(WEBKIT)('should report non-navigation downloads', async({browser, server}) => {
55+
// Our WebKit embedder does not download in this case.
56+
server.setRoute('/download', (req, res) => {
57+
res.setHeader('Content-Type', 'application/octet-stream');
58+
res.end(`Hello world`);
59+
});
60+
61+
const page = await browser.newPage({ acceptDownloads: true });
62+
await page.goto(server.EMPTY_PAGE);
63+
await page.setContent(`<a download="file.txt" href="${server.PREFIX}/download">download</a>`);
64+
const [ download ] = await Promise.all([
65+
page.waitForEvent('download'),
66+
page.click('a')
67+
]);
68+
const path = await download.path();
69+
expect(fs.existsSync(path)).toBeTruthy();
70+
expect(fs.readFileSync(path).toString()).toBe('Hello world');
71+
await page.close();
72+
});
5473
it('should delete file', async({browser, server}) => {
5574
const page = await browser.newPage({ acceptDownloads: true });
5675
await page.setContent(`<a download=true href="${server.PREFIX}/download">download</a>`);

0 commit comments

Comments
 (0)