4 https://bugzilla.mozilla.org/show_bug.cgi?id=413310
7 <title>Test for Bug
413310</title>
8 <script type=
"text/javascript" src=
"/MochiKit/MochiKit.js"></script>
9 <script type=
"text/javascript" src=
"/tests/SimpleTest/SimpleTest.js"></script>
10 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css" />
13 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=413310">Mozilla Bug
413310</a>
15 <script class=
"testbody" type=
"text/javascript">
17 /** Test for Bug
413310 **/
19 // NOTE: If we ever make subframes do bfcache stuff, this test will need to be
20 // modified accordingly! It assumes that subframes do NOT get bfcached.
23 var step = -
1; // One increment will come from the initial subframe onload.
24 // Note that this script should come before the subframe,
25 // so that doNextStep is defined when its onload handler fires.
29 SimpleTest.waitForExplicitFinish();
31 addLoadEvent(doNextStep);
33 function doNextStep() {
37 is(onloadCount,
1,
"Loaded initial page");
38 is($(
"i").contentWindow.location.href,
39 location.href.replace(/test_bug413310.html/,
40 "bug413310-subframe.html"),
41 "Unexpected subframe location after initial load");
42 $(
"i").contentDocument.forms[
0].submit();
45 is(onloadCount,
2,
"Loaded POST result");
47 is($(
"i").contentWindow.location.href,
48 location.href.replace(/test_bug413310.html/,
49 "bug413310-post.sjs"),
50 "Unexpected subframe location after POST load");
52 textContent = $(
"i").contentDocument.body.textContent;
53 isDeeply(textContent.match(/^POST /), [
"POST "],
"Not a POST?");
55 $(
"i").contentWindow.location.hash =
"foo";
56 setTimeout(doNextStep,
0);
59 is(onloadCount,
2,
"Anchor scroll should not fire onload");
60 is($(
"i").contentWindow.location.href,
61 location.href.replace(/test_bug413310.html/,
62 "bug413310-post.sjs#foo"),
63 "Unexpected subframe location after anchor scroll");
64 is(textContent, $(
"i").contentDocument.body.textContent,
65 "Did a load when scrolling?");
66 $(
"i").contentWindow.location.href =
"bug413310-subframe.html";;
69 is(onloadCount,
3,
"Done new load");
70 is($(
"i").contentWindow.location.href,
71 location.href.replace(/test_bug413310.html/,
72 "bug413310-subframe.html"),
73 "Unexpected subframe location after new load");
78 "History traversal didn't fire onload: bfcache issues!");
79 is($(
"i").contentWindow.location.href,
80 location.href.replace(/test_bug413310.html/,
81 "bug413310-post.sjs#foo"),
82 "Unexpected subframe location");
83 is(textContent, $(
"i").contentDocument.body.textContent,
84 "Did a load when going back?");
90 <!-- Use a timeout in onload so that we don't do a load immediately inside onload -->
91 <iframe id=
"i" src=
"bug413310-subframe.html" onload=
"setTimeout(doNextStep, 20)">
94 <div id=
"content" style=
"display: none">