test_bug1104732.html (2122B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=1104732 5 --> 6 <head> 7 <meta charset="utf-8"> 8 <title>Test for Bug 1104732</title> 9 <script src="/tests/SimpleTest/SimpleTest.js"></script> 10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 11 <script type="application/javascript"> 12 13 /** Test for Bug 1104732 */ 14 15 // Expected order of the values of the "state" variable: 16 // Test starting 17 // defer 18 // DOMContentLoaded 19 // load 20 21 // In the meantime, the async script load should happen before load. 22 // Ideally, we would want to assert that it happens after DOMContentLoaded, 23 // because it shouldn't be holding up DOMContentLoaded, but there is 24 // no *guarantee* that this is the case, so we cannot assert it. 25 26 var state = "Test starting"; 27 var asyncState = "not loaded"; 28 SimpleTest.waitForExplicitFinish(); 29 is(document.readyState, "loading", "Document should have been loading."); 30 document.addEventListener("DOMContentLoaded", function() { 31 is(document.readyState, "interactive", "readyState should be interactive during DOMContentLoaded."); 32 is(state, "defer", "Bad state upon DOMContentLoaded"); 33 state = "DOMContentLoaded"; 34 // This doesn't work (see above), but we can't "todo" this assertion either, because 35 // it will sometimes be the case... 36 // isnot(asyncState, "loaded", "Async script should not have delayed domcontentloaded"); 37 }); 38 window.addEventListener("load", function() { 39 is(document.readyState, "complete", "readyState should be complete during load."); 40 is(state, "DOMContentLoaded", "Bad state upon load"); 41 state = "load"; 42 is(asyncState, "loaded", "Async script should be loaded upon document load event"); 43 SimpleTest.finish(); 44 }); 45 </script> 46 <script defer src="file_defer_bug1104732.js"></script> 47 <script async src="file_async_bug1104732.sjs"></script> 48 </head> 49 <body> 50 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1104732">Mozilla Bug 1104732</a> 51 <p id="display"></p> 52 <div id="content" style="display: none"> 53 54 </div> 55 <pre id="test"> 56 </pre> 57 </body> 58 </html>