Bug 1049786 - Hopeful fix for the timeouts in bug 1051667. r=adw
authorMartijn Wargers <mwargers@mozilla.com>
Mon, 11 Aug 2014 11:04:07 -0700
changeset 198970 4d2bfef488bf74e473a5db8655259e3dc0f2f3ac
parent 198969 780c948d79f3ddc9a6910e08e477e13f6db23ffe
child 198971 e208104d663b159d2ac03977c37151224d102859
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersadw
bugs1049786, 1051667
milestone34.0a1
Bug 1049786 - Hopeful fix for the timeouts in bug 1051667. r=adw
toolkit/content/tests/browser/browser_bug295977_autoscroll_overflow.js
--- a/toolkit/content/tests/browser/browser_bug295977_autoscroll_overflow.js
+++ b/toolkit/content/tests/browser/browser_bug295977_autoscroll_overflow.js
@@ -192,20 +192,25 @@ function test()
   }
 
   function onFocus() {
     doc = gBrowser.contentDocument;
     nextTest();
   }
 
   function endTest() {
-    // remove 2 tabs that were opened by middle-click on links
-    gBrowser.removeTab(gBrowser.tabs[gBrowser.visibleTabs.length - 1]);
-    gBrowser.removeTab(gBrowser.tabs[gBrowser.visibleTabs.length - 1]);
+    registerCleanupFunction(function() {
+      // restore the changed prefs
+      if (Services.prefs.prefHasUserValue(kPrefName_AutoScroll))
+        Services.prefs.clearUserPref(kPrefName_AutoScroll);
+      if (Services.prefs.prefHasUserValue("middlemouse.paste"))
+        Services.prefs.clearUserPref("middlemouse.paste");
 
-    // restore the changed prefs
-    if (Services.prefs.prefHasUserValue(kPrefName_AutoScroll))
-      Services.prefs.clearUserPref(kPrefName_AutoScroll);
+      // remove 2 tabs that were opened by middle-click on links
+      while (gBrowser.visibleTabs.length > 1) {
+        gBrowser.removeTab(gBrowser.visibleTabs[gBrowser.visibleTabs.length - 1]);
+      }
+    });
 
     // waitForFocus() fixes a failure in the next test if the latter runs too soon.
     waitForFocus(finish);
   }
 }