| <html xmlns="http://www.w3.org/1999/xhtml"> |
| <head> |
| <title>testing "autofocus" in XHTML with dynamic changes (part two)</title> |
| <style> |
| input { background:red } |
| input:focus { background:lime } |
| </style> |
| <script language="JavaScript" type="text/javascript"> |
| function log(message) { |
| document.getElementById("console").innerHTML += "<li>"+message+"</li>"; |
| } |
| |
| function test() { |
| var input = document.getElementsByTagName('input')[0]; |
| var p = document.getElementsByTagName('p')[0]; |
| var input = p.removeChild(input); |
| input.autofocus = true; |
| p.appendChild(input); |
| |
| if (window.testRunner) { |
| testRunner.dumpAsText(); |
| testRunner.waitUntilDone(); |
| } |
| |
| setTimeout(check, 0); |
| } |
| |
| function check() { |
| if (document.activeElement == document.getElementsByTagName("input")[0]) |
| log("SUCCESS"); |
| else |
| log("FAILURE"); |
| |
| if (window.testRunner) |
| testRunner.notifyDone(); |
| } |
| </script> |
| </head> |
| <body onload="test()"> |
| <p>The form control should have a green background: <input/></p> |
| <hr/> |
| <ol id="console"></ol> |
| </body> |
| </html> |