fix: EventEmitter is missing properties in sandbox preload script. (#35522)
This commit is contained in:
parent
30bdede09f
commit
532162d2b5
3 changed files with 32 additions and 0 deletions
|
@ -45,6 +45,7 @@
|
|||
"eslint-plugin-node": "^11.1.0",
|
||||
"eslint-plugin-standard": "^4.0.1",
|
||||
"eslint-plugin-typescript": "^0.14.0",
|
||||
"events": "^3.2.0",
|
||||
"express": "^4.16.4",
|
||||
"folder-hash": "^2.1.1",
|
||||
"fs-extra": "^9.0.1",
|
||||
|
|
|
@ -2970,6 +2970,26 @@ describe('BrowserWindow module', () => {
|
|||
expect(url).to.equal(expectedUrl);
|
||||
});
|
||||
|
||||
it('exposes full EventEmitter object to preload script', async () => {
|
||||
const w = new BrowserWindow({
|
||||
show: false,
|
||||
webPreferences: {
|
||||
sandbox: true,
|
||||
preload: path.join(fixtures, 'module', 'preload-eventemitter.js')
|
||||
}
|
||||
});
|
||||
w.loadURL('about:blank');
|
||||
const [, rendererEventEmitterProperties] = await emittedOnce(ipcMain, 'answer');
|
||||
const { EventEmitter } = require('events');
|
||||
const emitter = new EventEmitter();
|
||||
const browserEventEmitterProperties = [];
|
||||
let currentObj = emitter;
|
||||
do {
|
||||
browserEventEmitterProperties.push(...Object.getOwnPropertyNames(currentObj));
|
||||
} while ((currentObj = Object.getPrototypeOf(currentObj)));
|
||||
expect(rendererEventEmitterProperties).to.deep.equal(browserEventEmitterProperties);
|
||||
});
|
||||
|
||||
it('should open windows in same domain with cross-scripting enabled', async () => {
|
||||
const w = new BrowserWindow({
|
||||
show: true,
|
||||
|
|
11
spec/fixtures/module/preload-eventemitter.js
vendored
Normal file
11
spec/fixtures/module/preload-eventemitter.js
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
(function () {
|
||||
const { EventEmitter } = require('events');
|
||||
const emitter = new EventEmitter();
|
||||
const rendererEventEmitterProperties = [];
|
||||
let currentObj = emitter;
|
||||
do {
|
||||
rendererEventEmitterProperties.push(...Object.getOwnPropertyNames(currentObj));
|
||||
} while ((currentObj = Object.getPrototypeOf(currentObj)));
|
||||
const { ipcRenderer } = require('electron');
|
||||
ipcRenderer.send('answer', rendererEventEmitterProperties);
|
||||
})();
|
Loading…
Reference in a new issue