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:
Samuel Attard 2021-03-01 13:52:29 -08:00 committed by GitHub
parent 2d0ad0b96a
commit 186301e126
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
37 changed files with 291 additions and 194 deletions

View file

@ -19,7 +19,7 @@ describe('modules support', () => {
ifdescribe(nativeModulesEnabled)('echo', () => {
afterEach(closeAllWindows);
it('can be required in renderer', async () => {
const w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true } });
const w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true, contextIsolation: false } });
w.loadURL('about:blank');
await expect(w.webContents.executeJavaScript('{ require(\'echo\'); null }')).to.be.fulfilled();
});
@ -51,7 +51,7 @@ describe('modules support', () => {
];
ifdescribe(nativeModulesEnabled && enablePlatforms.includes(process.platform))('module that use uv_dlopen', () => {
it('can be required in renderer', async () => {
const w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true } });
const w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true, contextIsolation: false } });
w.loadURL('about:blank');
await expect(w.webContents.executeJavaScript('{ require(\'uv-dlopen\'); null }')).to.be.fulfilled();
});
@ -163,7 +163,7 @@ describe('modules support', () => {
describe('when loaded URL is not file: protocol', () => {
afterEach(closeAllWindows);
it('searches for module under app directory', async () => {
const w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true } });
const w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true, contextIsolation: false } });
w.loadURL('about:blank');
const result = await w.webContents.executeJavaScript('typeof require("q").when');
expect(result).to.equal('function');