Bug 1356376: Wait for message manager to disconnect after closing content page. r?aswan draft
authorKris Maglione <maglione.k@gmail.com>
Thu, 24 Aug 2017 14:57:18 -0700
changeset 652489 6dab9d07dc51be6a2747a523474f996ea6a12389
parent 652488 80a0c38278154ddf519ee8ff9e7239e938540b37
child 652490 81f1033903be8e2aa241e496167de64b6332119d
push id76071
push usermaglione.k@gmail.com
push dateThu, 24 Aug 2017 21:57:48 +0000
reviewersaswan
bugs1356376
milestone57.0a1
Bug 1356376: Wait for message manager to disconnect after closing content page. r?aswan This may or may not fix the intermittent, but hopefully it will. MozReview-Commit-ID: BR0BtV4BPdq
toolkit/components/extensions/ExtensionXPCShellUtils.jsm
--- a/toolkit/components/extensions/ExtensionXPCShellUtils.jsm
+++ b/toolkit/components/extensions/ExtensionXPCShellUtils.jsm
@@ -18,16 +18,18 @@ XPCOMUtils.defineLazyModuleGetter(this, 
 XPCOMUtils.defineLazyModuleGetter(this, "Extension",
                                   "resource://gre/modules/Extension.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "FileUtils",
                                   "resource://gre/modules/FileUtils.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "Schemas",
                                   "resource://gre/modules/Schemas.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "Services",
                                   "resource://gre/modules/Services.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "TestUtils",
+                                  "resource://testing-common/TestUtils.jsm");
 
 XPCOMUtils.defineLazyGetter(this, "Management", () => {
   const {Management} = Cu.import("resource://gre/modules/Extension.jsm", {});
   return Management;
 });
 
 /* exported ExtensionTestUtils */
 
@@ -136,20 +138,25 @@ class ContentPage {
 
     this.browser.loadURI(url);
     return promiseBrowserLoaded(this.browser, url, redirectUrl);
   }
 
   async close() {
     await this.browserReady;
 
+    let {messageManager} = this.browser;
+
     this.browser = null;
 
     this.windowlessBrowser.close();
     this.windowlessBrowser = null;
+
+    await TestUtils.topicObserved("message-manager-disconnect",
+                                  subject => subject === messageManager);
   }
 }
 
 class ExtensionWrapper {
   constructor(testScope, extension = null) {
     this.testScope = testScope;
 
     this.extension = null;