Fix test_xulbrowser_plugin_visibility to be more robust and use fewer magic timeouts, review note from bug 583109 comment 52.
authorBenjamin Smedberg <benjamin@smedbergs.us>
Wed, 10 Nov 2010 08:35:46 -0500
changeset 57235 30b383d73524f23ce5ea32b176c580077e21c0e9
parent 57234 cff6e330a3deab267508bc44d73b81681131c7d4
child 57236 bdbef533364f1cdecbbefe16d8d8d9f5e0fd8100
push id16846
push userbsmedberg@mozilla.com
push dateWed, 10 Nov 2010 15:29:47 +0000
treeherdermozilla-central@bdbef533364f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs583109
milestone2.0b8pre
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
Fix test_xulbrowser_plugin_visibility to be more robust and use fewer magic timeouts, review note from bug 583109 comment 52.
modules/plugin/test/mochitest/xulbrowser_plugin_visibility.xul
--- a/modules/plugin/test/mochitest/xulbrowser_plugin_visibility.xul
+++ b/modules/plugin/test/mochitest/xulbrowser_plugin_visibility.xul
@@ -93,37 +93,50 @@
           return;
 
         ok(false, "Plugin in tab 1 never became visible.");
         done();
         return;
       }
 
       clearInterval(paintInterval);
+
       ok(true, "Plugin in tab 1 should be visible.");
       is(plugin1.getPaintCount(), 1 * doubleForDoublePass(),
          "Plugin in tab 1 should have painted once.");
 
       ok(!plugin2.isVisible(), "Plugin in tab 2 should not be visible.");
       is(plugin2.getPaintCount(), 0,
          "Plugin in tab 2 should not have painted.");
 
       tabbox.selectedIndex = 1;
-      setTimeout(part2, 100);
+      paintGiveUp = Date.now() + kTimeout;
+      paintInterval = setInterval(part2, 100);
     }
 
     function part2() {
+      if (!plugin2.isVisible()) {
+        if (Date.now() < paintGiveUp)
+          return;
+
+        ok(false, "Plugin in tab 2 never became visible.");
+        done();
+        return;
+      }
+
+      clearInterval(paintInterval);
+
+      ok(true, "Plugin in tab 2 became visible.");
+      is(plugin2.getPaintCount(), 1 * doubleForDoublePass(),
+         "Plugin in tab 2 should have painted once.");
+
       ok(!plugin1.isVisible(), "Plugin in tab 1 should have become invisible.");
       is(plugin1.getPaintCount(), 1 * doubleForDoublePass(),
          "Plugin in tab 1 should not have repainted.");
 
-      ok(plugin2.isVisible(), "Plugin in tab 2 should have become visible.");
-      is(plugin2.getPaintCount(), 1 * doubleForDoublePass(),
-         "Plugin in tab 2 should have painted once.");
-
       // Setcolor invalidates
       plugin1.setColor('FF00FF00');
       plugin2.setColor('FF00FF00');
 
       setTimeout(part3, 500);
     }
 
     function part3() {