Bug 717868. (Av1) test_reftests_with_caret.html: Fix "SimpleTest.finish()" handling. r=ehsan.
authorSerge Gautherie <sgautherie.bz@free.fr>
Sat, 14 Jan 2012 01:09:39 +0100
changeset 85624 3eaa7d9f1c69542503dce25d3d52bf0a6c4becfd
parent 85623 1a94821b4655a0faffd44e2e63585bdcb721e3d0
child 85671 27a7f197c6fc99b941d061490dd3bccd2ae5dadf
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs717868
milestone12.0a1
Bug 717868. (Av1) test_reftests_with_caret.html: Fix "SimpleTest.finish()" handling. r=ehsan.
layout/base/tests/test_reftests_with_caret.html
--- a/layout/base/tests/test_reftests_with_caret.html
+++ b/layout/base/tests/test_reftests_with_caret.html
@@ -9,16 +9,18 @@
   <style>
     iframe {
       width: 600px;
       height: 600px;
     }
   </style>
 <script type="text/javascript">
 
+SimpleTest.waitForExplicitFinish();
+
 var canvases = [];
 function callbackTestCanvas(canvas)
 {
   canvases.push(canvas);
 
   if (canvases.length != 2)
     return;
 
@@ -58,17 +60,17 @@ function createIframe(url,next) {
   iframe.remotePageLoaded = remotePageLoaded;
   var me = this;
   var currentIteration = 0;
   function iframeLoadCompleted() {
     var docEl = iframe.contentDocument.documentElement;
     if (docEl.className.indexOf("reftest-wait") >= 0) {
       if (currentIteration++ > MAX_ITERATIONS) {
         ok(false, "iframe load for " + url + " timed out");
-        SimpleTest.finish();
+        endTest();
       } else {
         setTimeout(iframeLoadCompleted, 10);
       }
       return;
     }
     iframe.remotePageLoaded();
     if (next) setTimeout(function(){createIframe(next,null);}, 0)
   }
@@ -77,25 +79,27 @@ function createIframe(url,next) {
 };
 
 function refTest(test,ref) {
   createIframe(test,ref);
 };
 
 var caretBlinkTime = null;
 function endTest() {
-  SimpleTest.finish();
   netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
   var prefs = Components.classes["@mozilla.org/preferences-service;1"]
                         .getService(Components.interfaces.nsIPrefBranch);
   if (caretBlinkTime !== null) {
     prefs.setIntPref("ui.caretBlinkTime", caretBlinkTime);
   } else {
     prefs.clearUserPref("ui.caretBlinkTime");
   }
+
+  // finish(), yet let the test actually end first, to be safe.
+  SimpleTest.executeSoon(SimpleTest.finish);
 }
 
 var isWindows = /WINNT/.test(SpecialPowers.OS);
 
 var tests = [
     [ 'bug389321-2.html' , 'bug389321-2-ref.html' ] ,
     [ 'bug389321-3.html' , 'bug389321-3-ref.html' ] ,
     [ 'bug482484.html'   , 'bug482484-ref.html'   ] ,
@@ -153,18 +157,16 @@ function nextTest() {
     }
     ++testIndex;
   } else {
     endTest();
   }
 }
 function runTests() {
   try {
-    SimpleTest.waitForExplicitFinish();
-
     netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
     var prefs = Components.classes["@mozilla.org/preferences-service;1"]
                           .getService(Components.interfaces.nsIPrefBranch);
     try {
       caretBlinkTime = prefs.getIntPref("ui.caretBlinkTime");
     } catch (e) {}
     prefs.setIntPref("ui.caretBlinkTime", -1);