Bug 1343571 - When clicking an action button of a PopupNotification in an inactive window, focus the window instead of performing the action, r=past.
authorFlorian Quèze <florian@queze.net>
Thu, 16 Mar 2017 19:14:22 +0100
changeset 398635 34554df9f50cb34482838c1200fea11cb87b9095
parent 398634 cfe7fdc401e0b4eb8eb9c77f9b3da85b7ad23450
child 398636 b5df0025c79dc5cce54216194ab9ba8ddb38d222
push id1490
push usermtabara@mozilla.com
push dateMon, 31 Jul 2017 14:08:16 +0000
treeherdermozilla-release@70e32e6bf15e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspast
bugs1343571
milestone55.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 1343571 - When clicking an action button of a PopupNotification in an inactive window, focus the window instead of performing the action, r=past.
toolkit/modules/PopupNotifications.jsm
--- a/toolkit/modules/PopupNotifications.jsm
+++ b/toolkit/modules/PopupNotifications.jsm
@@ -1397,16 +1397,23 @@ PopupNotifications.prototype = {
       if (!notification.recordedTelemetryMainAction) {
         notification.recordedTelemetryMainAction = true;
         notification._recordTelemetry("POPUP_NOTIFICATION_MAIN_ACTION_MS",
                                       timeSinceCreated);
       }
     }
 
     if (type == "buttoncommand" || type == "secondarybuttoncommand") {
+      if (Services.focus.activeWindow != this.window) {
+        Services.console.logStringMessage("PopupNotifications._onButtonEvent: " +
+                                          "Button click happened before the window was focused");
+        this.window.focus();
+        return;
+      }
+
       let timeSinceShown = this.window.performance.now() - notification.timeShown;
       if (timeSinceShown < this.buttonDelay) {
         Services.console.logStringMessage("PopupNotifications._onButtonEvent: " +
                                           "Button click happened before the security delay: " +
                                           timeSinceShown + "ms");
         return;
       }
     }