fix: webview.focus() should move page focus to webview (#14427)

This commit is contained in:
Cheng Zhao 2018-09-03 11:41:54 +09:00 committed by GitHub
parent aa01a7337c
commit 10176c71ff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View file

@ -366,6 +366,11 @@ const registerWebViewElement = function () {
return internal.webContents
}
// Focusing the webview should move page focus to the underlying iframe.
proto.focus = function () {
this.contentWindow.focus()
}
window.WebView = webFrame.registerEmbedderCustomElement('webview', {
prototype: proto
})

View file

@ -1302,8 +1302,9 @@ describe('<webview> tag', function () {
await domReadySignal
// If this test fails, check if webview.focus() still works.
const focusSignal = waitForEvent(webview, 'focus')
webview.contentWindow.focus()
webview.focus()
await focusSignal
})