8000 API: Documented way to close a WebContents · Issue #26929 · electron/electron · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
API: Documented way to close a WebContents #26929
Closed
@nornagon

Description

@nornagon

There should be a documented way to close a WebContents and allow it to be garbage collected.

I'd prefer not to document the existing webContents.destroy() method if possible as it's quite aggressive and makes the underlying WebContents object unusable after being called. Ideally, I'd like to have a webContents.close() method that returns the object to the state that it was in prior to loadURL() being called, and marks it as available for GC once references are dropped.

i.e. this should work:

const bv = new BrowserView
bv.webContents.loadURL("https://example.com")
// ... later ...
bv.webContents.close()
// If the reference to `bv` were dropped here, both `bv` and the webContents would be available for collection

// ... but if the reference is retained, the WebContents should be re-usable at a later date:
bv.webContents.loadURL("https://example.com")

Ref #23578.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0