1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/parser/htmlparser/tests/mochitest/test_bug688580.xhtml Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,62 @@ 1.4 +<html xmlns="http://www.w3.org/1999/xhtml"> 1.5 +<!-- 1.6 +https://bugzilla.mozilla.org/show_bug.cgi?id=688580 1.7 +--> 1.8 +<head> 1.9 + <title>Test for Bug 688580</title> 1.10 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.11 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.12 + <script type="application/javascript"> 1.13 + 1.14 + /** Test for Bug 688580 **/ 1.15 + 1.16 + // Expected order: 1.17 + // Test starting 1.18 + // readyState interactive 1.19 + // defer 1.20 + // DOMContentLoaded 1.21 + // readyState complete 1.22 + // load 1.23 + 1.24 + var state = "Test starting"; 1.25 + var readyStateCall = 0; 1.26 + SimpleTest.waitForExplicitFinish(); 1.27 + is(document.readyState, "loading", "Document should have been loading."); 1.28 + document.addEventListener("DOMContentLoaded", function () { 1.29 + is(document.readyState, "interactive", "readyState should be interactive during DOMContentLoaded."); 1.30 + is(state, "defer", "Bad state upon DOMContentLoaded"); 1.31 + state = "DOMContentLoaded"; 1.32 + }); 1.33 + document.addEventListener("readystatechange", function () { 1.34 + readyStateCall++; 1.35 + if (readyStateCall == 1) { 1.36 + is(document.readyState, "interactive", "readyState should have changed to interactive."); 1.37 + is(state, "Test starting", "Bad state upon first readystatechange."); 1.38 + state = "readyState interactive"; 1.39 + } else if (readyStateCall == 2) { 1.40 + is(document.readyState, "complete", "readyState should have changed to complete."); 1.41 + is(state, "DOMContentLoaded", "Bad state upon second readystatechange."); 1.42 + state = "readyState complete"; 1.43 + } else { 1.44 + ok(false, "Too many readystatechanges"); 1.45 + } 1.46 + }); 1.47 + window.addEventListener("load", function () { 1.48 + is(document.readyState, "complete", "readyState should be complete during load."); 1.49 + is(state, "readyState complete", "Bad state upon load") 1.50 + state = "load"; 1.51 + SimpleTest.finish(); 1.52 + }); 1.53 + </script> 1.54 + <script defer="" src="file_bug688580.js"></script> 1.55 +</head> 1.56 +<body> 1.57 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=688580">Mozilla Bug 688580</a> 1.58 +<p id="display"></p> 1.59 +<div id="content" style="display: none"> 1.60 + 1.61 +</div> 1.62 +<pre id="test"> 1.63 +</pre> 1.64 +</body> 1.65 +</html>