test: download link with data url (#22312)

References #21892
This commit is contained in:
Yury Semikhatsky 2023-04-10 14:15:06 -07:00 committed by GitHub
parent 2d1c736091
commit 1e9668f8bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -705,6 +705,16 @@ it('should convert navigation to a resource with unsupported mime type into down
await page.close();
});
it('should download links with data url', async ({ page, isWindows, browserName }) => {
it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/21892' });
it.fixme(browserName === 'webkit' && isWindows);
await page.setContent('<a download="SomeFile.txt" href="data:text/plain;charset=utf8;,hello world">Download!</a>');
const donwloadPromise = page.waitForEvent('download');
await page.getByText('Download').click();
const download = await donwloadPromise;
expect(download.suggestedFilename()).toBe('SomeFile.txt');
});
async function assertDownloadToPDF(download: Download, filePath: string) {
expect(download.suggestedFilename()).toBe(path.basename(filePath));
const stream = await download.createReadStream();