fix: webview crash when removing in close event (#38996)
This commit is contained in:
parent
5a77c75753
commit
c7a64ab994
4 changed files with 83 additions and 1 deletions
29
spec/fixtures/crash-cases/webview-remove-on-wc-close/index.js
vendored
Normal file
29
spec/fixtures/crash-cases/webview-remove-on-wc-close/index.js
vendored
Normal file
|
@ -0,0 +1,29 @@
|
|||
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();
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue