Wed, 31 Dec 2014 13:27:57 +0100
Ignore runtime configuration files generated during quality assurance.
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <!-- |
michael@0 | 4 | https://bugzilla.mozilla.org/show_bug.cgi?id=413310 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test for Bug 413310</title> |
michael@0 | 8 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 9 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
michael@0 | 10 | </head> |
michael@0 | 11 | <body> |
michael@0 | 12 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=413310">Mozilla Bug 413310</a> |
michael@0 | 13 | <p id="display"> |
michael@0 | 14 | <script class="testbody" type="text/javascript"> |
michael@0 | 15 | |
michael@0 | 16 | if (navigator.platform.startsWith("Mac")) { |
michael@0 | 17 | SimpleTest.expectAssertions(0, 2); |
michael@0 | 18 | } else { |
michael@0 | 19 | SimpleTest.expectAssertions(0, 1); |
michael@0 | 20 | } |
michael@0 | 21 | |
michael@0 | 22 | /** Test for Bug 413310 **/ |
michael@0 | 23 | |
michael@0 | 24 | // NOTE: If we ever make subframes do bfcache stuff, this test will need to be |
michael@0 | 25 | // modified accordingly! It assumes that subframes do NOT get bfcached. |
michael@0 | 26 | var onloadCount = 0; |
michael@0 | 27 | |
michael@0 | 28 | var step = -1; // One increment will come from the initial subframe onload. |
michael@0 | 29 | // Note that this script should come before the subframe, |
michael@0 | 30 | // so that doNextStep is defined when its onload handler fires. |
michael@0 | 31 | |
michael@0 | 32 | var textContent; |
michael@0 | 33 | |
michael@0 | 34 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 35 | |
michael@0 | 36 | addLoadEvent(doNextStep); |
michael@0 | 37 | |
michael@0 | 38 | function doNextStep() { |
michael@0 | 39 | ++step; |
michael@0 | 40 | switch (step) { |
michael@0 | 41 | case 1: |
michael@0 | 42 | is(onloadCount, 1, "Loaded initial page"); |
michael@0 | 43 | is($("i").contentWindow.location.href, |
michael@0 | 44 | location.href.replace(/test_bug413310.html/, |
michael@0 | 45 | "bug413310-subframe.html"), |
michael@0 | 46 | "Unexpected subframe location after initial load"); |
michael@0 | 47 | $("i").contentDocument.forms[0].submit(); |
michael@0 | 48 | break; |
michael@0 | 49 | case 2: |
michael@0 | 50 | is(onloadCount, 2, "Loaded POST result"); |
michael@0 | 51 | |
michael@0 | 52 | is($("i").contentWindow.location.href, |
michael@0 | 53 | location.href.replace(/test_bug413310.html/, |
michael@0 | 54 | "bug413310-post.sjs"), |
michael@0 | 55 | "Unexpected subframe location after POST load"); |
michael@0 | 56 | |
michael@0 | 57 | textContent = $("i").contentDocument.body.textContent; |
michael@0 | 58 | isDeeply(textContent.match(/^POST /), ["POST "], "Not a POST?"); |
michael@0 | 59 | |
michael@0 | 60 | $("i").contentWindow.location.hash = "foo"; |
michael@0 | 61 | setTimeout(doNextStep, 0); |
michael@0 | 62 | break; |
michael@0 | 63 | case 3: |
michael@0 | 64 | is(onloadCount, 2, "Anchor scroll should not fire onload"); |
michael@0 | 65 | is($("i").contentWindow.location.href, |
michael@0 | 66 | location.href.replace(/test_bug413310.html/, |
michael@0 | 67 | "bug413310-post.sjs#foo"), |
michael@0 | 68 | "Unexpected subframe location after anchor scroll"); |
michael@0 | 69 | is(textContent, $("i").contentDocument.body.textContent, |
michael@0 | 70 | "Did a load when scrolling?"); |
michael@0 | 71 | $("i").contentWindow.location.href = "bug413310-subframe.html";; |
michael@0 | 72 | break; |
michael@0 | 73 | case 4: |
michael@0 | 74 | is(onloadCount, 3, "Done new load"); |
michael@0 | 75 | is($("i").contentWindow.location.href, |
michael@0 | 76 | location.href.replace(/test_bug413310.html/, |
michael@0 | 77 | "bug413310-subframe.html"), |
michael@0 | 78 | "Unexpected subframe location after new load"); |
michael@0 | 79 | history.back(); |
michael@0 | 80 | break; |
michael@0 | 81 | case 5: |
michael@0 | 82 | is(onloadCount, 4, |
michael@0 | 83 | "History traversal didn't fire onload: bfcache issues!"); |
michael@0 | 84 | is($("i").contentWindow.location.href, |
michael@0 | 85 | location.href.replace(/test_bug413310.html/, |
michael@0 | 86 | "bug413310-post.sjs#foo"), |
michael@0 | 87 | "Unexpected subframe location"); |
michael@0 | 88 | is(textContent, $("i").contentDocument.body.textContent, |
michael@0 | 89 | "Did a load when going back?"); |
michael@0 | 90 | SimpleTest.finish(); |
michael@0 | 91 | break; |
michael@0 | 92 | } |
michael@0 | 93 | } |
michael@0 | 94 | </script> |
michael@0 | 95 | <!-- Use a timeout in onload so that we don't do a load immediately inside onload --> |
michael@0 | 96 | <iframe id="i" src="bug413310-subframe.html" onload="setTimeout(doNextStep, 20)"> |
michael@0 | 97 | </iframe> |
michael@0 | 98 | </p> |
michael@0 | 99 | <div id="content" style="display: none"> |
michael@0 | 100 | |
michael@0 | 101 | </div> |
michael@0 | 102 | <pre id="test"> |
michael@0 | 103 | </pre> |
michael@0 | 104 | </body> |
michael@0 | 105 | </html> |
michael@0 | 106 |