Bug 1335985 - Reset timeShown on window activation so that persistent notifications get the security delay again. r=past, a=lizzard
authorFlorian Quèze <florian@queze.net>
Mon, 20 Feb 2017 23:29:36 +0100
changeset 376462 1ec2eef6670b2ea5e00d6bc688222130d6cf375f
parent 376461 92c51788ef5270afae43d05c9661e99fb172e4da
child 376463 66e9dc9f094f790c94c7f2a5df0757c8f3b81e78
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspast, lizzard
bugs1335985
milestone53.0a2
Bug 1335985 - Reset timeShown on window activation so that persistent notifications get the security delay again. r=past, a=lizzard
browser/base/content/test/popupNotifications/browser_popupNotification_5.js
toolkit/modules/PopupNotifications.jsm
--- a/browser/base/content/test/popupNotifications/browser_popupNotification_5.js
+++ b/browser/base/content/test/popupNotifications/browser_popupNotification_5.js
@@ -190,16 +190,17 @@ var tests = [
       this.notification = showNotification(notifyObj);
       yield shown;
 
       ok(notifyObj.shownCallbackTriggered, "Should have triggered the shown event");
       ok(notifyObj.showingCallbackTriggered, "Should have triggered the showing event");
       // Reset to false so that we can ensure these are not fired a second time.
       notifyObj.shownCallbackTriggered = false;
       notifyObj.showingCallbackTriggered = false;
+      let timeShown = this.notification.timeShown;
 
       let promiseWin = BrowserTestUtils.waitForNewWindow();
       gBrowser.replaceTabWithWindow(firstTab);
       let win = yield promiseWin;
 
       let anchor = win.document.getElementById("default-notification-icon");
       win.PopupNotifications._reshowNotifications(anchor);
       ok(win.PopupNotifications.panel.childNodes.length == 0,
@@ -213,16 +214,18 @@ var tests = [
       ok(PopupNotifications.isPanelOpen,
          "Should have kept the popup on the first window");
       ok(!notifyObj.dismissalCallbackTriggered,
          "Should not have triggered a dismissed event");
       ok(!notifyObj.shownCallbackTriggered,
          "Should not have triggered a second shown event");
       ok(!notifyObj.showingCallbackTriggered,
          "Should not have triggered a second showing event");
+      ok(this.notification.timeShown > timeShown,
+         "should have updated timeShown to restart the security delay");
 
       this.notification.remove();
       gBrowser.removeTab(gBrowser.selectedTab);
       gBrowser.selectedTab = this.oldSelectedTab;
 
       goNext();
     }
   },
--- a/toolkit/modules/PopupNotifications.jsm
+++ b/toolkit/modules/PopupNotifications.jsm
@@ -582,18 +582,22 @@ PopupNotifications.prototype = {
   },
 
   handleEvent(aEvent) {
     switch (aEvent.type) {
       case "popuphidden":
         this._onPopupHidden(aEvent);
         break;
       case "activate":
-        if (this.isPanelOpen)
+        if (this.isPanelOpen) {
+          for (let elt of this.panel.children)
+            elt.notification.timeShown = this.window.performance.now();
           break;
+        }
+
       case "TabSelect":
         let self = this;
         // This is where we could detect if the panel is dismissed if the page
         // was switched. Unfortunately, the user usually has clicked elsewhere
         // at this point so this value only gets recorded for programmatic
         // reasons, like the "Learn More" link being clicked and resulting in a
         // tab switch.
         this.nextDismissReason = TELEMETRY_STAT_DISMISSAL_LEAVE_PAGE;