test: add test for app.on('certificate-error') event (#21978)
This commit is contained in:
parent
08b1f0e25d
commit
720cf6eb27
2 changed files with 13 additions and 4 deletions
|
@ -5,7 +5,7 @@ import * as http from 'http'
|
|||
import * as net from 'net'
|
||||
import * as fs from 'fs'
|
||||
import * as path from 'path'
|
||||
import { app, BrowserWindow, Menu } from 'electron'
|
||||
import { app, BrowserWindow, Menu, session } from 'electron'
|
||||
import { emittedOnce } from './events-helpers'
|
||||
import { closeWindow, closeAllWindows } from './window-helpers'
|
||||
import { ifdescribe } from './spec-helpers'
|
||||
|
@ -305,6 +305,15 @@ describe('app module', () => {
|
|||
})
|
||||
})
|
||||
|
||||
describe('certificate-error event', () => {
|
||||
afterEach(closeAllWindows)
|
||||
it('is emitted when visiting a server with a self-signed cert', async () => {
|
||||
const w = new BrowserWindow({ show: false })
|
||||
w.loadURL(secureUrl)
|
||||
await emittedOnce(app, 'certificate-error')
|
||||
})
|
||||
})
|
||||
|
||||
// xdescribe('app.importCertificate', () => {
|
||||
// let w = null
|
||||
|
||||
|
@ -708,6 +717,7 @@ describe('app module', () => {
|
|||
if (process.platform === 'linux') {
|
||||
this.skip()
|
||||
}
|
||||
session.fromPartition('empty-certificate').setCertificateVerifyProc((req, cb) => { cb(0) })
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
|
@ -722,6 +732,8 @@ describe('app module', () => {
|
|||
|
||||
afterEach(() => closeWindow(w).then(() => { w = null as any }))
|
||||
|
||||
after(() => session.fromPartition('empty-certificate').setCertificateVerifyProc(null))
|
||||
|
||||
it('can respond with empty certificate list', async () => {
|
||||
app.once('select-client-certificate', function (event, webContents, url, list, callback) {
|
||||
console.log('select-client-certificate emitted')
|
||||
|
|
|
@ -20,9 +20,6 @@ v8.setFlagsFromString('--expose_gc')
|
|||
app.commandLine.appendSwitch('js-flags', '--expose_gc')
|
||||
// Prevent the spec runner quiting when the first window closes
|
||||
app.on('window-all-closed', () => null)
|
||||
// TODO: This API should _probably_ only be enabled for the specific test that needs it
|
||||
// not the entire test suite
|
||||
app.commandLine.appendSwitch('ignore-certificate-errors')
|
||||
|
||||
// Use fake device for Media Stream to replace actual camera and microphone.
|
||||
app.commandLine.appendSwitch('use-fake-device-for-media-stream')
|
||||
|
|
Loading…
Reference in a new issue