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:
parent
3d139fc424
commit
3e92b72aef
7 changed files with 29 additions and 5 deletions
|
@ -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({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue