When defining an IFRAME with an editable document, clicking outside the IFRAME and then calling IFRAME.focus(), the caret is placed in the beginning of the editable area and the previous selection is lost. The URL shows a simple test case for it.
Created attachment 7848 [details] Test Case
Confirmed in WebKit 418.8 and the latest nightly. The behaviour differs slightly in the nightly in that the selection is correctly rendered as inactive when it loses focus, but upon restoration of focus the selection is still lost.
This bug sounds very similar to Bug 9642. Please check a nightly WebKit build on or after r15487 (Bug 9642 Comment #7) to see if this is fixed.
This appears to be fixed now. Tested with a locally-built r15495. Going to mark it a duplicate of Bug 9642. *** This bug has been marked as a duplicate of 9642 ***
NOTE: I filed Bug 9982 for the blue/green background that appears in the test case on WebKit nightly builds.
Bug 9984 is also related (I found an assertion failure working with the test case from this bug).