Skip to content

[Bug]: Destroyed event not emitted on close for custom BrowserView.webContents #37356

@mgalla10

Description

@mgalla10

Preflight Checklist

Electron Version

22.3.0

What operating system are you using?

Windows

Operating System Version

Windows 10 version 21H2

What arch are you using?

x64

Last Known Working Electron version

22.2.1

Expected Behavior

I've created a custom BrowserView, added it to my main BrowserWindow via addBrowserView(), and navigated its webContents to a file. Upon receiving a message from the renderer process, I attach a handler to the webContents' 'destroyed' event, then close the contents via webContents.close(). Since I'm omitting the 'waitForBeforeUnload' option in my close() call, I expect the 'destroyed' event to be emitted, and my attached handler to run.

Actual Behavior

The 'destroyed' event is not emitted, and my attached handler never run, until my main BrowserWindow is closed.

Testcase Gist URL

https://gist.github.com/mgalla10/cdff38e750ae49d01500445b019493ca

Additional Information

To repro, run the attached gist with v22.2.1 and click the "Close" button. After dismissing a message box saying "Closing page 2", that page will disappear and another "Page 2 closed" message box will appear. Run the gist again with v22.3.0 and notice that after dismissing the first message box, the page doesn't seem to disappear, and the second message box never appears.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions