Bug 1365133 - Properly clean up an observer as well as remove an observer notification that was unreferenced. r?evanxd draft
authorJared Wein <jwein@mozilla.com>
Fri, 07 Jul 2017 15:54:07 -0400
changeset 605559 bc78eadc26b2e61e0a138531de55c495bffb53f5
parent 605557 a35f01464b93cba6ad83a0a379e9c351e6118aad
child 636534 db9d9380c9866d66c5e09846e13147e660234933
push id67454
push userbmo:jaws@mozilla.com
push dateSat, 08 Jul 2017 00:00:12 +0000
reviewersevanxd
bugs1365133
milestone56.0a1
Bug 1365133 - Properly clean up an observer as well as remove an observer notification that was unreferenced. r?evanxd MozReview-Commit-ID: 3VMa53frUIz
browser/components/preferences/in-content-new/privacy.js
browser/components/preferences/in-content-new/tests/browser_change_app_handler.js
--- a/browser/components/preferences/in-content-new/privacy.js
+++ b/browser/components/preferences/in-content-new/privacy.js
@@ -283,21 +283,16 @@ var gPrivacyPane = {
     appendSearchKeywords("viewSecurityDevicesButton", [
       pkiBundle.getString("enable_fips"),
     ]);
     appendSearchKeywords("siteDataSettings", [
       bundlePrefs.getString("siteDataSettings.description"),
       bundlePrefs.getString("removeAllCookies.label"),
       bundlePrefs.getString("removeSelectedCookies.label"),
     ]);
-
-    // Notify observers that the UI is now ready
-    Components.classes["@mozilla.org/observer-service;1"]
-              .getService(Components.interfaces.nsIObserverService)
-              .notifyObservers(window, "privacy-pane-loaded");
   },
 
   // TRACKING PROTECTION MODE
 
   /**
    * Selects the right item of the Tracking Protection radiogroup.
    */
   trackingProtectionReadPrefs() {
--- a/browser/components/preferences/in-content-new/tests/browser_change_app_handler.js
+++ b/browser/components/preferences/in-content-new/tests/browser_change_app_handler.js
@@ -13,24 +13,20 @@ function setupFakeHandler() {
 
   gHandlerSvc.store(infoToModify);
 }
 
 add_task(async function() {
   setupFakeHandler();
 
   // Ensure general pane is loaded before testing.
-  let isGeneralPaneLoaded = false;
-  Services.obs.addObserver(() => {
-    isGeneralPaneLoaded = true;
-  }, "main-pane-loaded");
-
+  let generalPaneLoadedPromise = TestUtils.topicObserved("main-pane-loaded", () => true);
   let prefs = await openPreferencesViaOpenPreferencesAPI("paneGeneral", {leaveOpen: true});
   is(prefs.selectedPane, "paneGeneral", "General pane was selected");
-  await BrowserTestUtils.waitForCondition(() => isGeneralPaneLoaded);
+  await generalPaneLoadedPromise;
   let win = gBrowser.selectedBrowser.contentWindow;
 
   let container = win.document.getElementById("handlersView");
   let ourItem = container.querySelector("richlistitem[type='text/x-test-handler']");
   ok(ourItem, "handlersView is present");
   ourItem.scrollIntoView();
   container.selectItem(ourItem);
   ok(ourItem.selected, "Should be able to select our item.");