|
@@ -5,6 +5,7 @@ import { BrowserWindow, MessageChannelMain, utilityProcess, app } from 'electron
|
|
|
import { ifit } from './lib/spec-helpers';
|
|
|
import { closeWindow } from './lib/window-helpers';
|
|
|
import { once } from 'events';
|
|
|
+import { setImmediate } from 'timers/promises';
|
|
|
|
|
|
const fixturesPath = path.resolve(__dirname, 'fixtures', 'api', 'utility-process');
|
|
|
const isWindowsOnArm = process.platform === 'win32' && process.arch === 'arm64';
|
|
@@ -114,6 +115,36 @@ describe('utilityProcess module', () => {
|
|
|
});
|
|
|
});
|
|
|
|
|
|
+ describe('app.getAppMetrics()', () => {
|
|
|
+ it('with default serviceName', async () => {
|
|
|
+ const child = utilityProcess.fork(path.join(fixturesPath, 'endless.js'));
|
|
|
+ await once(child, 'spawn');
|
|
|
+ expect(child.pid).to.not.be.null();
|
|
|
+
|
|
|
+ await setImmediate();
|
|
|
+
|
|
|
+ const details = app.getAppMetrics().find(item => item.pid === child.pid)!;
|
|
|
+ expect(details).to.be.an('object');
|
|
|
+ expect(details.type).to.equal('Utility');
|
|
|
+ expect(details.serviceName).to.to.equal('node.mojom.NodeService');
|
|
|
+ expect(details.name).to.equal('Node Utility Process');
|
|
|
+ });
|
|
|
+
|
|
|
+ it('with custom serviceName', async () => {
|
|
|
+ const child = utilityProcess.fork(path.join(fixturesPath, 'endless.js'), [], { serviceName: 'Hello World!' });
|
|
|
+ await once(child, 'spawn');
|
|
|
+ expect(child.pid).to.not.be.null();
|
|
|
+
|
|
|
+ await setImmediate();
|
|
|
+
|
|
|
+ const details = app.getAppMetrics().find(item => item.pid === child.pid)!;
|
|
|
+ expect(details).to.be.an('object');
|
|
|
+ expect(details.type).to.equal('Utility');
|
|
|
+ expect(details.serviceName).to.to.equal('node.mojom.NodeService');
|
|
|
+ expect(details.name).to.equal('Hello World!');
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
describe('kill() API', () => {
|
|
|
it('terminates the child process gracefully', async () => {
|
|
|
const child = utilityProcess.fork(path.join(fixturesPath, 'endless.js'), [], {
|