mirror of
https://github.com/electron/electron.git
synced 2026-01-10 07:58:08 -05:00
Assert single window from closeWindow helper
This commit is contained in:
@@ -82,10 +82,7 @@ describe('browser-window module', function () {
|
||||
})
|
||||
|
||||
afterEach(function () {
|
||||
return closeWindow(w).then(function () {
|
||||
w = null
|
||||
assert.equal(BrowserWindow.getAllWindows().length, 1)
|
||||
})
|
||||
return closeWindow(w).then(function () { w = null })
|
||||
})
|
||||
|
||||
describe('BrowserWindow.close()', function () {
|
||||
@@ -859,7 +856,7 @@ describe('browser-window module', function () {
|
||||
assert(/Blocked a frame with origin/.test(exceptionMessage))
|
||||
|
||||
// FIXME this popup window should be closed in sandbox.html
|
||||
closeWindow(popupWindow).then(() => {
|
||||
closeWindow(popupWindow, {assertSingleWindow: false}).then(() => {
|
||||
popupWindow = null
|
||||
done()
|
||||
})
|
||||
|
||||
@@ -1,9 +1,18 @@
|
||||
exports.closeWindow = (window) => {
|
||||
const assert = require('assert')
|
||||
const {BrowserWindow} = require('electron').remote
|
||||
|
||||
exports.closeWindow = (window, {assertSingleWindow} = {assertSingleWindow: true}) => {
|
||||
if (window == null || window.isDestroyed()) {
|
||||
if (assertSingleWindow) {
|
||||
assert.equal(BrowserWindow.getAllWindows().length, 1)
|
||||
}
|
||||
return Promise.resolve()
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
window.once('closed', () => {
|
||||
if (assertSingleWindow) {
|
||||
assert.equal(BrowserWindow.getAllWindows().length, 1)
|
||||
}
|
||||
resolve()
|
||||
})
|
||||
window.setClosable(true)
|
||||
|
||||
Reference in New Issue
Block a user