Bug 649012 - Fix some flaky mochitests which rely on non-zero timeout values; rs=ted
☠☠ backed out by 1853104e4525 ☠ ☠
authorEhsan Akhgari <ehsan@mozilla.com>
Sat, 16 Apr 2011 19:39:34 -0400
changeset 68204 d407ee4dabcc3cca4601035507ce5ae6e77aa59b
parent 68203 8a2481966e27502786b868a8e7b34a382cf0caad
child 68205 1853104e4525658e236a5dd9247a2dc1b5f9afb9
push id19539
push usereakhgari@mozilla.com
push dateSun, 17 Apr 2011 03:05:46 +0000
treeherdermozilla-central@d407ee4dabcc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted
bugs649012
milestone6.0a1
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 649012 - Fix some flaky mochitests which rely on non-zero timeout values; rs=ted
content/base/test/chrome/test_bug430050.xul
content/base/test/file_bug503473-frame.sjs
content/base/test/test_bug300992.html
content/base/test/test_bug343596.html
content/base/test/test_bug513194.html
editor/libeditor/text/tests/test_bug527935.html
--- a/content/base/test/chrome/test_bug430050.xul
+++ b/content/base/test/chrome/test_bug430050.xul
@@ -34,19 +34,19 @@ https://bugzilla.mozilla.org/show_bug.cg
       function(evt) {
         if (evt.target == evt.currentTarget) {
           document.getElementById('b').setAttribute("src",
                                                     "data:text/plain,failed");
           document.getElementById('b').loadURI('data:text/plain,succeeded',
                                                null,
                                                'UTF-8');
         }
+        setTimeout(endTest, 0);
       }, true);
     document.documentElement.setAttribute("foo", "bar");
-    setTimeout(endTest, 100);
   }
   
   SimpleTest.waitForExplicitFinish();
   addLoadEvent(startTest);
 
   ]]></script>
   <browser flex="1" id="b"/>
 </window>
--- a/content/base/test/file_bug503473-frame.sjs
+++ b/content/base/test/file_bug503473-frame.sjs
@@ -8,16 +8,16 @@ function handleRequest(request, response
     '<!DOCTYPE html>' +
     '<div></div>' +
     '<script>' +
     'function doWrite() {' +
     '  document.write("<p></p>");' +
     '  parent.done();' +
     '  document.close();' +
     '}' +
-    'setTimeout(doWrite, 1);' +
+    'setTimeout(doWrite, 0);' +
     '</script>' 
   );
 
   response.bodyOutputStream.flush();
   // leave the stream open
 }
 
--- a/content/base/test/test_bug300992.html
+++ b/content/base/test/test_bug300992.html
@@ -30,17 +30,17 @@ document.onreadystatechange = function (
   is(document.readyState + '1', states[i++], 'readystatechange event "on" handler');
 };
 document.addEventListener('readystatechange', function(event) {
   is(document.readyState + '2', states[i++], 'readystatechange event document listener');
 }, false);
 window.addEventListener('readystatechange', function(event) {
   ok(false, 'window listener', 'readystatechange event should not bubble to window');
 }, false);
-setTimeout(function() {
+addLoadEvent(function() {
   is(i, states.length, 'readystatechange event count');
   SimpleTest.finish();
-}, 1000);
+});
 
 </script>
 </pre>
 </body>
 </html>
--- a/content/base/test/test_bug343596.html
+++ b/content/base/test/test_bug343596.html
@@ -35,17 +35,17 @@ try{
 catch(ex){
   // Note that this catch block does not execute.
   ok(false, "this catch block should not execute");
 }
 
 setTimeout(function(){
 ok(true,"setTimeout still executes after bogus script insertion"); 
 window.error = errorHandler;
-SimpleTest.finish();}, 200);
+SimpleTest.finish();}, 0);
 
 
 
 
 </script>
 </pre>
 </body>
 </html>
--- a/content/base/test/test_bug513194.html
+++ b/content/base/test/test_bug513194.html
@@ -59,14 +59,14 @@ https://bugzilla.mozilla.org/show_bug.cg
 
   document.write("<style>qux { foo: bar; }<\/style>");
 
   function done() {
     netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
     consoleListener.finish();
     consoleService.unregisterListener(consoleListener);
   }
-  setTimeout(done, 1);
+  setTimeout(done, 0);
 </script>
 </pre>
 </body>
 </html>
 
--- a/editor/libeditor/text/tests/test_bug527935.html
+++ b/editor/libeditor/text/tests/test_bug527935.html
@@ -43,25 +43,33 @@ SimpleTest.waitForFocus(function() {
       var event = document.createEvent("KeyboardEvent");
 
       event.initKeyEvent("keypress", true, true, null, false, false,
                          false, false, 0, "f".charCodeAt(0));
       newInput.value = "";
       newInput.focus();
       newInput.dispatchEvent(event);
 
-      setTimeout(function() {
+      hitEventLoop(function() {
         ok(!popupShown, "Popup must not be opened");
         SpecialPowers.removeAutoCompletePopupEventListener(window, listener);
         SimpleTest.finish();
-      }, 1000);
+      }, 100);
     }, 0);
   }, false);
 
   initValue.focus();
   initValue.value = "foo";
   synthesizeKey("VK_ENTER", {});
 });
 
+function hitEventLoop(func, times) {
+  if (times > 0) {
+    setTimeout(hitEventLoop, 0, func, times - 1);
+  } else {
+    setTimeout(func, 0);
+  }
+}
+
 </script>
 </pre>
 </body>
 </html>