Skip to content

Commit

Permalink
test: add test for app.on('certificate-error') event (#21978)
Browse files Browse the repository at this point in the history
  • Loading branch information
nornagon committed Feb 10, 2020
1 parent 50dac1d commit 721c97e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
12 changes: 12 additions & 0 deletions spec-main/api-app-spec.ts
Expand Up @@ -317,6 +317,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

Expand Down Expand Up @@ -745,6 +754,7 @@ describe('app module', () => {
if (process.platform === 'linux') {
this.skip()
}
session.fromPartition('empty-certificate').setCertificateVerifyProc((req, cb) => { cb(0) })
})

beforeEach(() => {
Expand All @@ -759,6 +769,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')
Expand Down
3 changes: 0 additions & 3 deletions spec-main/index.js
Expand Up @@ -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')
Expand Down

0 comments on commit 721c97e

Please sign in to comment.