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