fix: crash in window.print() (#19690)

* fix: crash in window.print()

* add preliminary tests
This commit is contained in:
Shelley Vohr 2019-08-12 23:44:14 -07:00 committed by GitHub
parent ba5ee79af8
commit e8fa248571
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 47 additions and 15 deletions

View file

@ -99,6 +99,28 @@ describe('webContents module', () => {
})
})
describe('webContents.print()', () => {
it('throws when invalid settings are passed', () => {
const w = new BrowserWindow({ show: false })
expect(() => {
// @ts-ignore this line is intentionally incorrect
w.webContents.print(true)
}).to.throw('webContents.print(): Invalid print settings specified.')
expect(() => {
// @ts-ignore this line is intentionally incorrect
w.webContents.print({}, true)
}).to.throw('webContents.print(): Invalid optional callback provided.')
})
it('does not crash', () => {
const w = new BrowserWindow({ show: false })
expect(() => {
w.webContents.print({ silent: true })
}).to.not.throw()
})
})
describe('webContents.executeJavaScript', () => {
describe('in about:blank', () => {
const expected = 'hello, world!'