4 <script src="../../resources/js-test.js"></script>
5 <iframe id="frame1" src="data:text/html,<input>" width="800" height="600"></iframe>
6 <iframe id="frame2" src="data:text/html,<input>" width="800" height="600"></iframe>
8 description('Make sure that clicking on an inactive frame clears existing element focus.');
12 window.onload = function() {
13 var iframe1 = document.getElementById('frame1');
14 var iframe2 = document.getElementById('frame2');
15 doc = iframe1.contentDocument;
16 innerInput = doc.querySelector('input');
18 debug('===> Making a frame with a focused element inactive by focus() for another frame.');
19 iframe2.contentWindow.focus();
20 // The following check is not important. activeElement is innerInput in Firefox,
21 // and is body in IE in this case.
22 shouldBe('doc.activeElement', 'innerInput');
24 iframe1.contentWindow.focus();
26 debug('===> Making a frame with a focused element inactive by mouse click for another frame.');
27 eventSender.mouseMoveTo(iframe2.offsetLeft + iframe2.offsetWidth / 2, iframe2.offsetTop + iframe2.offsetHeight / 2);
28 eventSender.mouseDown();
29 eventSender.mouseUp();
30 shouldBe('doc.activeElement', 'doc.body');
32 debug('===> Making the frame active again clicking by a non-focusable element.');
33 eventSender.mouseMoveTo(iframe1.offsetLeft + iframe1.offsetWidth / 2, iframe1.offsetTop + iframe1.offsetHeight / 2);
34 eventSender.mouseDown();
35 eventSender.mouseUp();
36 shouldBe('doc.activeElement', 'doc.body');