Bug 1638502 - Clean up DoH doorhanger's TabProgressListener properly. r=johannh
authorNihanth Subramanya <nhnt11@gmail.com>
Tue, 26 May 2020 15:43:30 +0000
changeset 532207 795f01419fc5492ca005234d3a36b288f4199055
parent 532206 0ab7279a73ad3040c584217ac258580f0b121641
child 532208 a192fd4ed14b35c6a6f56c1e528abaefe5cad6b1
push id117068
push usernhnt11@gmail.com
push dateTue, 26 May 2020 17:47:01 +0000
treeherderautoland@a192fd4ed14b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjohannh
bugs1638502
milestone78.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 1638502 - Clean up DoH doorhanger's TabProgressListener properly. r=johannh Differential Revision: https://phabricator.services.mozilla.com/D76786
browser/extensions/doh-rollout/background.js
browser/extensions/doh-rollout/experiments/doorhanger/api.js
browser/extensions/doh-rollout/experiments/doorhanger/schema.json
--- a/browser/extensions/doh-rollout/background.js
+++ b/browser/extensions/doh-rollout/background.js
@@ -649,16 +649,18 @@ const setup = {
 
       try {
         browser.captivePortal.onStateChange.removeListener(
           rollout.onCaptiveStateChanged
         );
       } catch (e) {
         // Captive Portal Service is disabled.
       }
+
+      await browser.experiments.doorhanger.cancel();
     }
   });
 
   if (await rollout.getSetting(DOH_ENABLED_PREF, false)) {
     await setup.start();
   } else if (
     (await rollout.getSetting(DOH_DONE_FIRST_RUN_PREF, false)) &&
     (await stateManager.shouldRunHeuristics())
--- a/browser/extensions/doh-rollout/experiments/doorhanger/api.js
+++ b/browser/extensions/doh-rollout/experiments/doorhanger/api.js
@@ -154,16 +154,19 @@ this.doorhanger = class doorhanger exten
                 if (closing) {
                   return;
                 }
                 win.gBrowser.removeTabsProgressListener(tabsProgressListener);
               }
             );
             return true;
           },
+          async cancel() {
+            EveryWindow.unregisterCallback("doh-rollout");
+          },
           onDoorhangerAccept: new EventManager({
             context,
             name: "doorhanger.onDoorhangerAccept",
             register: fire => {
               let listener = (value, tabId) => {
                 fire.async(tabId);
               };
               doorhangerEventEmitter.on("doorhanger-accept", listener);
@@ -184,9 +187,12 @@ this.doorhanger = class doorhanger exten
                 doorhangerEventEmitter.off("doorhanger-decline", listener);
               };
             },
           }).api(),
         },
       },
     };
   }
+  onShutdown() {
+    EveryWindow.unregisterCallback("doh-rollout");
+  }
 };
--- a/browser/extensions/doh-rollout/experiments/doorhanger/schema.json
+++ b/browser/extensions/doh-rollout/experiments/doorhanger/schema.json
@@ -32,16 +32,23 @@
                 "type": "string"
               },
               "cancelAccessKey": {
                 "type": "string"
               }
             }
           }
         ]
+      },
+      {
+        "name": "cancel",
+        "type": "function",
+        "description": "Cancel showing the notification.",
+        "async": true,
+        "parameters": []
       }
     ],
     "events": [
       {
         "name": "onDoorhangerAccept",
         "type": "function",
         "description": "The user clicked 'OK, Got It'",
         "parameters": [