|
@@ -9,9 +9,9 @@ import * as path from 'path'
|
|
|
import { homedir } from 'os'
|
|
|
import split = require('split')
|
|
|
import { app, BrowserWindow, Menu } from 'electron'
|
|
|
-import { emittedOnce } from './events-helpers';
|
|
|
-import { closeWindow, closeAllWindows } from './window-helpers';
|
|
|
-import { ifdescribe } from './spec-helpers';
|
|
|
+import { emittedOnce } from './events-helpers'
|
|
|
+import { closeWindow, closeAllWindows } from './window-helpers'
|
|
|
+import { ifdescribe, ifit } from './spec-helpers'
|
|
|
|
|
|
const features = process.electronBinding('features')
|
|
|
|
|
@@ -373,48 +373,38 @@ describe('app module', () => {
|
|
|
|
|
|
afterEach(() => closeWindow(w).then(() => { w = null as any }))
|
|
|
|
|
|
- it('should emit browser-window-focus event when window is focused', (done) => {
|
|
|
- app.once('browser-window-focus', (e, window) => {
|
|
|
- expect(w.id).to.equal(window.id)
|
|
|
- done()
|
|
|
- })
|
|
|
+ it('should emit browser-window-focus event when window is focused', async () => {
|
|
|
+ const emitted = emittedOnce(app, 'browser-window-focus')
|
|
|
w = new BrowserWindow({ show: false })
|
|
|
w.emit('focus')
|
|
|
+ const [, window] = await emitted
|
|
|
+ expect(window.id).to.equal(w.id)
|
|
|
})
|
|
|
|
|
|
- it('should emit browser-window-blur event when window is blured', (done) => {
|
|
|
- app.once('browser-window-blur', (e, window) => {
|
|
|
- expect(w.id).to.equal(window.id)
|
|
|
- done()
|
|
|
- })
|
|
|
+ it('should emit browser-window-blur event when window is blured', async () => {
|
|
|
+ const emitted = emittedOnce(app, 'browser-window-blur')
|
|
|
w = new BrowserWindow({ show: false })
|
|
|
w.emit('blur')
|
|
|
+ const [, window] = await emitted
|
|
|
+ expect(window.id).to.equal(w.id)
|
|
|
})
|
|
|
|
|
|
- it('should emit browser-window-created event when window is created', (done) => {
|
|
|
- app.once('browser-window-created', (e, window) => {
|
|
|
- setImmediate(() => {
|
|
|
- expect(w.id).to.equal(window.id)
|
|
|
- done()
|
|
|
- })
|
|
|
- })
|
|
|
+ it('should emit browser-window-created event when window is created', async () => {
|
|
|
+ const emitted = emittedOnce(app, 'browser-window-created')
|
|
|
w = new BrowserWindow({ show: false })
|
|
|
+ const [, window] = await emitted
|
|
|
+ expect(window.id).to.equal(w.id)
|
|
|
})
|
|
|
|
|
|
- it('should emit web-contents-created event when a webContents is created', (done) => {
|
|
|
- app.once('web-contents-created', (e, webContents) => {
|
|
|
- setImmediate(() => {
|
|
|
- expect(w.webContents.id).to.equal(webContents.id)
|
|
|
- done()
|
|
|
- })
|
|
|
- })
|
|
|
+ it('should emit web-contents-created event when a webContents is created', async () => {
|
|
|
+ const emitted = emittedOnce(app, 'web-contents-created')
|
|
|
w = new BrowserWindow({ show: false })
|
|
|
+ const [, webContents] = await emitted
|
|
|
+ expect(webContents.id).to.equal(w.webContents.id)
|
|
|
})
|
|
|
|
|
|
- it('should emit renderer-process-crashed event when renderer crashes', async function() {
|
|
|
- // FIXME: re-enable this test on win32.
|
|
|
- if (process.platform === 'win32')
|
|
|
- return this.skip()
|
|
|
+ // FIXME: re-enable this test on win32.
|
|
|
+ ifit(process.platform !== 'win32')('should emit renderer-process-crashed event when renderer crashes', async () => {
|
|
|
w = new BrowserWindow({
|
|
|
show: false,
|
|
|
webPreferences: {
|
|
@@ -423,10 +413,10 @@ describe('app module', () => {
|
|
|
})
|
|
|
await w.loadURL('about:blank')
|
|
|
|
|
|
- const promise = emittedOnce(app, 'renderer-process-crashed')
|
|
|
+ const emitted = emittedOnce(app, 'renderer-process-crashed')
|
|
|
w.webContents.executeJavaScript('process.crash()')
|
|
|
|
|
|
- const [, webContents] = await promise
|
|
|
+ const [, webContents] = await emitted
|
|
|
expect(webContents).to.equal(w.webContents)
|
|
|
})
|
|
|
|