Bug 589442 - Add a flush in this test in order to increase the chances that the old document survives in the bfcache. r=bent, a=test-only
authorMarkus Stange <mstange@themasta.com>
Sat, 27 Nov 2010 14:52:33 +0100
changeset 58322 4d4065d46e80674cb32d5a3a2ca35114e64f4997
parent 58321 6aad676f008c2647ef32d474aa0a44d4480bdfa4
child 58323 a5500a75626857a4521ddb01cca5b409411a2dff
push id1
push usershaver@mozilla.com
push dateTue, 04 Jan 2011 17:58:04 +0000
reviewersbent, test-only
bugs589442
milestone2.0b8pre
Bug 589442 - Add a flush in this test in order to increase the chances that the old document survives in the bfcache. r=bent, a=test-only
dom/src/threads/test/test_suspend.html
--- a/dom/src/threads/test/test_suspend.html
+++ b/dom/src/threads/test/test_suspend.html
@@ -1,9 +1,9 @@
-<!DOCTYPE HTML>
+<!DOCTYPE HTML>
 <html>
 <head>
   <title>Test for DOM Worker Threads</title>
   <script type="text/javascript" src="/MochiKit/packed.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>
@@ -65,46 +65,51 @@
       iframe.history.back();
     }
   }
 
   function badOnloadCallback() {
     if (finished) {
       return;
     }
-    ok(false, "shouldn't get here!");
+    ok(false, "We don't want suspend_iframe.html to fire a new load event, we want it to come out of the bfcache!");
     finishTest();
   }
 
   function suspendCallback() {
     if (finished) {
       return;
     }
     is(iframe.location, "about:blank", "Wrong url!");
     is(suspended, false, "Already suspended?");
     is(resumed, false, "Already resumed?");
     setCachePref(false);
     suspended = true;
-    iframe.onload = badOnloadCallback;
+    var iframeElement = document.getElementById("workerFrame");
+    iframeElement.onload = badOnloadCallback;
     oldMessageCount = lastCount;
     interval = setInterval(waitInterval, 1000);
   }
 
   function messageCallback(data) {
     if (finished) {
       return;
     }
 
     if (!suspended) {
       ok(lastCount === undefined || lastCount == data - 1,
          "Data is inconsistent");
       lastCount = data;
       if (lastCount == 50) {
         setCachePref(true);
         iframe.location = "about:blank";
+        // We want suspend_iframe.html to go into bfcache, so we need to flush
+        // out all pending notifications. Otherwise, if they're flushed too
+        // late, they could kick us out of the bfcache again.
+        iframe.document.body.offsetTop;
       }
       return;
     }
 
     var newLocation =
       window.location.toString().replace("test_suspend.html",
                                          "suspend_iframe.html");
     is(newLocation.indexOf(iframe.location.toString()), 0, "Wrong url!");