fix: emit window-all-closed after closing the window (#28867)
This commit is contained in:
parent
733f81449d
commit
c200840006
2 changed files with 15 additions and 2 deletions
|
@ -423,11 +423,11 @@ void NativeWindow::NotifyWindowClosed() {
|
||||||
if (is_closed_)
|
if (is_closed_)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
WindowList::RemoveWindow(this);
|
|
||||||
|
|
||||||
is_closed_ = true;
|
is_closed_ = true;
|
||||||
for (NativeWindowObserver& observer : observers_)
|
for (NativeWindowObserver& observer : observers_)
|
||||||
observer.OnWindowClosed();
|
observer.OnWindowClosed();
|
||||||
|
|
||||||
|
WindowList::RemoveWindow(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindow::NotifyWindowEndSession() {
|
void NativeWindow::NotifyWindowEndSession() {
|
||||||
|
|
|
@ -1626,6 +1626,8 @@ describe('default behavior', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('window-all-closed', () => {
|
describe('window-all-closed', () => {
|
||||||
|
afterEach(closeAllWindows);
|
||||||
|
|
||||||
it('quits when the app does not handle the event', async () => {
|
it('quits when the app does not handle the event', async () => {
|
||||||
const result = await runTestApp('window-all-closed');
|
const result = await runTestApp('window-all-closed');
|
||||||
expect(result).to.equal(false);
|
expect(result).to.equal(false);
|
||||||
|
@ -1635,6 +1637,17 @@ describe('default behavior', () => {
|
||||||
const result = await runTestApp('window-all-closed', '--handle-event');
|
const result = await runTestApp('window-all-closed', '--handle-event');
|
||||||
expect(result).to.equal(true);
|
expect(result).to.equal(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should omit closed windows from getAllWindows', async () => {
|
||||||
|
const w = new BrowserWindow({ show: false });
|
||||||
|
const len = new Promise(resolve => {
|
||||||
|
app.on('window-all-closed', () => {
|
||||||
|
resolve(BrowserWindow.getAllWindows().length);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
w.close();
|
||||||
|
expect(await len).to.equal(0);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('user agent fallback', () => {
|
describe('user agent fallback', () => {
|
||||||
|
|
Loading…
Reference in a new issue