Bug 1278130 - Retrieve list of blocked uris from parent browser. r=Ratty a=Ratty
authorFrank-Rainer Grahl <frgrahl@gmx.net>
Mon, 29 Aug 2016 16:21:53 +0200
changeset 27456 30533da241d183964eafae47ed4a39967d5c253e
parent 27455 0451d5cddfa9f01cf18c219f62872574aea482d2
child 27457 7c375071c615c1e757b48a14b31a293ed7d7f40e
push id1850
push userclokep@gmail.com
push dateWed, 08 Mar 2017 19:29:12 +0000
treeherdercomm-esr52@028df196b2d9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersRatty, Ratty
bugs1278130, 1273685
Bug 1278130 - Retrieve list of blocked uris from parent browser. r=Ratty a=Ratty See bug 1273685.
suite/browser/tabbrowser.xml
suite/common/utilityOverlay.js
--- a/suite/browser/tabbrowser.xml
+++ b/suite/browser/tabbrowser.xml
@@ -1104,16 +1104,18 @@
       </method>
 
       <field name="mAeroPeek">false</field>
 
       <method name="updateCurrentBrowser">
         <body>
           <![CDATA[
             var newBrowser = this.mPanelContainer.selectedPanel.firstChild;
+            var oldBrowser = this.mCurrentBrowser;
+
             // Transfer the dropped link handler to the new browser.
             // Note: closing the current tab sets mCurrentBrowser to null
             //       so we use mCurrentTab.linkedBrowser instead.
             newBrowser.droppedLinkHandler = this.mCurrentTab.linkedBrowser.droppedLinkHandler;
             newBrowser.showWindowResizer = this.mCurrentTab.linkedBrowser.showWindowResizer;
             newBrowser.docShellIsActive = this.mCurrentTab.linkedBrowser.docShellIsActive;
             if (this.mCurrentBrowser) {
               this.mCurrentBrowser.droppedLinkHandler = null;
@@ -1125,16 +1127,20 @@
             newBrowser.setAttribute("type", "content-primary");
             this.mCurrentBrowser = newBrowser;
             this.mCurrentTab = this.selectedTab;
             this.mCurrentTab.removeAttribute("unread");
             this.finder.mListeners.forEach(l => this.mCurrentBrowser.finder.addResultListener(l));
 
             var tabListener = this.mTabListeners[this.tabContainer.selectedIndex];
 
+            if (!oldBrowser ||
+                (!oldBrowser.blockedPopups != !newBrowser.blockedPopups))
+              this.mCurrentBrowser.updateBlockedPopups();
+
             // Update the URL bar.
             const nsIWebProgressListener = Components.interfaces.nsIWebProgressListener;
             this.updateUrlBar(newBrowser.webProgress,
                               null,
                               newBrowser.currentURI,
                               0,
                               newBrowser.securityUI,
                               newBrowser,
--- a/suite/common/utilityOverlay.js
+++ b/suite/common/utilityOverlay.js
@@ -1255,39 +1255,42 @@ function RemovePopupsItems(parent)
     parent.lastChild.remove();
 }
 
 function createShowPopupsMenu(parent, browser)
 {
   if (!browser)
     return false;
 
-  var popups = browser.blockedPopups;
-
-  if (!popups)
+  if (!browser.blockedPopups ||
+      browser.blockedPopups.count == 0)
     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;
+  browser.retrieveListOfBlockedPopups().then(blockedPopups => {
+
+    for (var i = 0; i < blockedPopups.length; i++) {
+
+      let blockedPopup = blockedPopups[i];
+      // popupWindowURI will be null if the file picker popup is blocked.
+      if (!blockedPopup.popupWindowURIspec)
+            continue;
 
-    var str = gUtilityBundle.getFormattedString("popupMenuShow", [URI.spec]);
-    // 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);
+      let str = gUtilityBundle.getFormattedString("popupMenuShow", [blockedPopup.popupWindowURIspec]);
+      // Check for duplicates in the blockedPopups list and reuse the old menuitem.
+      let menuitem = parent.getElementsByAttribute("label", str).item(0);
+      if (!menuitem) {
+        menuitem = document.createElement("menuitem");
+        menuitem.setAttribute("label", str);
+      }
+      menuitem.setAttribute("popupReportIndex", i);
+      parent.appendChild(menuitem);
     }
-    menuitem.setAttribute("popupReportIndex", i);
-    parent.appendChild(menuitem);
-  }
+  }, null);
 
   return parent.getElementsByAttribute("popupReportIndex", "*").item(0) != null;
 }
 
 function popupBlockerMenuCommand(target)
 {
   if (target.hasAttribute("popupReportIndex"))
     target.parentNode.browser.unblockPopup(target.getAttribute("popupReportIndex"));