Bug 439164: refactor test_bug413310 to avoid intermittent timing-related failures
authorBoris Zbarsky <bzbarsky@mit.edu>
Tue, 08 Jul 2008 18:04:40 -0400
changeset 15743 6f6c7d842726b315830651f1158be39956726fcb
parent 15742 f514587dd532f54a6ec4532b4916f96d38d3e524
child 15744 9e89b2cf5824a2384071a7801e1e531c704b2fc4
push idunknown
push userunknown
push dateunknown
bugs439164, 413310
milestone1.9.1a1pre
Bug 439164: refactor test_bug413310 to avoid intermittent timing-related failures
docshell/test/test_bug413310.html
--- a/docshell/test/test_bug413310.html
+++ b/docshell/test/test_bug413310.html
@@ -7,32 +7,27 @@ https://bugzilla.mozilla.org/show_bug.cg
   <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.
+// modified accordingly!  It assumes that subframes do NOTget bfcached.
 var onloadCount = 0;
 
 var step = -1;  // One increment will come from the initial subframe onload.
+                // Note that this script should come before the subframe,
+                // so that doNextStep is defined when its onload handler fires.
 
 var textContent;
 
 SimpleTest.waitForExplicitFinish();
 
 addLoadEvent(doNextStep);
 
 function doNextStep() {
@@ -87,12 +82,20 @@ function doNextStep() {
          "Unexpected subframe location");
       is(textContent, $("i").contentDocument.body.textContent,
          "Did a load when going back?");
       SimpleTest.finish();
       break;
   }
 }
 </script>
+<!-- Use a timeout in onload so that we don't do a load immediately inside onload -->
+<iframe id="i" src="bug413310-subframe.html" onload="setTimeout(doNextStep, 20)">
+</iframe>
+</p>
+<div id="content" style="display: none">
+  
+</div>
+<pre id="test">
 </pre>
 </body>
 </html>