uidriver/js: Stop auto-focusing on loading when the page is in an iframe

Fixes #1373
This commit is contained in:
Hajime Hoshi 2020-10-10 15:52:29 +09:00
parent 10f394f72b
commit 7f55fdf769

View File

@ -404,8 +404,13 @@ func init() {
func (u *UserInterface) Run(context driver.UIContext) error {
if u.initFocused {
// 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)
}