file_bug426646-2.html (1735B)
1 <html><head> 2 <title>Bug 426646, Using location.replace breaks iframe history</title> 3 <script type="text/javascript"> 4 var BASE_URI = "http://mochi.test:8888/tests/dom/base/test/"; 5 var url1 = BASE_URI + "iframe1_bug426646.html"; 6 7 var win0 = null; 8 9 function soon(f) { 10 return function() { setTimeout(f, 0); }; 11 } 12 13 function doe() { 14 document.body.innerHTML = "<iframe src='about:blank'></iframe>"; 15 document.body.innerHTML += "<iframe src='about:blank'></iframe>"; 16 win0 = window.frames[0]; 17 win0.frameElement.onload = soon(doe2); 18 win0.location.replace(url1); 19 } 20 21 function doe2() { 22 // Add some iframes/docshells. Session history should still work. 23 var ifr1 = document.createElement("iframe"); 24 ifr1.onload = soon(doe3); 25 document.body.insertBefore(ifr1, document.body.firstChild); 26 27 var ifr2 = document.createElement("iframe"); 28 ifr2.onload = soon(doe3); 29 document.body.insertBefore(ifr2, document.body.firstChild); 30 31 var ifr3 = document.createElement("iframe"); 32 ifr3.onload = soon(doe3); 33 document.body.insertBefore(ifr3, document.body.firstChild); 34 } 35 36 var doe3_count = 0; 37 function doe3() { 38 // Wait until all three iframes have loaded about:blank before navigating 39 // win0. 40 doe3_count++; 41 if (doe3_count < 3) { 42 return; 43 } 44 if (doe3_count > 3) { 45 ok(false, 'Unexpected ' + doe3_count + 'th call to doe3.'); 46 return; 47 } 48 49 win0.frameElement.onload = soon(doe4); 50 win0.location = BASE_URI + 'iframe2_bug426646.html'; 51 } 52 53 function doe4() { 54 win0.frameElement.onload = soon(doe5); 55 history.go(-1); 56 } 57 58 function doe5() { 59 opener.is(String(win0.location), url1, "History.go(-1) didn't work?"); 60 close(); 61 } 62 </script> 63 </head> 64 <body onload="setTimeout(doe, 0);" onunload="opener.nextTest();"> 65 </body></html>