fix: update shell.openExternal to correctly focus on external window (#44408)

* fix: Use openURL:configuration:completionHandler instead of openUrl

* test: add a test

* fix: add dispatch_async to replace GetUIThreadTaskRunner

* refactor: remove unused import

* fix: update to use BindPostTaskToCurrentDefault

* test: add regression test for window focus

* refactor: update to explicit task runner
This commit is contained in:
Alice Zhao 2024-10-29 15:10:10 -07:00 committed by GitHub
parent 7ff7160135
commit de04fc3b90
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 36 additions and 4 deletions

View file

@ -76,6 +76,21 @@ describe('shell module', () => {
requestReceived
]);
});
ifit(process.platform === 'darwin')('removes focus from the electron window after opening an external link', async () => {
const url = 'http://127.0.0.1';
const w = new BrowserWindow({ show: true });
await once(w, 'focus');
expect(w.isFocused()).to.be.true();
await Promise.all<void>([
shell.openExternal(url),
once(w, 'blur') as Promise<any>
]);
expect(w.isFocused()).to.be.false();
});
});
describe('shell.trashItem()', () => {