Bug 581018 - random failure in docshell test_bug293235.xul - wait both visit and pageShow. r=sdwilsh
authorMarco Bonardo <mbonardo@mozilla.com>
Fri, 23 Jul 2010 00:40:04 +0200
changeset 48103 9f94b4f804635587fd0e115411499bf775917e96
parent 48102 9d16542a1af28778544ddd3e5947d4224fb4020e
child 48104 8d7913fe2ecf719679153649e5ab5a60279a34b5
push idunknown
push userunknown
push dateunknown
reviewerssdwilsh
bugs581018, 293235
milestone2.0b3pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 581018 - random failure in docshell test_bug293235.xul - wait both visit and pageShow. r=sdwilsh
docshell/test/chrome/bug293235_window.xul
--- a/docshell/test/chrome/bug293235_window.xul
+++ b/docshell/test/chrome/bug293235_window.xul
@@ -87,32 +87,44 @@
       link1.className = "";
       function snapshotsEqual(snap1, snap2) {
         return compareSnapshots(snap1, snap2, true)[0];
       }
       ok(!snapshotsEqual(refLink, refVisited), "references should not match");
       ok(snapshotsEqual(refLink, snapshotWindow(TestWindow.getWindow())),
          "link should initially be blue");
 
+      let observedVisit = false, observedPageShow = false;
+      function maybeRunNextTest() {
+        ok(true, "maybe run next test? visited: " + observedVisit + " pageShow: " + observedPageShow);
+        if (observedVisit && observedPageShow)
+          nextTest();
+      }
+
       // Because adding visits is async, we will not be notified imemdiately.
       let visitObserver = {
         observe: function(aSubject, aTopic, aData)
         {
           if (!testURI.equals(aSubject.QueryInterface(Ci.nsIURI))) {
             return;
           }
           os.removeObserver(this, aTopic);
-          SimpleTest.executeSoon(nextTest);
+          observedVisit = true;
+          maybeRunNextTest();
         },
       };
       os.addObserver(visitObserver, "uri-visit-saved", false);
 
       // Load the page that the link on the previous page points to.
       doPageNavigation({
-        uri: getHttpUrl("bug293235_p2.html")
+        uri: getHttpUrl("bug293235_p2.html"),
+        onNavComplete: function() {
+          observedPageShow = true;
+          maybeRunNextTest();
+        }
       });
       yield;
 
       // And the nodes get notified after the "link-visited" topic, so
       // we need to execute soon...
       SimpleTest.executeSoon(nextTest);
       yield;