electron/spec/fixtures/sub-frames/webview-iframe-preload.js

16 lines
501 B
JavaScript
Raw Normal View History

2020-03-20 20:28:31 +00:00
const { ipcRenderer } = require('electron');
if (process.isMainFrame) {
window.addEventListener('DOMContentLoaded', () => {
2020-03-20 20:28:31 +00:00
const webview = document.createElement('webview');
webview.src = 'about:blank';
webview.setAttribute('webpreferences', 'contextIsolation=no');
webview.addEventListener('did-finish-load', () => {
2020-03-20 20:28:31 +00:00
ipcRenderer.send('webview-loaded');
}, { once: true });
document.body.appendChild(webview);
});
} else {
2020-03-20 20:28:31 +00:00
ipcRenderer.send('preload-in-frame');
}