Skip to content

[Bug]: No way to close a browserView #37378

@t57ser

Description

@t57ser

Preflight Checklist

Electron Version

23.1.0

What operating system are you using?

Windows

Operating System Version

10.0.19042

What arch are you using?

x64

Last Known Working Electron version

No response

Expected Behavior

There should be a way to close a browserView.

Actual Behavior

Neither window.close() nor webContents.close() has any effect.
You can play a video on youtube and hear the sound continue after .removeBrowserView is called. So that does not change the behavior either. Also calling window.close() in the devtools has no effect.

const electron = require( "electron" )

electron.app.whenReady().then(()=>{
	let main = new electron.BrowserWindow({
		"height" : 700,
		"width" : 800,
		show: true,
	});

	let view = new electron.BrowserView({});
	view.webContents.loadURL("https://www.youtube.com");
	main.addBrowserView(view);
	view.setBounds({x: 0, y: 0, width: 800, height: 700})
	view.webContents.openDevTools({ mode: "detach" });

	setTimeout(() => {
		console.log("calling webContents.close()")
		//main.removeBrowserView(view);
		//view.webContents.close();
		view.webContents.executeJavaScript("window.close()");
	}, 5000);
})

Testcase Gist URL

No response

Additional Information

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions