|
@@ -1,7 +1,7 @@
|
|
|
import { expect } from 'chai';
|
|
|
import * as childProcess from 'child_process';
|
|
|
import * as path from 'path';
|
|
|
-import { BrowserWindow, MessageChannelMain, utilityProcess } from 'electron/main';
|
|
|
+import { BrowserWindow, MessageChannelMain, utilityProcess, app } from 'electron/main';
|
|
|
import { ifit } from './lib/spec-helpers';
|
|
|
import { closeWindow } from './lib/window-helpers';
|
|
|
import { once } from 'events';
|
|
@@ -86,6 +86,26 @@ describe('utilityProcess module', () => {
|
|
|
});
|
|
|
});
|
|
|
|
|
|
+ describe('app \'child-process-gone\' event', () => {
|
|
|
+ it('with default serviceName', async () => {
|
|
|
+ utilityProcess.fork(path.join(fixturesPath, 'crash.js'));
|
|
|
+ const [, details] = await once(app, 'child-process-gone') as [any, Electron.Details];
|
|
|
+ expect(details.type).to.equal('Utility');
|
|
|
+ expect(details.serviceName).to.equal('node.mojom.NodeService');
|
|
|
+ expect(details.name).to.equal('Node Utility Process');
|
|
|
+ expect(details.reason).to.be.oneOf(['crashed', 'abnormal-exit']);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('with custom serviceName', async () => {
|
|
|
+ utilityProcess.fork(path.join(fixturesPath, 'crash.js'), [], { serviceName: 'Hello World!' });
|
|
|
+ const [, details] = await once(app, 'child-process-gone') as [any, Electron.Details];
|
|
|
+ expect(details.type).to.equal('Utility');
|
|
|
+ expect(details.serviceName).to.equal('node.mojom.NodeService');
|
|
|
+ expect(details.name).to.equal('Hello World!');
|
|
|
+ expect(details.reason).to.be.oneOf(['crashed', 'abnormal-exit']);
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
describe('kill() API', () => {
|
|
|
it('terminates the child process gracefully', async () => {
|
|
|
const child = utilityProcess.fork(path.join(fixturesPath, 'endless.js'), [], {
|