test: navigation to resource with unknown mime type (#20313)

https://github.com/microsoft/playwright/issues/20089
This commit is contained in:
Yury Semikhatsky 2023-01-24 07:29:46 -08:00 committed by GitHub
parent aedcecb3db
commit 2c52d5be59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -697,6 +697,21 @@ it('should download even if there is no "attachment" value', async ({ browser, s
await page.close();
});
it('should convert navigation to a resource with unsupported mime type into download', async ({ browser, server, mode, browserName }, testInfo) => {
it.fixme(browserName === 'webkit');
it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/19939' });
server.setRoute('/download', (req, res) => {
res.setHeader('Content-Type', 'application/octet-stream');
res.end(`Hello world`);
});
const page = await browser.newPage();
await Promise.all([
page.waitForEvent('download'),
page.goto(`${server.PREFIX}/download`).catch(() => {})
]);
await page.close();
});
async function assertDownloadToPDF(download: Download, filePath: string) {
expect(download.suggestedFilename()).toBe(path.basename(filePath));
const stream = await download.createReadStream();