electron/spec/fixtures/crash-cases/webview-remove-on-wc-close/index.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

30 lines
660 B
JavaScript
Raw Normal View History

const { app, BrowserWindow } = require('electron');
app.whenReady().then(() => {
const win = new BrowserWindow({
webPreferences: {
webviewTag: true
}
});
win.loadFile('index.html');
win.webContents.on('did-attach-webview', (event, contents) => {
contents.on('render-process-gone', () => {
process.exit(1);
});
contents.on('destroyed', () => {
process.exit(0);
});
contents.on('did-finish-load', () => {
win.webContents.executeJavaScript('document.querySelector(\'.close-btn\').click()');
});
contents.on('will-prevent-unload', event => {
event.preventDefault();
});
});
});