fix: prevent print crash on bad deviceName (#21946)
* fix: prevent print crash on bad deviceName * address review feedback
This commit is contained in:
parent
662b94f46e
commit
2955c67c4e
3 changed files with 44 additions and 3 deletions
|
@ -100,22 +100,35 @@ describe('webContents module', () => {
|
|||
})
|
||||
|
||||
ifdescribe(features.isPrintingEnabled())('webContents.print()', () => {
|
||||
let w: BrowserWindow
|
||||
|
||||
beforeEach(() => {
|
||||
w = new BrowserWindow({ show: false })
|
||||
})
|
||||
|
||||
afterEach(closeAllWindows)
|
||||
|
||||
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.')
|
||||
})
|
||||
|
||||
it('throws when an invalid callback is passed', () => {
|
||||
expect(() => {
|
||||
// @ts-ignore this line is intentionally incorrect
|
||||
w.webContents.print({}, true)
|
||||
}).to.throw('webContents.print(): Invalid optional callback provided.')
|
||||
})
|
||||
|
||||
ifit(process.platform !== 'linux')('throws when an invalid deviceName is passed', () => {
|
||||
expect(() => {
|
||||
w.webContents.print({ deviceName: 'i-am-a-nonexistent-printer' }, () => {})
|
||||
}).to.throw('webContents.print(): Invalid deviceName provided.')
|
||||
})
|
||||
|
||||
it('does not crash', () => {
|
||||
const w = new BrowserWindow({ show: false })
|
||||
expect(() => {
|
||||
w.webContents.print({ silent: true })
|
||||
}).to.not.throw()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue