1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/base/test/file_bug426646-2.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,64 @@ 1.4 +<html><head> 1.5 +<title>Bug 426646, Using location.replace breaks iframe history</title> 1.6 +<script type="text/javascript"> 1.7 +var url1 = "data:text/html;charset=utf-8,1st%20page"; 1.8 + 1.9 +var win0 = null; 1.10 + 1.11 +function soon(f) { 1.12 + return function() { setTimeout(f, 0); }; 1.13 +} 1.14 + 1.15 +function doe() { 1.16 + document.body.innerHTML = "<iframe src='about:blank'></iframe>"; 1.17 + document.body.innerHTML += "<iframe src='about:blank'></iframe>"; 1.18 + win0 = window.frames[0]; 1.19 + win0.frameElement.onload = soon(doe2); 1.20 + win0.location.replace(url1); 1.21 +} 1.22 + 1.23 +function doe2() { 1.24 + // Add some iframes/docshells. Session history should still work. 1.25 + var ifr1 = document.createElement("iframe"); 1.26 + document.body.insertBefore(ifr1, document.body.firstChild); 1.27 + ifr1.onload = soon(doe3); 1.28 + 1.29 + var ifr2 = document.createElement("iframe"); 1.30 + document.body.insertBefore(ifr2, document.body.firstChild); 1.31 + ifr2.onload = soon(doe3); 1.32 + 1.33 + var ifr3 = document.createElement("iframe"); 1.34 + document.body.insertBefore(ifr3, document.body.firstChild); 1.35 + ifr3.onload = soon(doe3); 1.36 +} 1.37 + 1.38 +var doe3_count = 0; 1.39 +function doe3() { 1.40 + // Wait until all three iframes have loaded about:blank before navigating 1.41 + // win0. 1.42 + doe3_count++; 1.43 + if (doe3_count < 3) { 1.44 + return; 1.45 + } 1.46 + if (doe3_count > 3) { 1.47 + ok(false, 'Unexpected ' + doe3_count + 'th call to doe3.'); 1.48 + return; 1.49 + } 1.50 + 1.51 + win0.frameElement.onload = soon(doe4); 1.52 + win0.location = 'data:text/html;charset=utf-8,2nd%20page'; 1.53 +} 1.54 + 1.55 +function doe4() { 1.56 + win0.frameElement.onload = soon(doe5); 1.57 + history.go(-1); 1.58 +} 1.59 + 1.60 +function doe5() { 1.61 + opener.is(win0.location, url1, "History.go(-1) didn't work?"); 1.62 + close(); 1.63 +} 1.64 +</script> 1.65 +</head> 1.66 +<body onload="setTimeout(doe, 0);" onunload="opener.nextTest();"> 1.67 +</body></html>