13f186f1e39c308b362f3cba89a36ec147c0343f
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / fast / events / frame-click-clear-focus.html
1 <!DOCTYPE html>
2 <html>
3 <body>
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>
7 <script>
8 description('Make sure that clicking on an inactive frame clears existing element focus.');
9 jsTestIsAsync = true;
10 var doc;
11 var innerInput;
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');
17     innerInput.focus();
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');
23
24     iframe1.contentWindow.focus();
25     innerInput.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');
31
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');
37     finishJSTest();
38 };
39 </script>
40 </body>
41 </html>