Bug 1139021 - Don't run extra collections in the parent process for the mochitest window leak detector. r=jmaher
authorAndrew McCreight <continuation@gmail.com>
Wed, 04 Mar 2015 14:00:24 -0800
changeset 231921 d0d72ca21cb76fb886dcbe4589daad53a447b11f
parent 231920 76aa36cef867e5f024917be899bb6b2bd5d681e8
child 231922 9f6d6c54a10dcb30ad909609ccec249dc594c25a
push idunknown
push userunknown
push dateunknown
reviewersjmaher
bugs1139021
milestone39.0a1
Bug 1139021 - Don't run extra collections in the parent process for the mochitest window leak detector. r=jmaher
testing/mochitest/ShutdownLeaksCollector.jsm
testing/mochitest/browser-test.js
--- a/testing/mochitest/ShutdownLeaksCollector.jsm
+++ b/testing/mochitest/ShutdownLeaksCollector.jsm
@@ -12,16 +12,22 @@ this.EXPORTED_SYMBOLS = ["ContentCollect
 
 // This listens for the message "browser-test:collect-request". When it gets it,
 // it runs some GCs and CCs, then prints out a message indicating the collections
 // are complete. Mochitest uses this information to determine when windows and
 // docshells should be destroyed.
 
 var ContentCollector = {
   init: function() {
+      let processType = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime).processType;
+      if (processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT) {
+        // In the main process, we handle triggering collections in browser-test.js
+        return;
+      }
+
     let cpmm = Cc["@mozilla.org/childprocessmessagemanager;1"]
                  .getService(Ci.nsISyncMessageSender);
     cpmm.addMessageListener("browser-test:collect-request", this);
   },
 
   receiveMessage: function(aMessage) {
     switch (aMessage.name) {
       case "browser-test:collect-request":
--- a/testing/mochitest/browser-test.js
+++ b/testing/mochitest/browser-test.js
@@ -286,16 +286,21 @@ Tester.prototype = {
       this.nextTest();
     }
     else{
       Services.console.unregisterListener(this);
       Services.obs.removeObserver(this, "chrome-document-global-created");
       Services.obs.removeObserver(this, "content-document-global-created");
       this.Promise.Debugging.clearUncaughtErrorObservers();
       this._treatUncaughtRejectionsAsFailures = false;
+
+      // In the main process, we print the ShutdownLeaksCollector message here.
+      let pid = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime).processID;
+      dump("Completed ShutdownLeaks collections in process " + pid + "\n");
+
       this.dumper.structuredLogger.info("TEST-START | Shutdown");
 
       if (this.tests.length) {
         this.dumper.structuredLogger.info("Browser Chrome Test Summary");
         this.dumper.structuredLogger.info("Passed:  " + passCount);
         this.dumper.structuredLogger.info("Failed:  " + failCount);
         this.dumper.structuredLogger.info("Todo:    " + todoCount);
       } else {