diff --git a/shell/browser/native_window_mac.mm b/shell/browser/native_window_mac.mm index 2c33f806cd0d..0b72d1bf6ba1 100644 --- a/shell/browser/native_window_mac.mm +++ b/shell/browser/native_window_mac.mm @@ -562,6 +562,11 @@ void NativeWindowMac::Unmaximize() { } bool NativeWindowMac::IsMaximized() { + // It's possible for [window_ isZoomed] to be true + // when the window is minimized or fullscreened. + if (IsMinimized() || IsFullscreen()) + return false; + if (HasStyleMask(NSWindowStyleMaskResizable) != 0) return [window_ isZoomed]; diff --git a/spec/api-browser-window-spec.ts b/spec/api-browser-window-spec.ts index 6001c144b9b7..de1035cc2ec0 100644 --- a/spec/api-browser-window-spec.ts +++ b/spec/api-browser-window-spec.ts @@ -1665,6 +1665,42 @@ describe('BrowserWindow module', () => { expectBoundsEqual(w.getNormalBounds(), bounds); }); + it('correctly reports maximized state after maximizing then minimizing', async () => { + w.destroy(); + w = new BrowserWindow({ show: false }); + + w.show(); + + const maximize = once(w, 'maximize'); + w.maximize(); + await maximize; + + const minimize = once(w, 'minimize'); + w.minimize(); + await minimize; + + expect(w.isMaximized()).to.equal(false); + expect(w.isMinimized()).to.equal(true); + }); + + it('correctly reports maximized state after maximizing then fullscreening', async () => { + w.destroy(); + w = new BrowserWindow({ show: false }); + + w.show(); + + const maximize = once(w, 'maximize'); + w.maximize(); + await maximize; + + const enterFS = once(w, 'enter-full-screen'); + w.setFullScreen(true); + await enterFS; + + expect(w.isMaximized()).to.equal(false); + expect(w.isFullScreen()).to.equal(true); + }); + it('does not change size for a frameless window with min size', async () => { w.destroy(); w = new BrowserWindow({