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
|
@ -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