Bug 1335985 - reset timeShown on window activation so that persistent notifications get the security delay again, r=past.
authorFlorian Quèze <florian@queze.net>
Mon, 20 Feb 2017 23:29:36 +0100
changeset 372950 a62ce221207c4db6f542426a68cfa0dbb91d118c
parent 372949 cc5a5a7e5331255b5dda147e09ea4d85a9bd8d56
child 372951 d84beb192e57e26846c82d3df3599381f4663792
child 372970 2afcab6fc172a8f7121abd24205f3ab354d54733
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspast
bugs1335985
milestone54.0a1
Bug 1335985 - reset timeShown on window activation so that persistent notifications get the security delay again, r=past.
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;