Use once when calling done callback
This commit is contained in:
parent
0ebe142b2f
commit
2c0de93f06
1 changed files with 7 additions and 7 deletions
|
@ -58,7 +58,7 @@ describe('browser-window module', function () {
|
||||||
w.webContents.on('did-finish-load', function () {
|
w.webContents.on('did-finish-load', function () {
|
||||||
w.close()
|
w.close()
|
||||||
})
|
})
|
||||||
w.on('closed', function () {
|
w.once('closed', function () {
|
||||||
var test = path.join(fixtures, 'api', 'unload')
|
var test = path.join(fixtures, 'api', 'unload')
|
||||||
var content = fs.readFileSync(test)
|
var content = fs.readFileSync(test)
|
||||||
fs.unlinkSync(test)
|
fs.unlinkSync(test)
|
||||||
|
@ -69,7 +69,7 @@ describe('browser-window module', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should emit beforeunload handler', function (done) {
|
it('should emit beforeunload handler', function (done) {
|
||||||
w.on('onbeforeunload', function () {
|
w.once('onbeforeunload', function () {
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
w.webContents.on('did-finish-load', function () {
|
w.webContents.on('did-finish-load', function () {
|
||||||
|
@ -81,7 +81,7 @@ describe('browser-window module', function () {
|
||||||
|
|
||||||
describe('window.close()', function () {
|
describe('window.close()', function () {
|
||||||
it('should emit unload handler', function (done) {
|
it('should emit unload handler', function (done) {
|
||||||
w.on('closed', function () {
|
w.once('closed', function () {
|
||||||
var test = path.join(fixtures, 'api', 'close')
|
var test = path.join(fixtures, 'api', 'close')
|
||||||
var content = fs.readFileSync(test)
|
var content = fs.readFileSync(test)
|
||||||
fs.unlinkSync(test)
|
fs.unlinkSync(test)
|
||||||
|
@ -92,7 +92,7 @@ describe('browser-window module', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should emit beforeunload handler', function (done) {
|
it('should emit beforeunload handler', function (done) {
|
||||||
w.on('onbeforeunload', function () {
|
w.once('onbeforeunload', function () {
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
w.loadURL('file://' + path.join(fixtures, 'api', 'close-beforeunload-false.html'))
|
w.loadURL('file://' + path.join(fixtures, 'api', 'close-beforeunload-false.html'))
|
||||||
|
@ -521,21 +521,21 @@ describe('browser-window module', function () {
|
||||||
|
|
||||||
describe('beforeunload handler', function () {
|
describe('beforeunload handler', function () {
|
||||||
it('returning undefined would not prevent close', function (done) {
|
it('returning undefined would not prevent close', function (done) {
|
||||||
w.on('closed', function () {
|
w.once('closed', function () {
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
w.loadURL('file://' + path.join(fixtures, 'api', 'close-beforeunload-undefined.html'))
|
w.loadURL('file://' + path.join(fixtures, 'api', 'close-beforeunload-undefined.html'))
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returning false would prevent close', function (done) {
|
it('returning false would prevent close', function (done) {
|
||||||
w.on('onbeforeunload', function () {
|
w.once('onbeforeunload', function () {
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
w.loadURL('file://' + path.join(fixtures, 'api', 'close-beforeunload-false.html'))
|
w.loadURL('file://' + path.join(fixtures, 'api', 'close-beforeunload-false.html'))
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returning empty string would prevent close', function (done) {
|
it('returning empty string would prevent close', function (done) {
|
||||||
w.on('onbeforeunload', function () {
|
w.once('onbeforeunload', function () {
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
w.loadURL('file://' + path.join(fixtures, 'api', 'close-beforeunload-empty-string.html'))
|
w.loadURL('file://' + path.join(fixtures, 'api', 'close-beforeunload-empty-string.html'))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue