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>
This commit is contained in:
parent
2d0ad0b96a
commit
186301e126
37 changed files with 291 additions and 194 deletions
|
@ -181,6 +181,7 @@ describe('chromium feature', () => {
|
|||
const webview = new WebView();
|
||||
const consoleMessage = waitForEvent(webview, 'console-message');
|
||||
webview.allowpopups = true;
|
||||
webview.setAttribute('webpreferences', 'contextIsolation=no');
|
||||
webview.src = url.format({
|
||||
pathname: `${fixtures}/pages/webview-opener-postMessage.html`,
|
||||
protocol: 'file',
|
||||
|
@ -266,7 +267,7 @@ describe('chromium feature', () => {
|
|||
const webview = new WebView();
|
||||
const eventPromise = waitForEvent(webview, 'ipc-message');
|
||||
webview.src = `file://${fixtures}/pages/worker.html`;
|
||||
webview.setAttribute('webpreferences', 'nodeIntegration, nodeIntegrationInWorker');
|
||||
webview.setAttribute('webpreferences', 'nodeIntegration, nodeIntegrationInWorker, contextIsolation=no');
|
||||
document.body.appendChild(webview);
|
||||
const event = await eventPromise;
|
||||
webview.remove();
|
||||
|
|
2
spec/fixtures/api/loaded-from-dataurl.js
vendored
2
spec/fixtures/api/loaded-from-dataurl.js
vendored
|
@ -1 +1 @@
|
|||
require('electron').ipcRenderer.send('answer', 'test');
|
||||
window.ping = 'pong';
|
||||
|
|
3
spec/fixtures/no-proprietary-codecs.js
vendored
3
spec/fixtures/no-proprietary-codecs.js
vendored
|
@ -16,7 +16,8 @@ app.whenReady().then(() => {
|
|||
window = new BrowserWindow({
|
||||
show: false,
|
||||
webPreferences: {
|
||||
nodeIntegration: true
|
||||
nodeIntegration: true,
|
||||
contextIsolation: false
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
<div>
|
||||
<button id="element-1">Button 1</button>
|
||||
<button id="element-2">Button 2</button>
|
||||
<webview src="tab-focus-loop-elements-wv.html" nodeintegration></webview>
|
||||
<webview src="tab-focus-loop-elements-wv.html" nodeintegration webpreferences="contextIsolation=no"></webview>
|
||||
<button id="element-3">Button 3</button>
|
||||
</div>
|
||||
</body>
|
||||
|
|
2
spec/fixtures/pages/webview-no-script.html
vendored
2
spec/fixtures/pages/webview-no-script.html
vendored
|
@ -1,5 +1,5 @@
|
|||
<html>
|
||||
<body>
|
||||
<webview nodeintegration src="ping.html"/>
|
||||
<webview nodeintegration src="ping.html" webpreferences="contextIsolation=no" />
|
||||
</body>
|
||||
</html>
|
||||
|
|
2
spec/fixtures/pages/webview-zoom-factor.html
vendored
2
spec/fixtures/pages/webview-zoom-factor.html
vendored
|
@ -1,5 +1,5 @@
|
|||
<html>
|
||||
<body>
|
||||
<webview nodeintegration src="zoom-factor.html"/>
|
||||
<webview nodeintegration src="zoom-factor.html" webpreferences="contextIsolation=no" />
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -109,7 +109,8 @@ app.whenReady().then(async function () {
|
|||
backgroundThrottling: false,
|
||||
nodeIntegration: true,
|
||||
enableRemoteModule: false,
|
||||
webviewTag: true
|
||||
webviewTag: true,
|
||||
contextIsolation: false
|
||||
}
|
||||
});
|
||||
window.loadFile('static/index.html', {
|
||||
|
|
|
@ -112,6 +112,7 @@ describe('<webview> tag', function () {
|
|||
it('inserts node symbols when set', async () => {
|
||||
const message = await startLoadingWebViewAndWaitForMessage(webview, {
|
||||
nodeintegration: 'on',
|
||||
webpreferences: 'contextIsolation=no',
|
||||
src: `file://${fixtures}/pages/d.html`
|
||||
});
|
||||
|
||||
|
@ -132,6 +133,7 @@ describe('<webview> tag', function () {
|
|||
|
||||
const message = await startLoadingWebViewAndWaitForMessage(webview, {
|
||||
nodeintegration: 'on',
|
||||
webpreferences: 'contextIsolation=no',
|
||||
src: `file://${fixtures}/pages/post.html`
|
||||
});
|
||||
|
||||
|
@ -154,6 +156,7 @@ describe('<webview> tag', function () {
|
|||
});
|
||||
loadWebView(webview, {
|
||||
allowpopups: 'on',
|
||||
webpreferences: 'contextIsolation=no',
|
||||
src
|
||||
});
|
||||
const { message } = await waitForEvent(webview, 'console-message');
|
||||
|
@ -163,6 +166,7 @@ describe('<webview> tag', function () {
|
|||
(nativeModulesEnabled ? it : it.skip)('loads native modules when navigation happens', async function () {
|
||||
await loadWebView(webview, {
|
||||
nodeintegration: 'on',
|
||||
webpreferences: 'contextIsolation=no',
|
||||
src: `file://${fixtures}/pages/native-module.html`
|
||||
});
|
||||
|
||||
|
@ -177,7 +181,8 @@ describe('<webview> tag', function () {
|
|||
it('loads the script before other scripts in window', async () => {
|
||||
const message = await startLoadingWebViewAndWaitForMessage(webview, {
|
||||
preload: `${fixtures}/module/preload.js`,
|
||||
src: `file://${fixtures}/pages/e.html`
|
||||
src: `file://${fixtures}/pages/e.html`,
|
||||
contextIsolation: false
|
||||
});
|
||||
|
||||
expect(message).to.be.a('string');
|
||||
|
@ -343,6 +348,7 @@ describe('<webview> tag', function () {
|
|||
const message = await startLoadingWebViewAndWaitForMessage(webview, {
|
||||
disablewebsecurity: '',
|
||||
nodeintegration: 'on',
|
||||
webpreferences: 'contextIsolation=no',
|
||||
src: `file://${fixtures}/pages/d.html`
|
||||
});
|
||||
|
||||
|
@ -391,6 +397,7 @@ describe('<webview> tag', function () {
|
|||
const message = await startLoadingWebViewAndWaitForMessage(webview, {
|
||||
nodeintegration: 'on',
|
||||
partition: 'test2',
|
||||
webpreferences: 'contextIsolation=no',
|
||||
src: `file://${fixtures}/pages/d.html`
|
||||
});
|
||||
|
||||
|
@ -464,7 +471,7 @@ describe('<webview> tag', function () {
|
|||
it('can enable nodeintegration', async () => {
|
||||
const message = await startLoadingWebViewAndWaitForMessage(webview, {
|
||||
src: `file://${fixtures}/pages/d.html`,
|
||||
webpreferences: 'nodeIntegration'
|
||||
webpreferences: 'nodeIntegration,contextIsolation=no'
|
||||
});
|
||||
|
||||
const types = JSON.parse(message);
|
||||
|
@ -493,7 +500,7 @@ describe('<webview> tag', function () {
|
|||
|
||||
const message = await startLoadingWebViewAndWaitForMessage(webview, {
|
||||
src: `data:text/html;base64,${encoded}`,
|
||||
webpreferences: 'webSecurity=no, nodeIntegration=yes'
|
||||
webpreferences: 'webSecurity=no, nodeIntegration=yes, contextIsolation=no'
|
||||
});
|
||||
|
||||
expect(message).to.equal('function');
|
||||
|
@ -526,6 +533,7 @@ describe('<webview> tag', function () {
|
|||
it('emits when guest sends an ipc message to browser', async () => {
|
||||
loadWebView(webview, {
|
||||
nodeintegration: 'on',
|
||||
webpreferences: 'contextIsolation=no',
|
||||
src: `file://${fixtures}/pages/ipc-message.html`
|
||||
});
|
||||
const { channel, args } = await waitForEvent(webview, 'ipc-message');
|
||||
|
@ -710,6 +718,7 @@ describe('<webview> tag', function () {
|
|||
it('should emit beforeunload handler', async () => {
|
||||
await loadWebView(webview, {
|
||||
nodeintegration: 'on',
|
||||
webpreferences: 'contextIsolation=no',
|
||||
src: `file://${fixtures}/pages/beforeunload-false.html`
|
||||
});
|
||||
|
||||
|
@ -821,6 +830,7 @@ describe('<webview> tag', function () {
|
|||
});
|
||||
loadWebView(webview, {
|
||||
nodeintegration: 'on',
|
||||
webpreferences: 'contextIsolation=no',
|
||||
src: `file://${fixtures}/pages/basic-auth.html?port=${port}`
|
||||
});
|
||||
});
|
||||
|
@ -896,6 +906,7 @@ describe('<webview> tag', function () {
|
|||
it('can send keyboard event', async () => {
|
||||
loadWebView(webview, {
|
||||
nodeintegration: 'on',
|
||||
webpreferences: 'contextIsolation=no',
|
||||
src: `file://${fixtures}/pages/onkeyup.html`
|
||||
});
|
||||
await waitForEvent(webview, 'dom-ready');
|
||||
|
@ -915,6 +926,7 @@ describe('<webview> tag', function () {
|
|||
it('can send mouse event', async () => {
|
||||
loadWebView(webview, {
|
||||
nodeintegration: 'on',
|
||||
webpreferences: 'contextIsolation=no',
|
||||
src: `file://${fixtures}/pages/onmouseup.html`
|
||||
});
|
||||
await waitForEvent(webview, 'dom-ready');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue