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

feat: add webContents.close() #35509

Merged
merged 4 commits into from Sep 16, 2022
Merged

feat: add webContents.close() #35509

merged 4 commits into from Sep 16, 2022

Conversation

nornagon
Copy link
Member

Description of Change

Adds webContents.close(), which has roughly the same effect as the page
calling window.close(). Closes #26929.

There was some discussion in #26929 about having a WebContents be reusable
after close, but after studying the //content API for a while, I'm not sure
that's reasonable to implement, since content::WebContents is only closable by
destroying it.

Checklist

Release Notes

Notes: Added webContents.close() method.

@nornagon nornagon added no-backport semver/minor backwards-compatible functionality labels Aug 30, 2022
@electron-cation electron-cation bot added new-pr 🌱 PR opened in the last 24 hours api-review/requested 🗳 labels Aug 30, 2022
@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Sep 6, 2022
Copy link
Contributor

@jkleinsc jkleinsc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API LGTM

docs/api/web-contents.md Outdated Show resolved Hide resolved
Copy link

@denox55 denox55 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

().

Copy link
Member

@samuelmaddock samuelmaddock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API LGTM

@ckerr
Copy link
Member

ckerr commented Sep 15, 2022

API LGTM

Copy link
Member

@ckerr ckerr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API LGTM

@ckerr ckerr merged commit eebf34c into main Sep 16, 2022
@ckerr ckerr deleted the web-contents-close branch September 16, 2022 23:23
@release-clerk
Copy link

release-clerk bot commented Sep 16, 2022

Release Notes Persisted

Added webContents.close() method.

@PascalPixel
Copy link

browserView.webContents.close() no longer stops a video from being played in Electron 23, the audio continues after closing a YouTube frame, it stopped it in Electron 22. Am now calling browserView.webContents.destroy() to get it to stop.

@nornagon
Copy link
Member Author

@PascalPixel please open a new issue with a repro, thanks!

khalwa pushed a commit to solarwindscloud/electron that referenced this pull request Feb 22, 2023
* feat: add webContents.close()

* update docs, add test for beforeunload override

* Update web-contents.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API: Documented way to close a WebContents
8 participants