Skip to content

Commit

Permalink
fix: requestFullscreen from WebContentsView (#41995)
Browse files Browse the repository at this point in the history
fix: requestFullscreen from WebContentsView

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
  • Loading branch information
3 people committed May 1, 2024
1 parent 8442653 commit ec4ffa9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions shell/browser/api/electron_api_web_contents_view.cc
Expand Up @@ -89,6 +89,9 @@ void WebContentsView::OnViewAddedToWidget(views::View* observed_view) {
widget->GetNativeWindowProperty(electron::kElectronNativeWindowKey));
if (!native_window)
return;
// We don't need to call SetOwnerWindow(nullptr) in OnViewRemovedFromWidget
// because that's handled in the WebContents dtor called prior.
api_web_contents_->SetOwnerWindow(native_window);
native_window->AddDraggableRegionProvider(this);
}

Expand Down
12 changes: 12 additions & 0 deletions spec/api-web-contents-view-spec.ts
Expand Up @@ -60,6 +60,18 @@ describe('WebContentsView', () => {
});
});

it('can be fullscreened', async () => {
const w = new BaseWindow();
const v = new WebContentsView();
w.setContentView(v);
await v.webContents.loadURL('data:text/html,<div id="div">This is a simple div.</div>');

const enterFullScreen = once(w, 'enter-full-screen');
await v.webContents.executeJavaScript('document.getElementById("div").requestFullscreen()', true);
await enterFullScreen;
expect(w.isFullScreen()).to.be.true('isFullScreen');
});

describe('visibilityState', () => {
it('is initially hidden', async () => {
const v = new WebContentsView();
Expand Down

0 comments on commit ec4ffa9

Please sign in to comment.