|
@@ -87,7 +87,7 @@ describe('window.postMessage', () => {
|
|
|
for (const nativeWindowOpen of [true, false]) {
|
|
|
describe(`when nativeWindowOpen: ${nativeWindowOpen}`, () => {
|
|
|
it('sets the source and origin correctly', async () => {
|
|
|
- const w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true, nativeWindowOpen } });
|
|
|
+ const w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true, nativeWindowOpen, contextIsolation: false } });
|
|
|
w.loadURL(`file://${fixturesPath}/pages/window-open-postMessage-driver.html`);
|
|
|
const [, message] = await emittedOnce(ipcMain, 'complete');
|
|
|
expect(message.data).to.equal('testing');
|
|
@@ -108,7 +108,8 @@ describe('focus handling', () => {
|
|
|
show: true,
|
|
|
webPreferences: {
|
|
|
nodeIntegration: true,
|
|
|
- webviewTag: true
|
|
|
+ webviewTag: true,
|
|
|
+ contextIsolation: false
|
|
|
}
|
|
|
});
|
|
|
|
|
@@ -228,7 +229,7 @@ describe('web security', () => {
|
|
|
});
|
|
|
|
|
|
it('engages CORB when web security is not disabled', async () => {
|
|
|
- const w = new BrowserWindow({ show: false, webPreferences: { webSecurity: true, nodeIntegration: true } });
|
|
|
+ const w = new BrowserWindow({ show: false, webPreferences: { webSecurity: true, nodeIntegration: true, contextIsolation: false } });
|
|
|
const p = emittedOnce(ipcMain, 'success');
|
|
|
await w.loadURL(`data:text/html,<script>
|
|
|
const s = document.createElement('script')
|
|
@@ -242,7 +243,7 @@ describe('web security', () => {
|
|
|
});
|
|
|
|
|
|
it('bypasses CORB when web security is disabled', async () => {
|
|
|
- const w = new BrowserWindow({ show: false, webPreferences: { webSecurity: false, nodeIntegration: true } });
|
|
|
+ const w = new BrowserWindow({ show: false, webPreferences: { webSecurity: false, nodeIntegration: true, contextIsolation: false } });
|
|
|
const p = emittedOnce(ipcMain, 'success');
|
|
|
await w.loadURL(`data:text/html,
|
|
|
<script>
|
|
@@ -253,7 +254,7 @@ describe('web security', () => {
|
|
|
});
|
|
|
|
|
|
it('engages CORS when web security is not disabled', async () => {
|
|
|
- const w = new BrowserWindow({ show: false, webPreferences: { webSecurity: true, nodeIntegration: true } });
|
|
|
+ const w = new BrowserWindow({ show: false, webPreferences: { webSecurity: true, nodeIntegration: true, contextIsolation: false } });
|
|
|
const p = emittedOnce(ipcMain, 'response');
|
|
|
await w.loadURL(`data:text/html,<script>
|
|
|
(async function() {
|
|
@@ -270,7 +271,7 @@ describe('web security', () => {
|
|
|
});
|
|
|
|
|
|
it('bypasses CORS when web security is disabled', async () => {
|
|
|
- const w = new BrowserWindow({ show: false, webPreferences: { webSecurity: false, nodeIntegration: true } });
|
|
|
+ const w = new BrowserWindow({ show: false, webPreferences: { webSecurity: false, nodeIntegration: true, contextIsolation: false } });
|
|
|
const p = emittedOnce(ipcMain, 'response');
|
|
|
await w.loadURL(`data:text/html,<script>
|
|
|
(async function() {
|
|
@@ -443,7 +444,8 @@ describe('chromium features', () => {
|
|
|
show: false,
|
|
|
webPreferences: {
|
|
|
nodeIntegration: true,
|
|
|
- partition: 'sw-file-scheme-spec'
|
|
|
+ partition: 'sw-file-scheme-spec',
|
|
|
+ contextIsolation: false
|
|
|
}
|
|
|
});
|
|
|
w.webContents.on('ipc-message', (event, channel, message) => {
|
|
@@ -480,7 +482,8 @@ describe('chromium features', () => {
|
|
|
show: false,
|
|
|
webPreferences: {
|
|
|
nodeIntegration: true,
|
|
|
- session: customSession
|
|
|
+ session: customSession,
|
|
|
+ contextIsolation: false
|
|
|
}
|
|
|
});
|
|
|
w.webContents.on('ipc-message', (event, channel, message) => {
|
|
@@ -508,7 +511,8 @@ describe('chromium features', () => {
|
|
|
webPreferences: {
|
|
|
nodeIntegration: true,
|
|
|
nodeIntegrationInWorker: true,
|
|
|
- partition: 'sw-file-scheme-worker-spec'
|
|
|
+ partition: 'sw-file-scheme-worker-spec',
|
|
|
+ contextIsolation: false
|
|
|
}
|
|
|
});
|
|
|
|
|
@@ -542,7 +546,8 @@ describe('chromium features', () => {
|
|
|
show: false,
|
|
|
webPreferences: {
|
|
|
nodeIntegration: true,
|
|
|
- partition: 'geolocation-spec'
|
|
|
+ partition: 'geolocation-spec',
|
|
|
+ contextIsolation: false
|
|
|
}
|
|
|
});
|
|
|
const message = emittedOnce(w.webContents, 'ipc-message');
|
|
@@ -661,7 +666,7 @@ describe('chromium features', () => {
|
|
|
const w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true } });
|
|
|
w.loadURL('about:blank');
|
|
|
w.webContents.executeJavaScript(`
|
|
|
- b = window.open('devtools://devtools/bundled/inspector.html', '', 'nodeIntegration=no,show=no')
|
|
|
+ { b = window.open('devtools://devtools/bundled/inspector.html', '', 'nodeIntegration=no,show=no'); null }
|
|
|
`);
|
|
|
const [, contents] = await emittedOnce(app, 'web-contents-created');
|
|
|
const typeofProcessGlobal = await contents.executeJavaScript('typeof process');
|
|
@@ -677,7 +682,7 @@ describe('chromium features', () => {
|
|
|
slashes: true
|
|
|
});
|
|
|
w.webContents.executeJavaScript(`
|
|
|
- b = window.open(${JSON.stringify(windowUrl)}, '', 'javascript=no,show=no')
|
|
|
+ { b = window.open(${JSON.stringify(windowUrl)}, '', 'javascript=no,show=no'); null }
|
|
|
`);
|
|
|
const [, contents] = await emittedOnce(app, 'web-contents-created');
|
|
|
await emittedOnce(contents, 'did-finish-load');
|
|
@@ -794,7 +799,8 @@ describe('chromium features', () => {
|
|
|
const w = new BrowserWindow({
|
|
|
show: false,
|
|
|
webPreferences: {
|
|
|
- nodeIntegration: true
|
|
|
+ nodeIntegration: true,
|
|
|
+ contextIsolation: false
|
|
|
}
|
|
|
});
|
|
|
w.loadFile(path.join(fixturesPath, 'pages', 'window-opener.html'));
|
|
@@ -831,7 +837,8 @@ describe('chromium features', () => {
|
|
|
show: false,
|
|
|
webPreferences: {
|
|
|
nodeIntegration: true,
|
|
|
- session: ses
|
|
|
+ session: ses,
|
|
|
+ contextIsolation: false
|
|
|
}
|
|
|
});
|
|
|
w.loadFile(path.join(fixturesPath, 'pages', 'media-id-reset.html'));
|
|
@@ -846,7 +853,8 @@ describe('chromium features', () => {
|
|
|
show: false,
|
|
|
webPreferences: {
|
|
|
nodeIntegration: true,
|
|
|
- session: ses
|
|
|
+ session: ses,
|
|
|
+ contextIsolation: false
|
|
|
}
|
|
|
});
|
|
|
w.loadFile(path.join(fixturesPath, 'pages', 'media-id-reset.html'));
|
|
@@ -914,7 +922,7 @@ describe('chromium features', () => {
|
|
|
for (const sandboxPopup of [false, true]) {
|
|
|
const description = `when parent=${s(parent)} opens child=${s(child)} with nodeIntegration=${nodeIntegration} nativeWindowOpen=${nativeWindowOpen} sandboxPopup=${sandboxPopup}, child should ${openerAccessible ? '' : 'not '}be able to access opener`;
|
|
|
it(description, async () => {
|
|
|
- const w = new BrowserWindow({ show: true, webPreferences: { nodeIntegration: true, nativeWindowOpen } });
|
|
|
+ const w = new BrowserWindow({ show: true, webPreferences: { nodeIntegration: true, nativeWindowOpen, contextIsolation: false } });
|
|
|
w.webContents.setWindowOpenHandler(() => ({
|
|
|
action: 'allow',
|
|
|
overrideBrowserWindowOptions: {
|
|
@@ -953,7 +961,7 @@ describe('chromium features', () => {
|
|
|
// We are testing whether context (3) can access context (2) under various conditions.
|
|
|
|
|
|
// This is context (1), the base window for the test.
|
|
|
- const w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true, webviewTag: true } });
|
|
|
+ const w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true, webviewTag: true, contextIsolation: false } });
|
|
|
await w.loadURL('about:blank');
|
|
|
|
|
|
const parentCode = `new Promise((resolve) => {
|
|
@@ -967,7 +975,7 @@ describe('chromium features', () => {
|
|
|
// This is context (2), a WebView which will call window.open()
|
|
|
const webview = new WebView()
|
|
|
webview.setAttribute('nodeintegration', '${nodeIntegration ? 'on' : 'off'}')
|
|
|
- webview.setAttribute('webpreferences', 'nativeWindowOpen=${nativeWindowOpen ? 'yes' : 'no'}')
|
|
|
+ webview.setAttribute('webpreferences', 'nativeWindowOpen=${nativeWindowOpen ? 'yes' : 'no'},contextIsolation=no')
|
|
|
webview.setAttribute('allowpopups', 'on')
|
|
|
webview.src = ${JSON.stringify(parent + '?p=' + encodeURIComponent(child))}
|
|
|
webview.addEventListener('dom-ready', async () => {
|
|
@@ -1011,7 +1019,8 @@ describe('chromium features', () => {
|
|
|
|
|
|
beforeEach(() => {
|
|
|
contents = (webContents as any).create({
|
|
|
- nodeIntegration: true
|
|
|
+ nodeIntegration: true,
|
|
|
+ contextIsolation: false
|
|
|
});
|
|
|
});
|
|
|
|
|
@@ -1143,7 +1152,8 @@ describe('chromium features', () => {
|
|
|
it('default value allows websql', async () => {
|
|
|
contents = (webContents as any).create({
|
|
|
session: sqlSession,
|
|
|
- nodeIntegration: true
|
|
|
+ nodeIntegration: true,
|
|
|
+ contextIsolation: false
|
|
|
});
|
|
|
contents.loadURL(origin);
|
|
|
const [, error] = await emittedOnce(ipcMain, 'web-sql-response');
|
|
@@ -1154,7 +1164,8 @@ describe('chromium features', () => {
|
|
|
contents = (webContents as any).create({
|
|
|
session: sqlSession,
|
|
|
nodeIntegration: true,
|
|
|
- enableWebSQL: false
|
|
|
+ enableWebSQL: false,
|
|
|
+ contextIsolation: false
|
|
|
});
|
|
|
contents.loadURL(origin);
|
|
|
const [, error] = await emittedOnce(ipcMain, 'web-sql-response');
|
|
@@ -1165,7 +1176,8 @@ describe('chromium features', () => {
|
|
|
contents = (webContents as any).create({
|
|
|
session: sqlSession,
|
|
|
nodeIntegration: true,
|
|
|
- enableWebSQL: false
|
|
|
+ enableWebSQL: false,
|
|
|
+ contextIsolation: false
|
|
|
});
|
|
|
contents.loadURL(origin);
|
|
|
const [, error] = await emittedOnce(ipcMain, 'web-sql-response');
|
|
@@ -1194,7 +1206,8 @@ describe('chromium features', () => {
|
|
|
webPreferences: {
|
|
|
nodeIntegration: true,
|
|
|
webviewTag: true,
|
|
|
- session: sqlSession
|
|
|
+ session: sqlSession,
|
|
|
+ contextIsolation: false
|
|
|
}
|
|
|
});
|
|
|
w.webContents.loadURL(origin);
|
|
@@ -1205,7 +1218,7 @@ describe('chromium features', () => {
|
|
|
new Promise((resolve, reject) => {
|
|
|
const webview = new WebView();
|
|
|
webview.setAttribute('src', '${origin}');
|
|
|
- webview.setAttribute('webpreferences', 'enableWebSQL=0');
|
|
|
+ webview.setAttribute('webpreferences', 'enableWebSQL=0,contextIsolation=no');
|
|
|
webview.setAttribute('partition', '${sqlPartition}');
|
|
|
webview.setAttribute('nodeIntegration', 'on');
|
|
|
document.body.appendChild(webview);
|
|
@@ -1223,7 +1236,8 @@ describe('chromium features', () => {
|
|
|
nodeIntegration: true,
|
|
|
enableWebSQL: false,
|
|
|
webviewTag: true,
|
|
|
- session: sqlSession
|
|
|
+ session: sqlSession,
|
|
|
+ contextIsolation: false
|
|
|
}
|
|
|
});
|
|
|
w.webContents.loadURL('data:text/html,<html></html>');
|
|
@@ -1232,7 +1246,7 @@ describe('chromium features', () => {
|
|
|
new Promise((resolve, reject) => {
|
|
|
const webview = new WebView();
|
|
|
webview.setAttribute('src', '${origin}');
|
|
|
- webview.setAttribute('webpreferences', 'enableWebSQL=1');
|
|
|
+ webview.setAttribute('webpreferences', 'enableWebSQL=1,contextIsolation=no');
|
|
|
webview.setAttribute('partition', '${sqlPartition}');
|
|
|
webview.setAttribute('nodeIntegration', 'on');
|
|
|
document.body.appendChild(webview);
|
|
@@ -1249,7 +1263,8 @@ describe('chromium features', () => {
|
|
|
webPreferences: {
|
|
|
nodeIntegration: true,
|
|
|
webviewTag: true,
|
|
|
- session: sqlSession
|
|
|
+ session: sqlSession,
|
|
|
+ contextIsolation: false
|
|
|
}
|
|
|
});
|
|
|
w.webContents.loadURL(origin);
|
|
@@ -1260,7 +1275,7 @@ describe('chromium features', () => {
|
|
|
new Promise((resolve, reject) => {
|
|
|
const webview = new WebView();
|
|
|
webview.setAttribute('src', '${origin}');
|
|
|
- webview.setAttribute('webpreferences', 'enableWebSQL=1');
|
|
|
+ webview.setAttribute('webpreferences', 'enableWebSQL=1,contextIsolation=no');
|
|
|
webview.setAttribute('partition', '${sqlPartition}');
|
|
|
webview.setAttribute('nodeIntegration', 'on');
|
|
|
document.body.appendChild(webview);
|
|
@@ -1404,7 +1419,8 @@ describe('iframe using HTML fullscreen API while window is OS-fullscreened', ()
|
|
|
fullscreen: true,
|
|
|
webPreferences: {
|
|
|
nodeIntegration: true,
|
|
|
- nodeIntegrationInSubFrames: true
|
|
|
+ nodeIntegrationInSubFrames: true,
|
|
|
+ contextIsolation: false
|
|
|
}
|
|
|
});
|
|
|
});
|