Skip to content

Instantly share code, notes, and snippets.

@codebytere
Last active November 17, 2022 11:53
Show Gist options
  • Save codebytere/d21eb8a039ab31faa910384a4ba3200c to your computer and use it in GitHub Desktop.
Save codebytere/d21eb8a039ab31faa910384a4ba3200c to your computer and use it in GitHub Desktop.
browserview-crash
const { app, BrowserWindow, BrowserView } = require('electron')
function createWindow() {
const win = new BrowserWindow({ width: 800, height: 600 });
win.webContents.loadURL('https://www.electronjs.org');
return win;
}
async function wait(ms) {
return new Promise( (resolve) => {
setTimeout( () => {
resolve();
}, ms);
});
}
async function startTest() {
const view = new BrowserView();
view.setBounds({x: 0, y: 0, width: 300, height: 300});
await view.webContents.loadURL('https://www.google.com');
let win = createWindow();
win.addBrowserView(view);
await wait(2500);
win.close();
win = createWindow();
win.addBrowserView(view);
}
app.on('ready', startTest);
{
"name": "volatile-courage-indicate-bgghl",
"productName": "volatile-courage-indicate-bgghl",
"description": "My Electron application description",
"keywords": [],
"main": "./main.js",
"version": "1.0.0",
"author": "codebytere",
"scripts": {
"start": "electron ."
},
"dependencies": {},
"devDependencies": {
"electron": "9999999999.9.9"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment