span element is not focused when using focus(), but it works in FF and Chrome: https://jsbin.com/womatikizo/edit?html,output
<rdar://problem/88399227>
It turns out this fails because of the !document->topOrigin().isSameOriginDomain(document->securityOrigin()) check in Element::focus. Origins are https://jsbin.com and https://null.jsbin.com.
Created attachment 452995 [details] Patch
Created attachment 453012 [details] Patch
Created attachment 453098 [details] Patch
Created attachment 453134 [details] Patch
The patch seems unrelated to comment #2. Was that a red herring?
(In reply to Simon Fraser (smfr) from comment #7) > The patch seems unrelated to comment #2. Was that a red herring? The last 2 patches or so were an experiment for another problem, I moved it to https://bugs.webkit.org/show_bug.cgi?id=237189. I still think the problem is with the code mentioned in comment #2. I'll ask Ali, who introduced this code.
@Ali it seems you introduced the cross-origin iframe check when focusing programmatically in https://bugs.webkit.org/show_bug.cgi?id=200515. I wonder why the test case works in chromium+FF but not WebKit. Could it be that https://jsbin.com and https://null.jsbin.com should actually be treated same origin? The iframe sandbox contains allow-same-origin, should that have an effect on the !document->topOrigin().isSameOriginDomain(document->securityOrigin()) check? It seems something changed to make the check not sufficient these days but I am not sure what.
WebKit ToT (Active element: [object HTMLBodyElement]) while Chrome Canary 115 - Active element: [object HTMLSpanElement]. Comment 09 refers to similar code, which Chris highlighted while testing bug 253409, where WebKit / Safari does not do focus properly leading to tests failure in JSFiddle etc.