test_bug715739.html (1990B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=715739 5 --> 6 <head> 7 <meta charset="utf-8"> 8 <title>Test for Bug 715739</title> 9 <script src="/tests/SimpleTest/SimpleTest.js"></script> 10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 11 </head> 12 <body onload="tick()"> 13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=715739">Mozilla Bug 715739</a> 14 <p id="display"></p> 15 <pre id="test"> 16 <script type="application/javascript"> 17 18 /** Test for Bug 715739 */ 19 20 SimpleTest.waitForExplicitFinish(); 21 22 var runNumber = 0; 23 24 function textChildren(node) { 25 var s = ""; 26 var n = node.firstChild; 27 while (n) { 28 if (n.nodeType == Node.TEXT_NODE) { 29 s += n.nodeValue; 30 } 31 n = n.nextSibling; 32 } 33 return s; 34 } 35 36 var f, d; 37 38 function tick() { 39 runNumber++; 40 f = document.getElementsByTagName("iframe")[0]; 41 d = f.contentDocument; 42 var text; 43 44 if (runNumber == 1) { 45 frames[1].setTimeout(` 46 var d = parent.d; 47 var f = parent.f; 48 d.open(); 49 f.addEventListener("load", parent.tick); 50 d.write("X"); 51 d.write("\u003cscript>document.write('Y');\u003c/script>"); 52 d.write("Z"); 53 d.close(); 54 `); 55 return; 56 } 57 58 if (runNumber == 2) { 59 text = textChildren(d.body); 60 is(text, "XYZ", "Wrong text before reload."); 61 f.contentWindow.location.reload(); 62 return; 63 } 64 65 if (runNumber == 3) { 66 text = textChildren(d.body); 67 is(text, "ABC", "Wrong text after reload."); 68 SimpleTest.finish(); 69 } 70 } 71 72 // We want to trigger a document.open/write with a different window as the 73 // entry global. Let's give that window a blob URL so we don't have to set up 74 // extra helper files. 75 var blob = new Blob(["ABC"], { type: "text/html" }); 76 var blobURL = URL.createObjectURL(blob); 77 78 </script> 79 </pre> 80 <div id="content" style="display: none"> 81 <iframe></iframe> 82 <iframe></iframe> 83 </div> 84 <script> 85 document.querySelectorAll("iframe")[1].src = blobURL; 86 </script> 87 </body> 88 </html>