Consolidate window closing

This commit is contained in:
Kevin Sawicki 2017-04-18 16:04:27 -07:00
parent 4a9383b50b
commit 4af44b1be6

View file

@ -13,6 +13,7 @@ const isCI = remote.getGlobal('isCi')
describe('chromium feature', function () {
var fixtures = path.resolve(__dirname, 'fixtures')
var listener = null
let w = null
afterEach(function () {
if (listener != null) {
@ -21,6 +22,10 @@ describe('chromium feature', function () {
listener = null
})
afterEach(function () {
return closeWindow(w).then(function () { w = null })
})
describe('heap snapshot', function () {
it('does not crash', function () {
if (process.env.TRAVIS === 'true') return
@ -44,11 +49,6 @@ describe('chromium feature', function () {
describe('document.hidden', function () {
var url = 'file://' + fixtures + '/pages/document-hidden.html'
var w = null
afterEach(function () {
return closeWindow(w).then(function () { w = null })
})
it('is set correctly when window is not shown', function (done) {
w = new BrowserWindow({
@ -119,7 +119,7 @@ describe('chromium feature', function () {
}
const deviceIds = []
const ses = session.fromPartition('persist:media-device-id')
let w = new BrowserWindow({
w = new BrowserWindow({
show: false,
webPreferences: {
session: ses
@ -155,11 +155,6 @@ describe('chromium feature', function () {
describe('navigator.serviceWorker', function () {
var url = 'file://' + fixtures + '/pages/service-worker/index.html'
var w = null
afterEach(function () {
return closeWindow(w).then(function () { w = null })
})
it('should register for file scheme', function (done) {
w = new BrowserWindow({
@ -188,12 +183,6 @@ describe('chromium feature', function () {
return
}
let w = null
afterEach(() => {
return closeWindow(w).then(function () { w = null })
})
it('returns a BrowserWindowProxy object', function () {
var b = window.open('about:blank', '', 'show=no')
assert.equal(b.closed, false)
@ -343,11 +332,6 @@ describe('chromium feature', function () {
describe('window.opener', function () {
let url = 'file://' + fixtures + '/pages/window-opener.html'
let w = null
afterEach(function () {
return closeWindow(w).then(function () { w = null })
})
it('is null for main window', function (done) {
w = new BrowserWindow({
@ -849,7 +833,6 @@ describe('chromium feature', function () {
})
describe('PDF Viewer', function () {
let w = null
const pdfSource = url.format({
pathname: path.join(fixtures, 'assets', 'cat.pdf').replace(/\\/g, '/'),
protocol: 'file',
@ -865,10 +848,6 @@ describe('chromium feature', function () {
})
})
afterEach(function () {
return closeWindow(w).then(function () { w = null })
})
it('opens when loading a pdf resource as top level navigation', function (done) {
ipcMain.once('pdf-loaded', function (event, success) {
if (success) done()