docshell/test/test_bug413310.html
author cbiesinger@gmail.com
Tue, 18 Mar 2008 14:00:53 -0700
changeset 13267 3d4062588c0f5187e90cd962c70750c62c03f18a
parent 12420 66a61530eb92f90183c616b020cd9d31213e3965
child 15743 6f6c7d842726b315830651f1158be39956726fcb
permissions -rw-r--r--
followup to bug 418535, add comments about which threads nsISocketTransportService functions can be called on patch by Florian Qu├Ęze <florian@queze.net> r+sr=biesi

<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=413310
-->
<head>
  <title>Test for Bug 413310</title>
  <script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=413310">Mozilla Bug 413310</a>
<p id="display">
<iframe id="i" src="bug413310-subframe.html" onload="setTimeout(doNextStep, 20)">
</iframe>
</p>
<div id="content" style="display: none">
  
</div>
<pre id="test">
<script class="testbody" type="text/javascript">

/** Test for Bug 413310 **/

// NOTE: If we ever make subframes do bfcache stuff, this test will need to be
// modified accordingly!  It assumes that subframes do not get bfcached.
var onloadCount = 0;

var step = -1;  // One increment will come from the initial subframe onload.

var textContent;

SimpleTest.waitForExplicitFinish();

addLoadEvent(doNextStep);

function doNextStep() {
  ++step;
  switch (step) {
    case 1:
      is(onloadCount, 1, "Loaded initial page");
      is($("i").contentWindow.location.href,
         location.href.replace(/test_bug413310.html/,
                               "bug413310-subframe.html"),
         "Unexpected subframe location after initial load");
      $("i").contentDocument.forms[0].submit();
      break;
    case 2:
      is(onloadCount, 2, "Loaded POST result");

      is($("i").contentWindow.location.href,
         location.href.replace(/test_bug413310.html/,
                               "bug413310-post.sjs"),
         "Unexpected subframe location after POST load");

      textContent = $("i").contentDocument.body.textContent;
      isDeeply(textContent.match(/^POST /), ["POST "], "Not a POST?");

      $("i").contentWindow.location.hash = "foo";
      setTimeout(doNextStep, 0);
      break;
    case 3: 
      is(onloadCount, 2, "Anchor scroll should not fire onload");
      is($("i").contentWindow.location.href,
         location.href.replace(/test_bug413310.html/,
                               "bug413310-post.sjs#foo"),
         "Unexpected subframe location after anchor scroll");
      is(textContent, $("i").contentDocument.body.textContent,
         "Did a load when scrolling?");
      $("i").contentWindow.location.href = "bug413310-subframe.html";;
      break;
    case 4:
      is(onloadCount, 3, "Done new load");
      is($("i").contentWindow.location.href,
         location.href.replace(/test_bug413310.html/,
                               "bug413310-subframe.html"),
         "Unexpected subframe location after new load");
      history.back();
      break;
    case 5:
      is(onloadCount, 4,
         "History traversal didn't fire onload: bfcache issues!");
      is($("i").contentWindow.location.href,
         location.href.replace(/test_bug413310.html/,
                               "bug413310-post.sjs#foo"),
         "Unexpected subframe location");
      is(textContent, $("i").contentDocument.body.textContent,
         "Did a load when going back?");
      SimpleTest.finish();
      break;
  }
}
</script>
</pre>
</body>
</html>