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: only exit fullscreen conditionally with setKiosk #38368

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions shell/browser/native_window_mac.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ class NativeWindowMac : public NativeWindow,
// The views::View that fills the client area.
std::unique_ptr<RootViewMac> root_view_;

bool fullscreen_before_kiosk_ = false;
bool is_kiosk_ = false;
bool zoom_to_page_width_ = false;
absl::optional<gfx::Point> traffic_light_position_;
Expand Down
7 changes: 5 additions & 2 deletions shell/browser/native_window_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1030,10 +1030,13 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) {
NSApplicationPresentationDisableHideApplication;
[NSApp setPresentationOptions:options];
is_kiosk_ = true;
SetFullScreen(true);
fullscreen_before_kiosk_ = IsFullscreen();
if (!fullscreen_before_kiosk_)
SetFullScreen(true);
} else if (!kiosk && is_kiosk_) {
is_kiosk_ = false;
SetFullScreen(false);
if (!fullscreen_before_kiosk_)
SetFullScreen(false);

// Set presentation options *after* asynchronously exiting
// fullscreen to ensure they take effect.
Expand Down
25 changes: 19 additions & 6 deletions spec/api-browser-window-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5176,19 +5176,32 @@ describe('BrowserWindow module', () => {

it('should not be changed by setKiosk method', async () => {
const w = new BrowserWindow();

const enterFullScreen = emittedOnce(w, 'enter-full-screen');
w.setKiosk(true);
await enterFullScreen;
expect(w.isFullScreen()).to.be.true('isFullScreen');

const leaveFullScreen = emittedOnce(w, 'leave-full-screen');
w.setKiosk(false);
await leaveFullScreen;
expect(w.isFullScreen()).to.be.false('isFullScreen');
});

it('should stay fullscreen if fullscreen before kiosk', async () => {
const w = new BrowserWindow();

const enterFullScreen = emittedOnce(w, 'enter-full-screen');
w.setFullScreen(true);
await enterFullScreen;
expect(w.isFullScreen()).to.be.true('isFullScreen');
await delay();

w.setKiosk(true);
await delay();
w.setKiosk(false);

// Wait enough time for a fullscreen change to take effect.
await delay(2000);
expect(w.isFullScreen()).to.be.true('isFullScreen');
const leaveFullScreen = emittedOnce(w, 'leave-full-screen');
w.setFullScreen(false);
await leaveFullScreen;
expect(w.isFullScreen()).to.be.false('isFullScreen');
});

// FIXME: https://github.com/electron/electron/issues/30140
Expand Down
Loading