tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_bug347174_write.html (2236B)


      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 
     15 <div id="content" style="display: none">
     16  
     17 </div>
     18 <pre id="test">
     19 <script class="testbody" type="text/javascript">
     20 
     21 /** Test for Bug 347174 */
     22 // simple test of readyState during loading, DOMContentLoaded, and complete
     23 // this test passes in IE7
     24 window.readyStateText = [];
     25 window.loaded = false;
     26 function attachCustomEventListener(element, eventName, command) {
     27    if (window.addEventListener && !window.opera)
     28        element.addEventListener(eventName, command, true);
     29    else if (window.attachEvent)
     30        element.attachEvent("on" + eventName, command);
     31 }
     32 
     33 function showMessage(msg) {
     34    window.readyStateText.push(msg);
     35    document.getElementById("display").innerHTML = readyStateText.join("<br>");
     36 }
     37 
     38 function frameLoad() {
     39  var doc = $('iframe').contentWindow.document;
     40  is(doc.readyState, "complete", "frame document.readyState should be 'complete' on load");
     41  showMessage("frame load: " + doc.readyState);
     42  if (window.loaded) SimpleTest.finish();
     43 }
     44 
     45 function load() {
     46    window.loaded = true;
     47 
     48    var imgsrc = "<img onload ='window.parent.imgLoad()' src='image.png?noCache="
     49               + (new Date().getTime()) + "'>\n";
     50    var doc = $('iframe').contentWindow.document;
     51    doc.writeln(imgsrc);
     52    doc.close();
     53    showMessage("frame after document.write: " + doc.readyState);
     54    isnot(doc.readyState, "complete", "frame document.readyState should not be 'complete' after document.write");
     55 }
     56 
     57 function imgLoad() {
     58    var doc = $('iframe').contentWindow.document;
     59    showMessage("frame after imgLoad: " + doc.readyState);
     60    is(doc.readyState, "interactive", "frame document.readyState should still be 'interactive' after img loads");
     61 }
     62 
     63 window.onload=load;
     64 
     65 SimpleTest.waitForExplicitFinish();
     66 
     67 </script>
     68 </pre>
     69 <iframe src="404doesnotexist" id="iframe" onload="frameLoad();"></iframe>
     70 </body>
     71 </html>