forked from electron/electron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocess-binding-spec.ts
44 lines (37 loc) · 1.78 KB
/
process-binding-spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { expect } from 'chai';
import { BrowserWindow } from 'electron/main';
import { closeAllWindows } from './lib/window-helpers';
describe('process._linkedBinding', () => {
describe('in the main process', () => {
it('can access electron_browser bindings', () => {
process._linkedBinding('electron_browser_app');
});
it('can access electron_common bindings', () => {
process._linkedBinding('electron_common_v8_util');
});
it('cannot access electron_renderer bindings', () => {
expect(() => {
process._linkedBinding('electron_renderer_ipc');
}).to.throw(/No such binding was linked: electron_renderer_ipc/);
});
});
describe('in the renderer process', () => {
afterEach(closeAllWindows);
it('cannot access electron_browser bindings', async () => {
const w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true, contextIsolation: false } });
w.loadURL('about:blank');
await expect(w.webContents.executeJavaScript('void process._linkedBinding(\'electron_browser_app\')'))
.to.eventually.be.rejectedWith(/Script failed to execute/);
});
it('can access electron_common bindings', async () => {
const w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true, contextIsolation: false } });
w.loadURL('about:blank');
await w.webContents.executeJavaScript('void process._linkedBinding(\'electron_common_v8_util\')');
});
it('can access electron_renderer bindings', async () => {
const w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true, contextIsolation: false } });
w.loadURL('about:blank');
await w.webContents.executeJavaScript('void process._linkedBinding(\'electron_renderer_ipc\')');
});
});
});