Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add test to make sure that 'download' attr is respected #5538

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 29 additions & 0 deletions test/download.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,35 @@ describe('download event', () => {
await page.close();
});

it('should report proper download url when download is from download attribute', (test, {browserName}) => {
// @see https://github.com/microsoft/playwright/issues/5537
test.fixme(browserName === 'webkit');
}, async ({browser, server}) => {
const page = await browser.newPage({ acceptDownloads: true });
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.url()).toBe(`${server.PREFIX}/chromium-linux.zip`);
await page.close();
});

it('should report downloads for download attribute', async ({browser, server}) => {
const page = await browser.newPage({ acceptDownloads: true });
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`);
const path = await download.path();
expect(fs.existsSync(path)).toBeTruthy();
await page.close();
});

it('should save to user-specified path', async ({testInfo, browser, server}) => {
const page = await browser.newPage({ acceptDownloads: true });
await page.setContent(`<a href="${server.PREFIX}/download">download</a>`);
Expand Down