test_bug688580.xhtml (2106B)
1 <html xmlns="http://www.w3.org/1999/xhtml"> 2 <!-- 3 https://bugzilla.mozilla.org/show_bug.cgi?id=688580 4 --> 5 <head> 6 <title>Test for Bug 688580</title> 7 <script src="/tests/SimpleTest/SimpleTest.js"></script> 8 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 9 <script type="application/javascript"> 10 11 /** Test for Bug 688580 */ 12 13 // Expected order: 14 // Test starting 15 // readyState interactive 16 // defer 17 // DOMContentLoaded 18 // readyState complete 19 // load 20 21 var state = "Test starting"; 22 var readyStateCall = 0; 23 SimpleTest.waitForExplicitFinish(); 24 is(document.readyState, "loading", "Document should have been loading."); 25 document.addEventListener("DOMContentLoaded", function() { 26 is(document.readyState, "interactive", "readyState should be interactive during DOMContentLoaded."); 27 is(state, "defer", "Bad state upon DOMContentLoaded"); 28 state = "DOMContentLoaded"; 29 }); 30 document.addEventListener("readystatechange", function() { 31 readyStateCall++; 32 if (readyStateCall == 1) { 33 is(document.readyState, "interactive", "readyState should have changed to interactive."); 34 is(state, "Test starting", "Bad state upon first readystatechange."); 35 state = "readyState interactive"; 36 } else if (readyStateCall == 2) { 37 is(document.readyState, "complete", "readyState should have changed to complete."); 38 is(state, "DOMContentLoaded", "Bad state upon second readystatechange."); 39 state = "readyState complete"; 40 } else { 41 ok(false, "Too many readystatechanges"); 42 } 43 }); 44 window.addEventListener("load", function() { 45 is(document.readyState, "complete", "readyState should be complete during load."); 46 is(state, "readyState complete", "Bad state upon load"); 47 state = "load"; 48 SimpleTest.finish(); 49 }); 50 </script> 51 <script defer="" src="file_bug688580.js"></script> 52 </head> 53 <body> 54 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=688580">Mozilla Bug 688580</a> 55 <p id="display"></p> 56 <div id="content" style="display: none"> 57 58 </div> 59 <pre id="test"> 60 </pre> 61 </body> 62 </html>