Close windows instead of destroying them

This commit is contained in:
Kevin Sawicki 2016-08-03 12:47:53 -07:00
parent cce6be1900
commit 0ebe142b2f
10 changed files with 45 additions and 62 deletions

View file

@ -2,6 +2,7 @@
const assert = require('assert')
const path = require('path')
const {closeWindow} = require('./window-helpers')
const {ipcRenderer, remote} = require('electron')
const {ipcMain, webContents, BrowserWindow} = remote
@ -17,6 +18,12 @@ const comparePaths = function (path1, path2) {
describe('ipc module', function () {
var fixtures = path.join(__dirname, 'fixtures')
var w = null
afterEach(function () {
return closeWindow(w).then(function () { w = null })
})
describe('remote.require', function () {
it('should returns same object for the same module', function () {
var dialog1 = remote.require('electron')
@ -302,19 +309,18 @@ describe('ipc module', function () {
it('does not crash when reply is not sent and browser is destroyed', function (done) {
this.timeout(10000)
var w = new BrowserWindow({
w = new BrowserWindow({
show: false
})
ipcMain.once('send-sync-message', function (event) {
event.returnValue = null
w.destroy()
done()
})
w.loadURL('file://' + path.join(fixtures, 'api', 'send-sync-message.html'))
})
it('does not crash when reply is sent by multiple listeners', function (done) {
var w = new BrowserWindow({
w = new BrowserWindow({
show: false
})
ipcMain.on('send-sync-message', function (event) {
@ -322,7 +328,6 @@ describe('ipc module', function () {
})
ipcMain.on('send-sync-message', function (event) {
event.returnValue = null
w.destroy()
done()
})
w.loadURL('file://' + path.join(fixtures, 'api', 'send-sync-message.html'))
@ -354,12 +359,6 @@ describe('ipc module', function () {
})
describe('remote listeners', function () {
var w = null
afterEach(function () {
w.destroy()
})
it('can be added and removed correctly', function () {
w = new BrowserWindow({
show: false