Bug 734172 - Stop blaming tests that replace the first tab for leaking. r=ttaubert
authorDão Gottwald <dao@mozilla.com>
Thu, 17 May 2012 16:41:08 +0200
changeset 98283 c220dcb86e4e3b0bf5a20d5298608f443585fbd8
parent 98282 ee527adf9d444a80437b05dbcad2bb875937286e
child 98284 908e9a9acabd232d7c60e691a49717d545336b61
push id1116
push userlsblakk@mozilla.com
push dateMon, 16 Jul 2012 19:38:18 +0000
treeherdermozilla-beta@95f959a8b4dc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersttaubert
bugs734172
milestone15.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 734172 - Stop blaming tests that replace the first tab for leaking. r=ttaubert
build/automationutils.py
testing/mochitest/browser-test.js
--- a/build/automationutils.py
+++ b/build/automationutils.py
@@ -454,17 +454,17 @@ def wrapCommand(cmd):
   return cmd
 
 class ShutdownLeakLogger(object):
   """
   Parses the mochitest run log when running a debug build, assigns all leaked
   DOM windows (that are still around after test suite shutdown, despite running
   the GC) to the tests that created them and prints leak statistics.
   """
-  MAX_LEAK_COUNT = 10
+  MAX_LEAK_COUNT = 7
 
   def __init__(self, logger):
     self.logger = logger
     self.tests = []
     self.leakedWindows = {}
     self.leakedDocShells = set()
     self.currentTest = None
     self.seenShutdown = False
--- a/testing/mochitest/browser-test.js
+++ b/testing/mochitest/browser-test.js
@@ -244,16 +244,24 @@ Tester.prototype = {
       this.currentTest.scope = null;
     }
 
     // Check the window state for the current test before moving to the next one.
     // This also causes us to check before starting any tests, since nextTest()
     // is invoked to start the tests.
     this.waitForWindowsState((function () {
       if (this.done) {
+        // Many tests randomly add and remove tabs, resulting in the original
+        // tab being replaced by a new one. The last test in the suite doing this
+        // will erroneously be blamed for leaking this new tab's DOM window and
+        // docshell until shutdown. We can prevent this by removing this tab now
+        // that all tests are done.
+        gBrowser.addTab();
+        gBrowser.removeCurrentTab();
+
         // Schedule GC and CC runs before finishing in order to detect
         // DOM windows leaked by our tests or the tested code.
         Cu.schedulePreciseGC((function () {
           let winutils = window.QueryInterface(Ci.nsIInterfaceRequestor)
                                .getInterface(Ci.nsIDOMWindowUtils);
           winutils.garbageCollect();
           winutils.garbageCollect();
           winutils.garbageCollect();