test_bug656283.html (1440B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=656283 5 --> 6 <head> 7 <title>Test for Bug 656283</title> 8 <script src="/tests/SimpleTest/SimpleTest.js"></script> 9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 10 </head> 11 <body onload="test()"> 12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=656283">Mozilla Bug 656283</a> 13 <p id="display"></p> 14 <div id="content" style="display: none"> 15 16 </div> 17 <pre id="test"> 18 <script type="application/javascript"> 19 20 /** Test for Bug 656283 */ 21 22 SimpleTest.waitForExplicitFinish(); 23 24 var ifr; 25 function test() { 26 var d = document.implementation.createHTMLDocument(""); 27 is(d.activeElement, d.body, "Active element should be body by default! (1)"); 28 29 30 ifr = document.getElementById("ifr"); 31 ifr.onload = test2; 32 ifr.srcdoc = "1"; 33 } 34 35 var firstDoc; 36 function test2() { 37 firstDoc = ifr.contentDocument; 38 is(firstDoc.activeElement, firstDoc.body, 39 "Active element should be body by default! (2)"); 40 ifr.onload = test3; 41 ifr.srcdoc = "<input>"; 42 } 43 44 function test3() { 45 ifr.contentDocument.getElementsByTagName("input")[0].focus(); 46 is(firstDoc.activeElement, firstDoc.body, 47 "Active element should be body by default! (3)"); 48 ifr.remove(); 49 is(firstDoc.activeElement, firstDoc.body, 50 "Active element should be body by default! (4)"); 51 SimpleTest.finish(); 52 } 53 54 </script> 55 </pre> 56 <iframe id="ifr"></irame> 57 </body> 58 </html>