Bug 1265797 - WebExtensions Notification observer should not remove the notificationId on alertshow. r=aswan
authorBob Silverberg <bsilverberg@mozilla.com>
Tue, 10 May 2016 12:14:44 -0400
changeset 297691 5bdcb5693f01c712b82da8b63e1c83abf5e743e8
parent 297690 3dc42f7cf44937f84eaa80a6660a5b003ce56aaa
child 297692 71e53cab38fd88cf4938cd6c297b98d1468da65a
push id30265
push userkwierso@gmail.com
push dateTue, 17 May 2016 21:15:15 +0000
treeherdermozilla-central@f3f2fa1d7eed [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaswan
bugs1265797
milestone49.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 1265797 - WebExtensions Notification observer should not remove the notificationId on alertshow. r=aswan MozReview-Commit-ID: 4RGVdSrF4OU
toolkit/components/extensions/ext-notifications.js
--- a/toolkit/components/extensions/ext-notifications.js
+++ b/toolkit/components/extensions/ext-notifications.js
@@ -49,29 +49,32 @@ Notification.prototype = {
       // This will fail if the OS doesn't support this function.
     }
     notificationsMap.get(this.extension).delete(this.id);
   },
 
   observe(subject, topic, data) {
     let notifications = notificationsMap.get(this.extension);
 
+    function emitAndDelete(event) {
+      notifications.emit(event, data);
+      notifications.delete(this.id);
+    }
+
     // Don't try to emit events if the extension has been unloaded
     if (!notifications) {
       return;
     }
 
     if (topic === "alertclickcallback") {
-      notifications.emit("clicked", data);
+      emitAndDelete("clicked");
     }
     if (topic === "alertfinished") {
-      notifications.emit("closed", data);
+      emitAndDelete("closed");
     }
-
-    notifications.delete(this.id);
   },
 };
 
 /* eslint-disable mozilla/balanced-listeners */
 extensions.on("startup", (type, extension) => {
   let map = new Map();
   EventEmitter.decorate(map);
   notificationsMap.set(extension, map);