fix: savePage throw on relative paths (#32728)

This commit is contained in:
Shelley Vohr 2022-02-07 09:51:59 +01:00 committed by GitHub
parent d46431b564
commit 81fcd732c2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 1 deletions

View file

@ -3431,6 +3431,23 @@ describe('BrowserWindow module', () => {
} catch {}
});
it('should throw when passing relative paths', async () => {
const w = new BrowserWindow({ show: false });
await w.loadFile(path.join(fixtures, 'pages', 'save_page', 'index.html'));
await expect(
w.webContents.savePage('save_page.html', 'HTMLComplete')
).to.eventually.be.rejectedWith('Path must be absolute');
await expect(
w.webContents.savePage('save_page.html', 'HTMLOnly')
).to.eventually.be.rejectedWith('Path must be absolute');
await expect(
w.webContents.savePage('save_page.html', 'MHTML')
).to.eventually.be.rejectedWith('Path must be absolute');
});
it('should save page to disk with HTMLOnly', async () => {
const w = new BrowserWindow({ show: false });
await w.loadFile(path.join(fixtures, 'pages', 'save_page', 'index.html'));