| <html> | |
| <head> | |
| <title>Test case for bug 5122: Equivalent of Mozilla's DOMContentLoaded needed</title> | |
| <script type="text/javascript"> | |
| function log(message) | |
| { | |
| var item = document.createElement("li"); | |
| item.appendChild(document.createTextNode(message)); | |
| document.getElementById('log').appendChild(item); | |
| } | |
| if (window.testRunner) { | |
| testRunner.dumpAsText(); | |
| log = alert; | |
| } | |
| counter = 0; | |
| document.addEventListener('DOMContentLoaded', function() { log('DOMContentLoaded event fired on document!'); counter++; }, false); | |
| window.addEventListener('DOMContentLoaded', function() { | |
| log('DOMContentLoaded event bubbled to window!'); | |
| counter++; | |
| // Fire a short-duration timer that will fire before the image completes loading to ensure that | |
| // DOMContentLoaded is in fact happening before the image has loaded. | |
| window.setTimeout(function() { log('Timer callback called.'); counter++; }, 10) | |
| }, false); | |
| window.addEventListener('load', function() { | |
| log('load event fired!'); | |
| if (counter == 3) | |
| log('PASSED'); | |
| else | |
| log('FAILED'); | |
| }, false); | |
| </script> | |
| </head> | |
| <body> | |
| <h1>Test case for <a href='http://bugs.webkit.org/show_bug.cgi?id=5122'>bug 5122</a>: Equivalent of Mozilla's DOMContentLoaded needed</h1> | |
| <p>You should see a note about the DOMContentLoaded event being fired and bubbled, a timer being called, and then the load event being fired.</p> | |
| <img src='../../navigation/resources/slow-resource.pl?delay=250'> | |
| <ol id='log'> | |
| </ol> | |
| </body> | |
| </html> |