From 7f55fdf7694420611bb21a84286ea157bf61a4ad Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sat, 10 Oct 2020 15:52:29 +0900 Subject: [PATCH] uidriver/js: Stop auto-focusing on loading when the page is in an iframe Fixes #1373 --- internal/uidriver/js/ui_js.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/uidriver/js/ui_js.go b/internal/uidriver/js/ui_js.go index 3f9126690..fd47367ea 100644 --- a/internal/uidriver/js/ui_js.go +++ b/internal/uidriver/js/ui_js.go @@ -404,7 +404,12 @@ func init() { func (u *UserInterface) Run(context driver.UIContext) error { if u.initFocused { - canvas.Call("focus") + // Do not focus the canvas when the current document is in an iframe. + // Otherwise, the parent page tries to focus the iframe on every loading, which is annoying (#1373). + isInIframe := !jsutil.Equal(window.Get("location"), window.Get("parent").Get("location")) + if !isInIframe { + canvas.Call("focus") + } } u.running = true return <-u.loop(context)