Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: emit window-all-closed after closing the window #28867

Merged
merged 1 commit into from
Apr 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions shell/browser/native_window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -423,11 +423,11 @@ void NativeWindow::NotifyWindowClosed() {
if (is_closed_)
return;

WindowList::RemoveWindow(this);

is_closed_ = true;
for (NativeWindowObserver& observer : observers_)
observer.OnWindowClosed();

WindowList::RemoveWindow(this);
}

void NativeWindow::NotifyWindowEndSession() {
Expand Down
13 changes: 13 additions & 0 deletions spec-main/api-app-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1626,6 +1626,8 @@ describe('default behavior', () => {
});

describe('window-all-closed', () => {
afterEach(closeAllWindows);

it('quits when the app does not handle the event', async () => {
const result = await runTestApp('window-all-closed');
expect(result).to.equal(false);
Expand All @@ -1635,6 +1637,17 @@ describe('default behavior', () => {
const result = await runTestApp('window-all-closed', '--handle-event');
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', () => {
Expand Down