chromium/third_party/blink/web_tests/fast/events/frame-click-clear-focus.html

<!DOCTYPE html>
<html>
<body>
<script src="../../resources/js-test.js"></script>
<iframe id="frame1" srcdoc="<input>" width="800" height="600"></iframe>
<iframe id="frame2" srcdoc="<input>" width="800" height="600"></iframe>
<script>
description('Make sure that clicking on an inactive frame clears existing element focus.');
jsTestIsAsync = true;
var doc;
var innerInput;
window.onload = function() {
    var iframe1 = document.getElementById('frame1');
    var iframe2 = document.getElementById('frame2');
    doc = iframe1.contentDocument;
    innerInput = doc.querySelector('input');
    innerInput.focus();
    debug('===> Making a frame with a focused element inactive by focus() for another frame.');
    iframe2.contentWindow.focus();
    // The following check is not important. activeElement is innerInput in Firefox,
    // and is body in IE in this case.
    shouldBe('doc.activeElement', 'doc.body');

    iframe1.contentWindow.focus();
    innerInput.focus();
    debug('===> Making a frame with a focused element inactive by mouse click for another frame.');
    eventSender.mouseMoveTo(iframe2.offsetLeft + iframe2.offsetWidth / 2, iframe2.offsetTop + iframe2.offsetHeight / 2);
    eventSender.mouseDown();
    eventSender.mouseUp();
    shouldBe('doc.activeElement', 'doc.body');

    debug('===> Making the frame active again clicking by a non-focusable element.');
    eventSender.mouseMoveTo(iframe1.offsetLeft + iframe1.offsetWidth / 2, iframe1.offsetTop + iframe1.offsetHeight / 2);
    eventSender.mouseDown();
    eventSender.mouseUp();
    shouldBe('doc.activeElement', 'doc.body');
    finishJSTest();
};
</script>
</body>
</html>