diff --git a/lib/renderer/web-view/web-view.js b/lib/renderer/web-view/web-view.js index 3c0e2e20a8..063d6ab562 100644 --- a/lib/renderer/web-view/web-view.js +++ b/lib/renderer/web-view/web-view.js @@ -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 }) diff --git a/spec/webview-spec.js b/spec/webview-spec.js index c8a6b9d634..c841f6b56e 100644 --- a/spec/webview-spec.js +++ b/spec/webview-spec.js @@ -1302,8 +1302,9 @@ describe(' 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 })