fix: nativeImage.createThumbnailFromPath and shell.openExternal in renderer (#41875)

* fix: nativeImage.createThumbnailFromPath in renderer

* also fix shell.openExternal
This commit is contained in:
Jeremy Rose 2024-04-19 06:43:01 -07:00 committed by GitHub
parent c4aeb17245
commit ed9fec7da4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 60 additions and 34 deletions

View file

@ -31,7 +31,7 @@ describe('shell module', () => {
});
afterEach(closeAllWindows);
it('opens an external link', async () => {
async function urlOpened () {
let url = 'http://127.0.0.1';
let requestReceived: Promise<any>;
if (process.platform === 'linux') {
@ -53,12 +53,26 @@ describe('shell module', () => {
url = (await listen(server)).url;
requestReceived = new Promise<void>(resolve => server.on('connection', () => resolve()));
}
return { url, requestReceived };
}
it('opens an external link', async () => {
const { url, requestReceived } = await urlOpened();
await Promise.all<void>([
shell.openExternal(url),
requestReceived
]);
});
it('opens an external link in the renderer', async () => {
const { url, requestReceived } = await urlOpened();
const w = new BrowserWindow({ show: false, webPreferences: { sandbox: false, contextIsolation: false, nodeIntegration: true } });
await w.loadURL('about:blank');
await Promise.all<void>([
w.webContents.executeJavaScript(`require("electron").shell.openExternal(${JSON.stringify(url)})`),
requestReceived
]);
});
});
describe('shell.trashItem()', () => {