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