The blur event is not fired on an <input> within an <iframe> when the input loses focus by programmatically focusing the window.
In particular, suppose there is an <input> within an <iframe> and perform the following actions programmatically (in order):
1) Call focus() on <input>.
2) Call focus() on the current window.
Then the following sequence of events are fired, where an event := (event target element, event type):
(window, blur), (<iframe>, focus), (<input>, focus), (<iframe>, blur), (window, focus).
Notice, the event (<input>, blur) is missing from this sequence. The expected result is:
window, blur), (<iframe>, focus), (<input>, focus), (<input>, blur), (<iframe>, blur), (window, focus).
By the unfocusing steps listed in section 6.4.2 of the HTML 5 spec. <http://dev.w3.org/html5/spec/Overview.html#focus-management>, we should fire a blur event at <input>.
Created attachment 46332 [details]
Note, you can use the test case <https://bugs.webkit.org/attachment.cgi?id=12423> on bug #12262 to verify that the non-programmatic case works.
Created attachment 46333 [details]
For your convenience, here is a self-contained version of the layout test.
Created attachment 63303 [details]
Patch with test case
Hey Dan. Any reason this patch is not up for review? Did you find a problem in it?
(In reply to comment #4)
> Hey Dan. Any reason this patch is not up for review? Did you find a problem in it?
I have not put this up for review as I am still investigating this issue.
I've had intermittent discussions with Ian Hicksons about this change. Part of these discussions are with respect to the behavior of window.focus() and window.blur(). Section 7.4.3 of the HTML 5 spec. (which describes these methods) is not explicit with regards to whether these methods result in the execution of the focusing and unfocusing steps outlined in section 7.4.2 (or some similar algorithm), respectively. Further reading of the spec., and possible discussions are needed.
I hope to look at this some more this weekend.
Apologies for the forward dup, but I ran into this issue independently and filed it as <https://bugs.webkit.org/show_bug.cgi?id=110172>. I verified that my change fixes the test attached here (as well as another issue having to do with document.activeElement).
*** This bug has been marked as a duplicate of bug 110172 ***