feat: hide menu bar on windows fullscreen (#43402)

* feat: hide menu bar on windows fullscreen

* test: state prior to html fullscreen transition

* refactor: restore `#ifdef` for readability

Reference: https://github.com/electron/electron/pull/43402#discussion_r1729356262

* docs: menu bar behavior changed

---------

Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
This commit is contained in:
Piotr Płaczek 2024-09-12 19:13:04 +01:00 committed by GitHub
parent 3dd7e46291
commit 29c2744e57
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 53 additions and 0 deletions

View file

@ -5630,6 +5630,37 @@ describe('BrowserWindow module', () => {
});
});
ifdescribe(process.platform !== 'darwin')('fullscreen state', () => {
it('correctly remembers state prior to HTML fullscreen transition', async () => {
const w = new BrowserWindow();
await w.loadFile(path.join(fixtures, 'pages', 'a.html'));
expect(w.isMenuBarVisible()).to.be.true('isMenuBarVisible');
expect(w.isFullScreen()).to.be.false('is fullscreen');
const enterFullScreen = once(w, 'enter-full-screen');
const leaveFullScreen = once(w, 'leave-full-screen');
await w.webContents.executeJavaScript('document.getElementById("div").requestFullscreen()', true);
await enterFullScreen;
await w.webContents.executeJavaScript('document.exitFullscreen()', true);
await leaveFullScreen;
expect(w.isFullScreen()).to.be.false('is fullscreen');
expect(w.isMenuBarVisible()).to.be.true('isMenuBarVisible');
w.setMenuBarVisibility(false);
expect(w.isMenuBarVisible()).to.be.false('isMenuBarVisible');
await w.webContents.executeJavaScript('document.getElementById("div").requestFullscreen()', true);
await enterFullScreen;
await w.webContents.executeJavaScript('document.exitFullscreen()', true);
await leaveFullScreen;
expect(w.isMenuBarVisible()).to.be.false('isMenuBarVisible');
});
});
ifdescribe(process.platform === 'darwin')('fullscreenable state', () => {
it('with functions', () => {
it('can be set with fullscreenable constructor option', () => {