4 https://bugzilla.mozilla.org/show_bug.cgi?id=602256
7 <title>Test for Bug
602256</title>
9 <body onload=
"SimpleTest.executeSoon(run_test)">
10 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=602256">Mozilla Bug
602256</a>
12 <iframe id=
"iframe" src=
"data:text/html,<p%20id='text'>Start</p>"></iframe>
15 <script type=
"application/javascript">
17 /** Test for Bug
602256 **/
19 var testWin = window.opener ? window.opener : window.parent;
21 var SimpleTest = testWin.SimpleTest;
22 function is() { testWin.is.apply(testWin, arguments); }
27 return location.hash.replace(/^#/,
"");
30 function waitForLoad(aCallback) {
32 gFrame.removeEventListener(
"load", listener, false);
33 SimpleTest.executeSoon(aCallback);
36 gFrame.addEventListener(
"load", listener, false);
39 function loadContent(aURL, aCallback) {
40 waitForLoad(aCallback);
46 return gFrame.contentDocument.documentURI;
49 function getContent() {
50 return gFrame.contentDocument.getElementById(
"text").textContent;
53 var START =
"data:text/html,<p%20id='text'>Start</p>";
54 var URL1 =
"data:text/html,<p%20id='text'>Test1</p>";
55 var URL2 =
"data:text/html,<p%20id='text'>Test2</p>";
58 window.location.hash =
"START";
60 gFrame = document.getElementById(
"iframe");
62 test_basic_inner_navigation();
69 function test_basic_inner_navigation() {
70 // Navigate the inner frame a few times
71 loadContent(URL1, function() {
72 is(getURL(), URL1,
"URL should be correct");
73 is(getContent(),
"Test1",
"Page should be correct");
75 loadContent(URL2, function() {
76 is(getURL(), URL2,
"URL should be correct");
77 is(getContent(),
"Test2",
"Page should be correct");
79 // Test that history is working
80 waitForLoad(function() {
81 is(getURL(), URL1,
"URL should be correct");
82 is(getContent(),
"Test1",
"Page should be correct");
84 waitForLoad(function() {
85 is(getURL(), URL2,
"URL should be correct");
86 is(getContent(),
"Test2",
"Page should be correct");
88 test_state_navigation();
90 window.history.forward();
92 window.history.back();
97 function test_state_navigation() {
98 window.location.hash =
"STATE1";
100 is(getURL(), URL2,
"URL should be correct");
101 is(getContent(),
"Test2",
"Page should be correct");
103 window.location.hash =
"STATE2";
105 is(getURL(), URL2,
"URL should be correct");
106 is(getContent(),
"Test2",
"Page should be correct");
108 window.history.back();
110 is(gState(),
"STATE1",
"State should be correct after going back");
111 is(getURL(), URL2,
"URL should be correct");
112 is(getContent(),
"Test2",
"Page should be correct");
114 window.history.forward();
116 is(gState(),
"STATE2",
"State should be correct after going forward");
117 is(getURL(), URL2,
"URL should be correct");
118 is(getContent(),
"Test2",
"Page should be correct");
120 window.history.back();
121 window.history.back();
123 is(gState(),
"START",
"State should be correct");
124 is(getURL(), URL2,
"URL should be correct");
125 is(getContent(),
"Test2",
"Page should be correct");
127 waitForLoad(function() {
128 is(getURL(), URL1,
"URL should be correct");
129 is(getContent(),
"Test1",
"Page should be correct");
131 waitForLoad(function() {
132 is(gState(),
"START",
"State should be correct");
133 is(getURL(), START,
"URL should be correct");
134 is(getContent(),
"Start",
"Page should be correct");
139 window.history.back();
141 is(gState(),
"START",
"State should be correct after going back twice");
144 window.history.back();
145 is(gState(),
"START",
"State should be correct");