4 https://bugzilla.mozilla.org/show_bug.cgi?id=413310
7 <title>Test for Bug
413310</title>
8 <script type=
"text/javascript" src=
"/tests/SimpleTest/SimpleTest.js"></script>
9 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css" />
12 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=413310">Mozilla Bug
413310</a>
14 <script class=
"testbody" type=
"text/javascript">
16 if (navigator.platform.startsWith(
"Mac")) {
17 SimpleTest.expectAssertions(
0,
2);
19 SimpleTest.expectAssertions(
0,
1);
22 /** Test for Bug
413310 **/
24 // NOTE: If we ever make subframes do bfcache stuff, this test will need to be
25 // modified accordingly! It assumes that subframes do NOT get bfcached.
28 var step = -
1; // One increment will come from the initial subframe onload.
29 // Note that this script should come before the subframe,
30 // so that doNextStep is defined when its onload handler fires.
34 SimpleTest.waitForExplicitFinish();
36 addLoadEvent(doNextStep);
38 function doNextStep() {
42 is(onloadCount,
1,
"Loaded initial page");
43 is($(
"i").contentWindow.location.href,
44 location.href.replace(/test_bug413310.html/,
45 "bug413310-subframe.html"),
46 "Unexpected subframe location after initial load");
47 $(
"i").contentDocument.forms[
0].submit();
50 is(onloadCount,
2,
"Loaded POST result");
52 is($(
"i").contentWindow.location.href,
53 location.href.replace(/test_bug413310.html/,
54 "bug413310-post.sjs"),
55 "Unexpected subframe location after POST load");
57 textContent = $(
"i").contentDocument.body.textContent;
58 isDeeply(textContent.match(/^POST /), [
"POST "],
"Not a POST?");
60 $(
"i").contentWindow.location.hash =
"foo";
61 setTimeout(doNextStep,
0);
64 is(onloadCount,
2,
"Anchor scroll should not fire onload");
65 is($(
"i").contentWindow.location.href,
66 location.href.replace(/test_bug413310.html/,
67 "bug413310-post.sjs#foo"),
68 "Unexpected subframe location after anchor scroll");
69 is(textContent, $(
"i").contentDocument.body.textContent,
70 "Did a load when scrolling?");
71 $(
"i").contentWindow.location.href =
"bug413310-subframe.html";;
74 is(onloadCount,
3,
"Done new load");
75 is($(
"i").contentWindow.location.href,
76 location.href.replace(/test_bug413310.html/,
77 "bug413310-subframe.html"),
78 "Unexpected subframe location after new load");
83 "History traversal didn't fire onload: bfcache issues!");
84 is($(
"i").contentWindow.location.href,
85 location.href.replace(/test_bug413310.html/,
86 "bug413310-post.sjs#foo"),
87 "Unexpected subframe location");
88 is(textContent, $(
"i").contentDocument.body.textContent,
89 "Did a load when going back?");
95 <!-- Use a timeout in onload so that we don't do a load immediately inside onload -->
96 <iframe id=
"i" src=
"bug413310-subframe.html" onload=
"setTimeout(doNextStep, 20)">
99 <div id=
"content" style=
"display: none">