Consider merging https://chromium.googlesource.com/chromium/blink/+/60ed87d48e7c337cada58f2ae25da4d9eb426207 When the page loses focus a blur event is dispatched once, prevent a second dispatch (via e.g. programmatic blur()-ing), when a page doesn't have focus, prevent a focus event dispatch (via e.g. programmatic focus()-ing), as it will receive a focus event when the page regains focus.
Got reverted in http://src.chromium.org/viewvc/blink?view=revision&revision=160140. But the concept of the change seems correct. Also see https://code.google.com/p/chromium/issues/detail?id=276757
It landed in this commit: https://src.chromium.org/viewvc/blink?view=revision&revision=164069 I took a test case from the above and changed it into JSFiddle: https://jsfiddle.net/8ueL62kx/ *** Firefox Nightly 105 *** Load test, it would be focused in input field but no event is fired and then click any where besides "input" field, it will fire "blur" event. *** Chrome Canary 106 *** Load test, it would be focused in input field but no event is fired and then click any where besides "input" field, it will fire "blurfocus" event. *** Safari Technology Preview 151 *** Load test, it would be focused in input field but no event is fired and then click any where besides "input" field, it will fire "blurfocus" event. _______ I am not sure on web-spec or whether something else is required but just going to share what I tested or observed. Thanks!
<rdar://problem/99045743>
I tried to land this change in following PR based Comment 03 - commit of Chromium: Link - https://github.com/WebKit/WebKit/pull/4774 and these are learnings: 1) Fixing Developer Tools test case is easy and can be followed from Chromium patch without any issue. 2) Someone need to update "TestRunner" - testRunner.focusWebView part to accommodate this change to ensure that the focus work properly since it leads to 77 API failures on iOS: https://ews-build.webkit.org/#/builders/9/builds/81789 ____ Since it is beyond my capability to update (2), I will leave it for someone else to fix this bug but will document my attempt for others. Thanks!