test_bug347174.html (1985B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=347174 5 --> 6 <head> 7 <title>Test for Bug 347174</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> 12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=347174">Mozilla Bug 347174</a> 13 <p id="display"></p> 14 <div id="content" style="display: none"> 15 16 </div> 17 <pre id="test"> 18 <script class="testbody" type="text/javascript"> 19 20 /** Test for Bug 347174 */ 21 // simple test of readyState during loading, DOMContentLoaded, and complete 22 // this test passes in IE7 23 window.readyStateText = []; 24 window.readyStateText.push("script tag: " + document.readyState); 25 is(document.readyState, "loading", "document.readyState should be 'loading' when scripts runs initially"); 26 27 function attachCustomEventListener(element, eventName, command) { 28 if (window.addEventListener && !window.opera) 29 element.addEventListener(eventName, command, true); 30 else if (window.attachEvent) 31 element.attachEvent("on" + eventName, command); 32 } 33 34 function showMessage(msg) { 35 window.readyStateText.push(msg); 36 document.getElementById("display").innerHTML = readyStateText.join("<br>"); 37 } 38 39 function load() { 40 is(document.readyState, "complete", "document.readyState should be 'complete' on load"); 41 showMessage("load: " + document.readyState); 42 SimpleTest.finish(); 43 } 44 45 function readyStateChange() { 46 showMessage("readyStateChange: " + document.readyState); 47 } 48 49 function DOMContentLoaded() { 50 is(document.readyState, "interactive", "document.readyState should be 'interactive' on DOMContentLoaded"); 51 showMessage("DOMContentLoaded: " + document.readyState); 52 } 53 54 window.onload=load; 55 56 attachCustomEventListener(document, "readystatechange", readyStateChange); 57 attachCustomEventListener(document, "DOMContentLoaded", DOMContentLoaded); 58 59 SimpleTest.waitForExplicitFinish(); 60 61 </script> 62 </pre> 63 </body> 64 </html>