Backout bug 1008585 because bug 933462 was backed out a=IanN
authorNeil Rashbrook <neil@parkwaycc.co.uk>
Wed, 20 Aug 2014 00:07:35 +0100
changeset 20291 3327fcf349aa6762f7ac93ac814be9a714bbdff7
parent 20288 98d5981276990d9874cbb14dd968bec7100f0753
child 20292 ca5ec1a2966ff4a5b06007a6142626012fc76674
push id1199
push userneil@parkwaycc.co.uk
push dateTue, 19 Aug 2014 23:29:02 +0000
treeherdercomm-beta@ca5ec1a2966f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersIanN
bugs1008585, 933462
Backout bug 1008585 because bug 933462 was backed out a=IanN
suite/common/bindings/notification.xml
suite/common/utilityOverlay.js
--- a/suite/common/bindings/notification.xml
+++ b/suite/common/bindings/notification.xml
@@ -2091,28 +2091,44 @@
                           .offline = false;
             }, true);
         ]]>
       </handler>
 
       <handler event="DOMUpdatePageReport" phase="capturing">
         <![CDATA[
           var browser = this.activeBrowser;
-          if (!browser.blockedPopups)
+          if (!browser.pageReport)
             return;
 
-          // this.popupCount can be 0, while browser.blockedPopups has not been cleared.
-          if (!this.popupCount && browser.blockedPopups.length > 1) {
-            this.popupCount = browser.blockedPopups.length;
+          // this.popupCount can be 0, while browser.pageReport has not been cleared.
+          if (!this.popupCount && browser.pageReport.length > 1) {
+            this.popupCount = browser.pageReport.length;
           } else {
             this.popupCount++;
           }
           this.playSoundForBlockedPopup();
           this.notifyPopupCountChanged();
 
+          // Check for duplicates and remove the old occurence of this url,
+          // to update the features.
+          var lastItemPlace = browser.pageReport.length - 1;
+          var lastItem = browser.pageReport[lastItemPlace];
+          for (var i = 0; i < lastItemPlace; i++) {
+            if (browser.pageReport[i].popupWindowURI.equals(lastItem.popupWindowURI)) {
+              browser.pageReport.splice(i, 1);
+              break;
+            }
+          }
+
+          // Limit the length of the menu to some reasonable size.
+          // We only add one item every time in browser.xml, so no need for more complex stuff.
+          if (browser.pageReport.length > 100)
+            browser.pageReport.shift();
+
           var tmp = {};
           Components.utils.import("resource://gre/modules/PluralForm.jsm", tmp);
           if (this._prefs.getBoolPref("privacy.popups.showBrowserMessage"))
           {
             var brandShortName = this._brandStringBundle.GetStringFromName("brandShortName");
             var message = this._stringBundle.GetStringFromName("popupWarning.message");
             message = tmp.PluralForm.get(this.popupCount, message)
                                     .replace("#1", brandShortName)
--- a/suite/common/utilityOverlay.js
+++ b/suite/common/utilityOverlay.js
@@ -1224,56 +1224,51 @@ function popupNotificationMenuShowing(ev
   }
 
   var separator = document.getElementById("popupNotificationMenuSeparator");
   separator.hidden = !createShowPopupsMenu(event.target, notificationbox.activeBrowser);
 }
 
 function RemovePopupsItems(parent)
 {
-  while (parent.lastChild && parent.lastChild.hasAttribute("popupReportIndex"))
+  while (parent.lastChild && ("popup" in parent.lastChild))
     parent.lastChild.remove();
 }
 
 function createShowPopupsMenu(parent, browser)
 {
   if (!browser)
     return false;
 
-  var popups = browser.blockedPopups;
+  var popups = browser.pageReport;
 
   if (!popups)
     return false;
 
-  parent.browser = browser;
-
   for (var i = 0; i < popups.length; i++) {
-    // popupWindowURI will be null if a file input was blocked.
-    var URI = popups[i].popupWindowURI;
-    if (!URI)
-      continue;
-
-    var str = gUtilityBundle.getFormattedString("popupMenuShow", [URI]);
-    // Check for duplicates and reuse the old menuitem.
-    var menuitem = parent.getElementsByAttribute("label", str).item(0);
-    if (!menuitem) {
-      menuitem = document.createElement("menuitem");
-      menuitem.setAttribute("label", str);
-    }
-    menuitem.setAttribute("popupReportIndex", i);
+    var popup = popups[i];
+    var menuitem = document.createElement("menuitem");
+    var str = gUtilityBundle.getFormattedString("popupMenuShow",
+                                                [popup.popupWindowURI.spec]);
+    menuitem.setAttribute("label", str);
+    menuitem.popup = popup;
     parent.appendChild(menuitem);
   }
 
-  return parent.getElementsByAttribute("popupReportIndex", "*").item(0) != null;
+  return true;
 }
 
 function popupBlockerMenuCommand(target)
 {
-  if (target.hasAttribute("popupReportIndex"))
-    target.parentNode.browser.unblockPopup(target.getAttribute("popupReportIndex"));
+  if (!("popup" in target))
+    return;
+  var popup = target.popup;
+  var reqWin = popup.requestingWindow;
+  if (reqWin.document == popup.requestingDocument)
+    reqWin.open(popup.popupWindowURI.spec, popup.popupWindowName, popup.popupWindowFeatures);
 }
 
 function disablePopupBlockerNotifications()
 {
   Services.prefs.setBoolPref("privacy.popups.showBrowserMessage", false);
 }
 
 /**