import { expect } from 'chai'; import { BrowserWindow, WebContents, session, ipcMain, app, protocol, webContents } from 'electron/main'; import { emittedOnce } from './events-helpers'; import { closeAllWindows } from './window-helpers'; import * as https from 'https'; import * as http from 'http'; import * as path from 'path'; import * as fs from 'fs'; import * as url from 'url'; import * as ChildProcess from 'child_process'; import { EventEmitter } from 'events'; import { promisify } from 'util'; import { ifit, ifdescribe, delay, defer } from './spec-helpers'; import { AddressInfo } from 'net'; import { PipeTransport } from './pipe-transport'; const features = process._linkedBinding('electron_common_features'); const fixturesPath = path.resolve(__dirname, '..', 'spec', 'fixtures'); describe('reporting api', () => { it('sends a report for a deprecation', async () => { const reports = new EventEmitter(); // The Reporting API only works on https with valid certs. To dodge having // to set up a trusted certificate, hack the validator. session.defaultSession.setCertificateVerifyProc((req, cb) => { cb(0); }); const certPath = path.join(fixturesPath, 'certificates'); const options = { key: fs.readFileSync(path.join(certPath, 'server.key')), cert: fs.readFileSync(path.join(certPath, 'server.pem')), ca: [ fs.readFileSync(path.join(certPath, 'rootCA.pem')), fs.readFileSync(path.join(certPath, 'intermediateCA.pem')) ], requestCert: true, rejectUnauthorized: false }; const server = https.createServer(options, (req, res) => { if (req.url === '/report') { let data = ''; req.on('data', (d) => { data += d.toString('utf-8'); }); req.on('end', () => { reports.emit('report', JSON.parse(data)); }); } res.setHeader('Report-To', JSON.stringify({ group: 'default', max_age: 120, endpoints: [{ url: `https://localhost:${(server.address() as any).port}/report` }] })); res.setHeader('Content-Type', 'text/html'); // using the deprecated `webkitRequestAnimationFrame` will trigger a // "deprecation" report. res.end(''); }); await new Promise(resolve => server.listen(0, '127.0.0.1', resolve)); const bw = new BrowserWindow({ show: false }); try { const reportGenerated = emittedOnce(reports, 'report'); const url = `https://localhost:${(server.address() as any).port}/a`; await bw.loadURL(url); const [report] = await reportGenerated; expect(report).to.be.an('array'); expect(report[0].type).to.equal('deprecation'); expect(report[0].url).to.equal(url); expect(report[0].body.id).to.equal('PrefixedRequestAnimationFrame'); } finally { bw.destroy(); server.close(); } }); }); describe('window.postMessage', () => { afterEach(async () => { await closeAllWindows(); }); it('sets the source and origin correctly', async () => { const w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true } }); w.loadURL(`file://${fixturesPath}/pages/window-open-postMessage-driver.html`); const [, message] = await emittedOnce(ipcMain, 'complete'); expect(message.data).to.equal('testing'); expect(message.origin).to.equal('file://'); expect(message.sourceEqualsOpener).to.equal(true); expect(message.eventOrigin).to.equal('file://'); }); }); describe('focus handling', () => { let webviewContents: WebContents = null as unknown as WebContents; let w: BrowserWindow = null as unknown as BrowserWindow; beforeEach(async () => { w = new BrowserWindow({ show: true, webPreferences: { nodeIntegration: true, webviewTag: true } }); const webviewReady = emittedOnce(w.webContents, 'did-attach-webview'); await w.loadFile(path.join(fixturesPath, 'pages', 'tab-focus-loop-elements.html')); const [, wvContents] = await webviewReady; webviewContents = wvContents; await emittedOnce(webviewContents, 'did-finish-load'); w.focus(); }); afterEach(() => { webviewContents = null as unknown as WebContents; w.destroy(); w = null as unknown as BrowserWindow; }); const expectFocusChange = async () => { const [, focusedElementId] = await emittedOnce(ipcMain, 'focus-changed'); return focusedElementId; }; describe('a TAB press', () => { const tabPressEvent: any = { type: 'keyDown', keyCode: 'Tab' }; it('moves focus to the next focusable item', async () => { let focusChange = expectFocusChange(); w.webContents.sendInputEvent(tabPressEvent); let focusedElementId = await focusChange; expect(focusedElementId).to.equal('BUTTON-element-1', `should start focused in element-1, it's instead in ${focusedElementId}`); focusChange = expectFocusChange(); w.webContents.sendInputEvent(tabPressEvent); focusedElementId = await focusChange; expect(focusedElementId).to.equal('BUTTON-element-2', `focus should've moved to element-2, it's instead in ${focusedElementId}`); focusChange = expectFocusChange(); w.webContents.sendInputEvent(tabPressEvent); focusedElementId = await focusChange; expect(focusedElementId).to.equal('BUTTON-wv-element-1', `focus should've moved to the webview's element-1, it's instead in ${focusedElementId}`); focusChange = expectFocusChange(); webviewContents.sendInputEvent(tabPressEvent); focusedElementId = await focusChange; expect(focusedElementId).to.equal('BUTTON-wv-element-2', `focus should've moved to the webview's element-2, it's instead in ${focusedElementId}`); focusChange = expectFocusChange(); webviewContents.sendInputEvent(tabPressEvent); focusedElementId = await focusChange; expect(focusedElementId).to.equal('BUTTON-element-3', `focus should've moved to element-3, it's instead in ${focusedElementId}`); focusChange = expectFocusChange(); w.webContents.sendInputEvent(tabPressEvent); focusedElementId = await focusChange; expect(focusedElementId).to.equal('BUTTON-element-1', `focus should've looped back to element-1, it's instead in ${focusedElementId}`); }); }); describe('a SHIFT + TAB press', () => { const shiftTabPressEvent: any = { type: 'keyDown', modifiers: ['Shift'], keyCode: 'Tab' }; it('moves focus to the previous focusable item', async () => { let focusChange = expectFocusChange(); w.webContents.sendInputEvent(shiftTabPressEvent); let focusedElementId = await focusChange; expect(focusedElementId).to.equal('BUTTON-element-3', `should start focused in element-3, it's instead in ${focusedElementId}`); focusChange = expectFocusChange(); w.webContents.sendInputEvent(shiftTabPressEvent); focusedElementId = await focusChange; expect(focusedElementId).to.equal('BUTTON-wv-element-2', `focus should've moved to the webview's element-2, it's instead in ${focusedElementId}`); focusChange = expectFocusChange(); webviewContents.sendInputEvent(shiftTabPressEvent); focusedElementId = await focusChange; expect(focusedElementId).to.equal('BUTTON-wv-element-1', `focus should've moved to the webview's element-1, it's instead in ${focusedElementId}`); focusChange = expectFocusChange(); webviewContents.sendInputEvent(shiftTabPressEvent); focusedElementId = await focusChange; expect(focusedElementId).to.equal('BUTTON-element-2', `focus should've moved to element-2, it's instead in ${focusedElementId}`); focusChange = expectFocusChange(); w.webContents.sendInputEvent(shiftTabPressEvent); focusedElementId = await focusChange; expect(focusedElementId).to.equal('BUTTON-element-1', `focus should've moved to element-1, it's instead in ${focusedElementId}`); focusChange = expectFocusChange(); w.webContents.sendInputEvent(shiftTabPressEvent); focusedElementId = await focusChange; expect(focusedElementId).to.equal('BUTTON-element-3', `focus should've looped back to element-3, it's instead in ${focusedElementId}`); }); }); }); describe('web security', () => { afterEach(closeAllWindows); let server: http.Server; let serverUrl: string; before(async () => { server = http.createServer((req, res) => { res.setHeader('Content-Type', 'text/html'); res.end('
'); }); await new Promise(resolve => server.listen(0, '127.0.0.1', resolve)); serverUrl = `http://localhost:${(server.address() as any).port}`; }); after(() => { server.close(); }); it('engages CORB when web security is not disabled', async () => { const w = new BrowserWindow({ show: true, webPreferences: { webSecurity: true, nodeIntegration: true } }); const p = emittedOnce(ipcMain, 'success'); await w.loadURL(`data:text/html,`); await p; }); it('bypasses CORB when web security is disabled', async () => { const w = new BrowserWindow({ show: true, webPreferences: { webSecurity: false, nodeIntegration: true } }); const p = emittedOnce(ipcMain, 'success'); await w.loadURL(`data:text/html, `); await p; }); it('does not crash when multiple WebContent are created with web security disabled', () => { const options = { webPreferences: { webSecurity: false } }; const w1 = new BrowserWindow(options); w1.loadURL(serverUrl); const w2 = new BrowserWindow(options); w2.loadURL(serverUrl); }); }); describe('command line switches', () => { let appProcess: ChildProcess.ChildProcessWithoutNullStreams | undefined; afterEach(() => { if (appProcess && !appProcess.killed) { appProcess.kill(); appProcess = undefined; } }); describe('--lang switch', () => { const currentLocale = app.getLocale(); const testLocale = async (locale: string, result: string) => { const appPath = path.join(fixturesPath, 'api', 'locale-check'); const electronPath = process.execPath; appProcess = ChildProcess.spawn(electronPath, [appPath, `--lang=${locale}`]); let output = ''; appProcess.stdout.on('data', (data) => { output += data; }); await emittedOnce(appProcess.stdout, 'end'); output = output.replace(/(\r\n|\n|\r)/gm, ''); expect(output).to.equal(result); }; it('should set the locale', async () => testLocale('fr', 'fr')); it('should not set an invalid locale', async () => testLocale('asdfkl', currentLocale)); }); describe('--remote-debugging-pipe switch', () => { it('should expose CDP via pipe', async () => { const electronPath = process.execPath; appProcess = ChildProcess.spawn(electronPath, ['--remote-debugging-pipe'], { stdio: ['pipe', 'pipe', 'pipe', 'pipe', 'pipe'] }); const stdio = appProcess.stdio as unknown as [NodeJS.ReadableStream, NodeJS.WritableStream, NodeJS.WritableStream, NodeJS.WritableStream, NodeJS.ReadableStream]; const pipe = new PipeTransport(stdio[3], stdio[4]); const versionPromise = new Promise(resolve => { pipe.onmessage = resolve; }); pipe.send({ id: 1, method: 'Browser.getVersion', params: {} }); const message = (await versionPromise) as any; expect(message.id).to.equal(1); expect(message.result.product).to.contain('Chrome'); expect(message.result.userAgent).to.contain('Electron'); }); it('should override --remote-debugging-port switch', async () => { const electronPath = process.execPath; appProcess = ChildProcess.spawn(electronPath, ['--remote-debugging-pipe', '--remote-debugging-port=0'], { stdio: ['pipe', 'pipe', 'pipe', 'pipe', 'pipe'] }); let stderr = ''; appProcess.stderr.on('data', (data: string) => { stderr += data; }); const stdio = appProcess.stdio as unknown as [NodeJS.ReadableStream, NodeJS.WritableStream, NodeJS.WritableStream, NodeJS.WritableStream, NodeJS.ReadableStream]; const pipe = new PipeTransport(stdio[3], stdio[4]); const versionPromise = new Promise(resolve => { pipe.onmessage = resolve; }); pipe.send({ id: 1, method: 'Browser.getVersion', params: {} }); const message = (await versionPromise) as any; expect(message.id).to.equal(1); expect(stderr).to.not.include('DevTools listening on'); }); it('should shut down Electron upon Browser.close CDP command', async () => { const electronPath = process.execPath; appProcess = ChildProcess.spawn(electronPath, ['--remote-debugging-pipe'], { stdio: ['pipe', 'pipe', 'pipe', 'pipe', 'pipe'] }); const stdio = appProcess.stdio as unknown as [NodeJS.ReadableStream, NodeJS.WritableStream, NodeJS.WritableStream, NodeJS.WritableStream, NodeJS.ReadableStream]; const pipe = new PipeTransport(stdio[3], stdio[4]); pipe.send({ id: 1, method: 'Browser.close', params: {} }); await new Promise(resolve => { appProcess!.on('exit', resolve); }); }); }); describe('--remote-debugging-port switch', () => { it('should display the discovery page', (done) => { const electronPath = process.execPath; let output = ''; appProcess = ChildProcess.spawn(electronPath, ['--remote-debugging-port=']); appProcess.stderr.on('data', (data) => { output += data; const m = /DevTools listening on ws:\/\/127.0.0.1:(\d+)\//.exec(output); if (m) { appProcess!.stderr.removeAllListeners('data'); const port = m[1]; http.get(`http://127.0.0.1:${port}`, (res) => { try { expect(res.statusCode).to.eql(200); expect(parseInt(res.headers['content-length']!)).to.be.greaterThan(0); done(); } catch (e) { done(e); } finally { res.destroy(); } }); } }); }); }); }); describe('chromium features', () => { afterEach(closeAllWindows); describe('accessing key names also used as Node.js module names', () => { it('does not crash', (done) => { const w = new BrowserWindow({ show: false }); w.webContents.once('did-finish-load', () => { done(); }); w.webContents.once('crashed', () => done(new Error('WebContents crashed.'))); w.loadFile(path.join(fixturesPath, 'pages', 'external-string.html')); }); }); describe('loading jquery', () => { it('does not crash', (done) => { const w = new BrowserWindow({ show: false }); w.webContents.once('did-finish-load', () => { done(); }); w.webContents.once('crashed', () => done(new Error('WebContents crashed.'))); w.loadFile(path.join(__dirname, 'fixtures', 'pages', 'jquery.html')); }); }); describe('navigator.languages', () => { it('should return the system locale only', async () => { const appLocale = app.getLocale(); const w = new BrowserWindow({ show: false }); await w.loadURL('about:blank'); const languages = await w.webContents.executeJavaScript('navigator.languages'); expect(languages.length).to.be.greaterThan(0); expect(languages).to.contain(appLocale); }); }); describe('navigator.serviceWorker', () => { it('should register for file scheme', (done) => { const w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true, partition: 'sw-file-scheme-spec' } }); w.webContents.on('ipc-message', (event, channel, message) => { if (channel === 'reload') { w.webContents.reload(); } else if (channel === 'error') { done(message); } else if (channel === 'response') { expect(message).to.equal('Hello from serviceWorker!'); session.fromPartition('sw-file-scheme-spec').clearStorageData({ storages: ['serviceworkers'] }).then(() => done()); } }); w.webContents.on('crashed', () => done(new Error('WebContents crashed.'))); w.loadFile(path.join(fixturesPath, 'pages', 'service-worker', 'index.html')); }); it('should register for intercepted file scheme', (done) => { const customSession = session.fromPartition('intercept-file'); customSession.protocol.interceptBufferProtocol('file', (request, callback) => { let file = url.parse(request.url).pathname!; if (file[0] === '/' && process.platform === 'win32') file = file.slice(1); const content = fs.readFileSync(path.normalize(file)); const ext = path.extname(file); let type = 'text/html'; if (ext === '.js') type = 'application/javascript'; callback({ data: content, mimeType: type } as any); }); const w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true, session: customSession } }); w.webContents.on('ipc-message', (event, channel, message) => { if (channel === 'reload') { w.webContents.reload(); } else if (channel === 'error') { done(`unexpected error : ${message}`); } else if (channel === 'response') { expect(message).to.equal('Hello from serviceWorker!'); customSession.clearStorageData({ storages: ['serviceworkers'] }).then(() => { customSession.protocol.uninterceptProtocol('file'); done(); }); } }); w.webContents.on('crashed', () => done(new Error('WebContents crashed.'))); w.loadFile(path.join(fixturesPath, 'pages', 'service-worker', 'index.html')); }); it('should not crash when nodeIntegration is enabled', (done) => { const w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true, nodeIntegrationInWorker: true, partition: 'sw-file-scheme-worker-spec' } }); w.webContents.on('ipc-message', (event, channel, message) => { if (channel === 'reload') { w.webContents.reload(); } else if (channel === 'error') { done(`unexpected error : ${message}`); } else if (channel === 'response') { expect(message).to.equal('Hello from serviceWorker!'); session.fromPartition('sw-file-scheme-worker-spec').clearStorageData({ storages: ['serviceworkers'] }).then(() => done()); } }); w.webContents.on('crashed', () => done(new Error('WebContents crashed.'))); w.loadFile(path.join(fixturesPath, 'pages', 'service-worker', 'index.html')); }); }); describe('navigator.geolocation', () => { before(function () { if (!features.isFakeLocationProviderEnabled()) { return this.skip(); } }); it('returns error when permission is denied', async () => { const w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true, partition: 'geolocation-spec' } }); const message = emittedOnce(w.webContents, 'ipc-message'); w.webContents.session.setPermissionRequestHandler((wc, permission, callback) => { if (permission === 'geolocation') { callback(false); } else { callback(true); } }); w.loadFile(path.join(fixturesPath, 'pages', 'geolocation', 'index.html')); const [, channel] = await message; expect(channel).to.equal('success', 'unexpected response from geolocation api'); }); }); describe('form submit', () => { let server: http.Server; let serverUrl: string; before(async () => { server = http.createServer((req, res) => { let body = ''; req.on('data', (chunk) => { body += chunk; }); res.setHeader('Content-Type', 'application/json'); req.on('end', () => { res.end(`body:${body}`); }); }); await new Promise(resolve => server.listen(0, '127.0.0.1', resolve)); serverUrl = `http://localhost:${(server.address() as any).port}`; }); after(async () => { server.close(); await closeAllWindows(); }); [true, false].forEach((isSandboxEnabled) => describe(`sandbox=${isSandboxEnabled}`, () => { it('posts data in the same window', async () => { const w = new BrowserWindow({ show: false, webPreferences: { sandbox: isSandboxEnabled } }); await w.loadFile(path.join(fixturesPath, 'pages', 'form-with-data.html')); const loadPromise = emittedOnce(w.webContents, 'did-finish-load'); w.webContents.executeJavaScript(` const form = document.querySelector('form') form.action = '${serverUrl}'; form.submit(); `); await loadPromise; const res = await w.webContents.executeJavaScript('document.body.innerText'); expect(res).to.equal('body:greeting=hello'); }); it('posts data to a new window with target=_blank', async () => { const w = new BrowserWindow({ show: false, webPreferences: { sandbox: isSandboxEnabled } }); await w.loadFile(path.join(fixturesPath, 'pages', 'form-with-data.html')); const windowCreatedPromise = emittedOnce(app, 'browser-window-created'); w.webContents.executeJavaScript(` const form = document.querySelector('form') form.action = '${serverUrl}'; form.target = '_blank'; form.submit(); `); const [, newWin] = await windowCreatedPromise; const res = await newWin.webContents.executeJavaScript('document.body.innerText'); expect(res).to.equal('body:greeting=hello'); }); }) ); }); describe('window.open', () => { for (const show of [true, false]) { it(`inherits parent visibility over parent {show=${show}} option`, async () => { const w = new BrowserWindow({ show }); // toggle visibility if (show) { w.hide(); } else { w.show(); } defer(() => { w.close(); }); const newWindow = emittedOnce(w.webContents, 'new-window'); w.loadFile(path.join(fixturesPath, 'pages', 'window-open.html')); const [,,,, options] = await newWindow; expect(options.show).to.equal(w.isVisible()); }); } it('disables node integration when it is disabled on the parent window for chrome devtools URLs', async () => { 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') `); const [, contents] = await emittedOnce(app, 'web-contents-created'); const typeofProcessGlobal = await contents.executeJavaScript('typeof process'); expect(typeofProcessGlobal).to.equal('undefined'); }); it('disables JavaScript when it is disabled on the parent window', async () => { const w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true } }); w.webContents.loadURL('about:blank'); const windowUrl = require('url').format({ pathname: `${fixturesPath}/pages/window-no-javascript.html`, protocol: 'file', slashes: true }); w.webContents.executeJavaScript(` b = window.open(${JSON.stringify(windowUrl)}, '', 'javascript=no,show=no') `); const [, contents] = await emittedOnce(app, 'web-contents-created'); await emittedOnce(contents, 'did-finish-load'); // Click link on page contents.sendInputEvent({ type: 'mouseDown', clickCount: 1, x: 1, y: 1 }); contents.sendInputEvent({ type: 'mouseUp', clickCount: 1, x: 1, y: 1 }); const [, window] = await emittedOnce(app, 'browser-window-created'); const preferences = window.webContents.getLastWebPreferences(); expect(preferences.javascript).to.be.false(); }); it('handles cycles when merging the parent options into the child options', async () => { const foo = {} as any; foo.bar = foo; foo.baz = { hello: { world: true } }; foo.baz2 = foo.baz; const w = new BrowserWindow({ show: false, foo: foo } as any); w.loadFile(path.join(fixturesPath, 'pages', 'window-open.html')); const [,,,, options] = await emittedOnce(w.webContents, 'new-window'); expect(options.show).to.be.false(); expect((options as any).foo).to.deep.equal({ bar: undefined, baz: { hello: { world: true } }, baz2: { hello: { world: true } } }); }); it('defines a window.location getter', async () => { let targetURL: string; if (process.platform === 'win32') { targetURL = `file:///${fixturesPath.replace(/\\/g, '/')}/pages/base-page.html`; } else { targetURL = `file://${fixturesPath}/pages/base-page.html`; } const w = new BrowserWindow({ show: false }); w.loadURL('about:blank'); w.webContents.executeJavaScript(`{ b = window.open(${JSON.stringify(targetURL)}); null }`); const [, window] = await emittedOnce(app, 'browser-window-created'); await emittedOnce(window.webContents, 'did-finish-load'); expect(await w.webContents.executeJavaScript('b.location.href')).to.equal(targetURL); }); it('defines a window.location setter', async () => { const w = new BrowserWindow({ show: false }); w.loadURL('about:blank'); w.webContents.executeJavaScript('{ b = window.open("about:blank"); null }'); const [, { webContents }] = await emittedOnce(app, 'browser-window-created'); await emittedOnce(webContents, 'did-finish-load'); // When it loads, redirect w.webContents.executeJavaScript(`{ b.location = ${JSON.stringify(`file://${fixturesPath}/pages/base-page.html`)}; null }`); await emittedOnce(webContents, 'did-finish-load'); }); it('defines a window.location.href setter', async () => { const w = new BrowserWindow({ show: false }); w.loadURL('about:blank'); w.webContents.executeJavaScript('{ b = window.open("about:blank"); null }'); const [, { webContents }] = await emittedOnce(app, 'browser-window-created'); await emittedOnce(webContents, 'did-finish-load'); // When it loads, redirect w.webContents.executeJavaScript(`{ b.location.href = ${JSON.stringify(`file://${fixturesPath}/pages/base-page.html`)}; null }`); await emittedOnce(webContents, 'did-finish-load'); }); it('open a blank page when no URL is specified', async () => { const w = new BrowserWindow({ show: false }); w.loadURL('about:blank'); w.webContents.executeJavaScript('{ b = window.open(); null }'); const [, { webContents }] = await emittedOnce(app, 'browser-window-created'); await emittedOnce(webContents, 'did-finish-load'); expect(await w.webContents.executeJavaScript('b.location.href')).to.equal('about:blank'); }); it('open a blank page when an empty URL is specified', async () => { const w = new BrowserWindow({ show: false }); w.loadURL('about:blank'); w.webContents.executeJavaScript('{ b = window.open(\'\'); null }'); const [, { webContents }] = await emittedOnce(app, 'browser-window-created'); await emittedOnce(webContents, 'did-finish-load'); expect(await w.webContents.executeJavaScript('b.location.href')).to.equal('about:blank'); }); it('sets the window title to the specified frameName', async () => { const w = new BrowserWindow({ show: false }); w.loadURL('about:blank'); w.webContents.executeJavaScript('{ b = window.open(\'\', \'hello\'); null }'); const [, window] = await emittedOnce(app, 'browser-window-created'); expect(window.getTitle()).to.equal('hello'); }); it('does not throw an exception when the frameName is a built-in object property', async () => { const w = new BrowserWindow({ show: false }); w.loadURL('about:blank'); w.webContents.executeJavaScript('{ b = window.open(\'\', \'__proto__\'); null }'); const [, window] = await emittedOnce(app, 'browser-window-created'); expect(window.getTitle()).to.equal('__proto__'); }); it('denies custom open when nativeWindowOpen: true', async () => { const w = new BrowserWindow({ show: false, webPreferences: { contextIsolation: false, nodeIntegration: true, nativeWindowOpen: true } }); w.loadURL('about:blank'); const previousListeners = process.listeners('uncaughtException'); process.removeAllListeners('uncaughtException'); try { const uncaughtException = new Promise