electron/spec-main/fixtures/sub-frames/webview-iframe-preload.js
Samuel Attard 186301e126
feat: enable context isolation by default (#26890)
* feat: enable context isolation by default

* chore: set default in ctx iso getter

* spec: make all specs work with the new contextIsolation default

* spec: fix affinity specs

* spec: update tests for new ctx iso default

* spec: update tests for new ctx iso default

* spec: update tests for new ctx iso default

* spec: update tests for new ctx iso default

* chore: move stray prod deps to dev deps

* spec: update tests for new ctx iso default

* turn off contextIsolation for visibility tests

* turn off contextIsolation for <webview> tag nodeintegration attribute loads native modules when navigation happens

Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
2021-03-01 16:52:29 -05:00

15 lines
501 B
JavaScript

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