feat: expose system preferences to utility process (#42598)

* chore: expose  system preferences to utility process

* chore: add tests, doc changes and module-list update

* relative link

* use @

* fix test

* chore: disable linux test

* kick

* noop on windows utility process

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: George Xu <33054982+georgexu99@users.noreply.github.com>
This commit is contained in:
trop[bot] 2024-06-20 15:33:21 -04:00 committed by GitHub
parent 3d139fc424
commit 3e92b72aef
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 29 additions and 5 deletions

View file

@ -7,6 +7,7 @@ import { closeWindow } from './lib/window-helpers';
import { once } from 'node:events';
import { pathToFileURL } from 'node:url';
import { setImmediate } from 'node:timers/promises';
import { systemPreferences } from 'electron';
const fixturesPath = path.resolve(__dirname, 'fixtures', 'api', 'utility-process');
const isWindowsOnArm = process.platform === 'win32' && process.arch === 'arm64';
@ -404,6 +405,18 @@ describe('utilityProcess module', () => {
expect(output).to.include(result);
});
ifit(process.platform !== 'linux')('can access exposed main process modules from the utility process', async () => {
const message = 'Message from utility process';
const child = utilityProcess.fork(path.join(fixturesPath, 'expose-main-process-module.js'));
await once(child, 'spawn');
child.postMessage(message);
const [data] = await once(child, 'message');
expect(data).to.equal(systemPreferences.getMediaAccessStatus('screen'));
const exit = once(child, 'exit');
expect(child.kill()).to.be.true();
await exit;
});
it('can establish communication channel with sandboxed renderer', async () => {
const result = 'Message from sandboxed renderer';
const w = new BrowserWindow({