Bug 506850 - mochitest-chrome: test_action_keys_respect_focus.xul and test_clear_button_disabled.xul (intermittently) report "Test timed out"; (Bv1a) Need pref("accessibility.tabfocus", 7) on MacOSX (too); r=neil
authorSerge Gautherie <sgautherie.bz@free.fr>
Thu, 13 Aug 2009 01:39:37 +0200
changeset 3292 3bf49c355cb2785af8984be75b7b731e7aac9958
parent 3291 2383f23818c276a24271fed9aa512b737b71bc34
child 3293 5ab96c3ff2e57e386d01ad0366bf6c048b6ee57c
push idunknown
push userunknown
push dateunknown
reviewersneil
bugs506850
Bug 506850 - mochitest-chrome: test_action_keys_respect_focus.xul and test_clear_button_disabled.xul (intermittently) report "Test timed out"; (Bv1a) Need pref("accessibility.tabfocus", 7) on MacOSX (too); r=neil
suite/common/downloads/tests/chrome/test_action_keys_respect_focus.xul
--- a/suite/common/downloads/tests/chrome/test_action_keys_respect_focus.xul
+++ b/suite/common/downloads/tests/chrome/test_action_keys_respect_focus.xul
@@ -53,16 +53,33 @@
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
 
   <script type="application/javascript">
   <![CDATA[
 
+// accessibility.tabfocus must be set to value 7 before running test also
+// on a mac.
+function setOrRestoreTabFocus(newValue) {
+  const prefSvcContractID = "@mozilla.org/preferences-service;1";
+  const prefSvcIID = Components.interfaces.nsIPrefService;
+  var prefs = Components.classes[prefSvcContractID].getService(prefSvcIID)
+                                                   .getBranch("accessibility.");
+  if (!newValue) {
+    try {
+      prefs.clearUserPref("tabfocus");
+    } catch(ex) {}
+  } else {
+    prefs.setIntPref("tabfocus", newValue);
+  }
+}
+
+
 var openInvokeCount = 0;
 var removeInvokeCount = 0;
 var resumeInvokeCount = 0;
 var testedFunctions = {
   openDownload : null,
   removeDownload : null,
   resumeDownload : null
 };
@@ -76,22 +93,26 @@ function getCounter(aFn)
       return function() removeInvokeCount++;
     case "resumeDownload":
       return function() resumeInvokeCount++;
   }
 }
 
 function backupTestedFunction(aFn, aWin)
 {
+  ok(true, "backupTestedFunction('" + aFn + "')");
+
   [testedFunctions[aFn], aWin[aFn]] = [aWin[aFn], getCounter(aFn)];
 }
 function restoreTestedFunction(aFn, aWin)
 {
   aWin[aFn] = testedFunctions[aFn];
   testedFunctions[aFn] = null;
+
+  ok(true, "restoreTestedFunction('" + aFn + "')");
 }
 
 function keyPressObs(aWin, aKey)
 {
   this.mWin = aWin;
   this.mKey = aKey;
 }
 keyPressObs.prototype = {
@@ -161,16 +182,18 @@ dlObs.prototype = {
   },
   onStateChange: function(a, b, c, d, e) { },
   onProgressChange: function(a, b, c, d, e, f, g) { },
   onSecurityChange: function(a, b, c, d) { }
 };
 
 function test()
 {
+  setOrRestoreTabFocus(7);
+
   var dm = Components.classes["@mozilla.org/download-manager;1"]
                      .getService(Components.interfaces.nsIDownloadManager);
 
   function addDownload()
   {
     function createURI(aObj)
     {
       var ios = Components.classes["@mozilla.org/network/io-service;1"]
@@ -336,16 +359,17 @@ function test()
           break;
         case 8:
           is(openInvokeCount, 1, "Clear List: Enter didn't open download");
           restoreTestedFunction("openDownload", win);
 
           // We're done here
           obs.removeObserver(testObs, DLMGR_UI_DONE);
           win.close();
+          setOrRestoreTabFocus(0);
           SimpleTest.finish();
 
           break;
       }
     }
   };
   obs.addObserver(testObs, DLMGR_UI_DONE, false);