Bug 1592776 - Fix cleanup of mock service registration. r=dom-workers-and-storage-reviewers,asuth
☠☠ backed out by 4f7f6d6bc618 ☠ ☠
authorSimon Giesecke <sgiesecke@mozilla.com>
Tue, 02 Jun 2020 11:09:58 +0000
changeset 597596 9af9690fcef1f8f9377dc6fc876eccf205c51389
parent 597595 189c39e5f2d18f87252b670f58bfef39bb765b59
child 597597 e0a47494eaeafc78099c58c94cdc01546c9f47a5
push id13310
push userffxbld-merge
push dateMon, 29 Jun 2020 14:50:06 +0000
treeherdermozilla-beta@15a59a0afa5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdom-workers-and-storage-reviewers, asuth
bugs1592776
milestone79.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 1592776 - Fix cleanup of mock service registration. r=dom-workers-and-storage-reviewers,asuth Differential Revision: https://phabricator.services.mozilla.com/D77781
dom/notification/test/mochitest/MockServices.js
--- a/dom/notification/test/mochitest/MockServices.js
+++ b/dom/notification/test/mochitest/MockServices.js
@@ -112,16 +112,23 @@ var MockServices = (function() {
       return this.QueryInterface(aIID);
     },
   };
   mockAlertsService = SpecialPowers.wrapCallbackObject(mockAlertsService);
 
   // MockServices API
   return {
     register() {
+      this.originalAlertsCID = registrar.contractIDToCID(
+        ALERTS_SERVICE_CONTRACT_ID
+      );
+      this.originalSystemAlertsCID = registrar.contractIDToCID(
+        SYSTEM_ALERTS_SERVICE_CONTRACT_ID
+      );
+
       registrar.registerFactory(
         MOCK_ALERTS_CID,
         "alerts service",
         ALERTS_SERVICE_CONTRACT_ID,
         mockAlertsService
       );
 
       registrar.registerFactory(
@@ -130,15 +137,32 @@ var MockServices = (function() {
         SYSTEM_ALERTS_SERVICE_CONTRACT_ID,
         mockAlertsService
       );
     },
 
     unregister() {
       registrar.unregisterFactory(MOCK_ALERTS_CID, mockAlertsService);
       registrar.unregisterFactory(MOCK_SYSTEM_ALERTS_CID, mockAlertsService);
+
+      // Passing `null` for the factory re-maps the contract ID to the
+      // entry for its original CID.
+
+      registrar.registerFactory(
+        this.originalAlertsCID,
+        "alerts service",
+        ALERTS_SERVICE_CONTRACT_ID,
+        null
+      );
+
+      registrar.registerFactory(
+        this.originalSystemAlertsCID,
+        "system alerts service",
+        SYSTEM_ALERTS_SERVICE_CONTRACT_ID,
+        null
+      );
     },
 
     activeAlertNotifications,
 
     activeAppNotifications,
   };
 })();