Skip to content

feat: add webContents.close() - #35509

Merged
ckerr merged 4 commits into
mainfrom
web-contents-close
Sep 16, 2022
Merged

ckerr merged 4 commits into
mainfrom
web-contents-close

Conversation

@nornagon

Copy link
Copy Markdown
Contributor

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 removed the new-pr 🌱 PR opened recently label Sep 6, 2022

@jkleinsc jkleinsc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

API LGTM

Comment thread docs/api/web-contents.md Resolved
Comment thread docs/api/web-contents.md Resolved

@denox55 denox55 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

().

Comment thread docs/api/web-contents.md Resolved

@samuelmaddock samuelmaddock left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

API LGTM

@ckerr

ckerr commented Sep 15, 2022

Copy link
Copy Markdown
Member

API LGTM

@ckerr ckerr left a comment

Copy link
Copy Markdown
Member

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

release-clerk Bot commented Sep 16, 2022

Copy link
Copy Markdown

Release Notes Persisted

Added webContents.close() method.

@PascalPixel

Copy link
Copy Markdown

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
Copy Markdown
Contributor 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