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: safer check for WCO button updates #34874

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
6 changes: 3 additions & 3 deletions shell/browser/native_window_views.cc
Expand Up @@ -876,7 +876,7 @@ bool NativeWindowViews::IsMovable() {
void NativeWindowViews::SetMinimizable(bool minimizable) {
#if BUILDFLAG(IS_WIN)
FlipWindowStyle(GetAcceleratedWidget(), minimizable, WS_MINIMIZEBOX);
if (titlebar_overlay_enabled()) {
if (IsWindowControlsOverlayEnabled()) {
auto* frame_view =
static_cast<WinFrameView*>(widget()->non_client_view()->frame_view());
frame_view->caption_button_container()->UpdateButtons();
Expand All @@ -896,7 +896,7 @@ bool NativeWindowViews::IsMinimizable() {
void NativeWindowViews::SetMaximizable(bool maximizable) {
#if BUILDFLAG(IS_WIN)
FlipWindowStyle(GetAcceleratedWidget(), maximizable, WS_MAXIMIZEBOX);
if (titlebar_overlay_enabled()) {
if (IsWindowControlsOverlayEnabled()) {
auto* frame_view =
static_cast<WinFrameView*>(widget()->non_client_view()->frame_view());
frame_view->caption_button_container()->UpdateButtons();
Expand Down Expand Up @@ -936,7 +936,7 @@ void NativeWindowViews::SetClosable(bool closable) {
} else {
EnableMenuItem(menu, SC_CLOSE, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
}
if (titlebar_overlay_enabled()) {
if (IsWindowControlsOverlayEnabled()) {
auto* frame_view =
static_cast<WinFrameView*>(widget()->non_client_view()->frame_view());
frame_view->caption_button_container()->UpdateButtons();
Expand Down
35 changes: 35 additions & 0 deletions spec-main/api-browser-window-spec.ts
Expand Up @@ -2424,6 +2424,41 @@ describe('BrowserWindow module', () => {
ifit(process.platform === 'darwin')('sets Window Control Overlay with hidden inset title bar', async () => {
await testWindowsOverlay('hiddenInset');
});

ifdescribe(process.platform === 'win32')('when an invalid titleBarStyle is initially set', () => {
let w: BrowserWindow;

beforeEach(() => {
w = new BrowserWindow({
show: false,
webPreferences: {
nodeIntegration: true,
contextIsolation: false
},
titleBarOverlay: {
color: '#0000f0',
symbolColor: '#ffffff'
},
titleBarStyle: 'hiddenInset'
});
});

afterEach(async () => {
await closeAllWindows();
});

it('does not crash changing minimizability ', () => {
expect(() => {
w.setMinimizable(false);
}).to.not.throw();
});

it('does not crash changing maximizability', () => {
expect(() => {
w.setMaximizable(false);
}).to.not.throw();
});
});
});

ifdescribe(['win32', 'darwin'].includes(process.platform))('"titleBarOverlay" option', () => {
Expand Down