refactor: make shell.OpenExternal async (#17135)
This commit is contained in:
parent
0755857a0c
commit
6d96f30ed3
16 changed files with 70 additions and 140 deletions
|
@ -198,7 +198,6 @@ describe('remote module', () => {
|
|||
assert.strictEqual(typeof remote.app.getPath, 'function')
|
||||
assert.strictEqual(typeof remote.webContents.getFocusedWebContents, 'function')
|
||||
assert.strictEqual(typeof remote.clipboard.readText, 'function')
|
||||
assert.strictEqual(typeof remote.shell.openExternalSync, 'function')
|
||||
})
|
||||
|
||||
it('returns toString() of original function via toString()', () => {
|
||||
|
|
|
@ -36,7 +36,7 @@ describe('shell module', () => {
|
|||
}
|
||||
})
|
||||
|
||||
it('opens an external link asynchronously', done => {
|
||||
it('opens an external link', done => {
|
||||
const url = 'http://www.example.com'
|
||||
if (process.platform === 'linux') {
|
||||
process.env.BROWSER = '/bin/true'
|
||||
|
@ -46,18 +46,6 @@ describe('shell module', () => {
|
|||
|
||||
shell.openExternal(url).then(() => done())
|
||||
})
|
||||
|
||||
it('opens an external link synchronously', () => {
|
||||
const url = 'http://www.example.com'
|
||||
if (process.platform === 'linux') {
|
||||
process.env.DE = 'generic'
|
||||
process.env.DE = '/bin/true'
|
||||
process.env.DISPLAY = ''
|
||||
}
|
||||
|
||||
const success = shell.openExternalSync(url)
|
||||
assert.strictEqual(true, success)
|
||||
})
|
||||
})
|
||||
|
||||
describe('shell.readShortcutLink(shortcutPath)', () => {
|
||||
|
|
|
@ -997,7 +997,7 @@ shell.moveItemToTrash('/home/user/Desktop/test.txt')
|
|||
|
||||
shell.openExternal('https://github.com', {
|
||||
activate: false
|
||||
})
|
||||
}).then(() => {})
|
||||
|
||||
shell.beep()
|
||||
|
||||
|
|
|
@ -218,7 +218,7 @@ app.on('ready', () => {
|
|||
// shell
|
||||
// https://github.com/atom/electron/blob/master/docs/api/shell.md
|
||||
|
||||
shell.openExternal('https://github.com')
|
||||
shell.openExternal('https://github.com').then(() => {})
|
||||
|
||||
// <webview>
|
||||
// https://github.com/atom/electron/blob/master/docs/api/web-view-tag.md
|
||||
|
@ -238,8 +238,9 @@ webview.addEventListener('found-in-page', function (e) {
|
|||
|
||||
const requestId = webview.findInPage('test')
|
||||
|
||||
webview.addEventListener('new-window', function (e) {
|
||||
require('electron').shell.openExternal(e.url)
|
||||
webview.addEventListener('new-window', async e => {
|
||||
const { shell } = require('electron')
|
||||
await shell.openExternal(e.url)
|
||||
})
|
||||
|
||||
webview.addEventListener('close', function () {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue