NEW235670
span element is not focused when using focus()
https://bugs.webkit.org/show_bug.cgi?id=235670
Summary span element is not focused when using focus()
Rob Buis
Reported 2022-01-26 13:43:25 PST
span element is not focused when using focus(), but it works in FF and Chrome: https://jsbin.com/womatikizo/edit?html,output
Attachments
Patch (1.44 KB, patch)
2022-02-23 09:58 PST, Rob Buis
no flags
Patch (1.49 KB, patch)
2022-02-23 12:19 PST, Rob Buis
no flags
Patch (3.41 KB, patch)
2022-02-24 06:16 PST, Rob Buis
no flags
Patch (6.39 KB, patch)
2022-02-24 13:32 PST, Rob Buis
ews-feeder: commit-queue-
Radar WebKit Bug Importer
Comment 1 2022-02-02 13:44:16 PST
Rob Buis
Comment 2 2022-02-23 09:24:28 PST
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.
Rob Buis
Comment 3 2022-02-23 09:58:35 PST
Rob Buis
Comment 4 2022-02-23 12:19:30 PST
Rob Buis
Comment 5 2022-02-24 06:16:41 PST
Rob Buis
Comment 6 2022-02-24 13:32:47 PST
Simon Fraser (smfr)
Comment 7 2022-02-24 14:38:12 PST
The patch seems unrelated to comment #2. Was that a red herring?
Rob Buis
Comment 8 2022-02-25 08:35:47 PST
(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.
Rob Buis
Comment 9 2022-02-25 08:41:54 PST
@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.
Ahmad Saleem
Comment 10 2023-05-11 09:07:17 PDT
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.
Note You need to log in before you can comment on or make changes to this bug.