fix: nativeImage.createThumbnailFromPath
and shell.openExternal
in renderer (#41875)
* fix: nativeImage.createThumbnailFromPath in renderer * also fix shell.openExternal
This commit is contained in:
parent
c4aeb17245
commit
ed9fec7da4
4 changed files with 60 additions and 34 deletions
|
@ -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()', () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue