Bug 1273685. Further reduce the message size by limiting the size of the URI to be sent. r=Gijs
authorFelipe Gomes <felipc@gmail.com>
Mon, 30 May 2016 19:03:16 -0300
changeset 340536 3a87296fe4145138c2ce15512bb31f76fe869cb4
parent 340535 6421e7c224d73b7e9b1106df6d63323bb414517f
child 340537 62ce2708b5beb734fc235e31498deb92f0e5fb2e
push id1183
push userraliiev@mozilla.com
push dateMon, 05 Sep 2016 20:01:49 +0000
treeherdermozilla-release@3148731bed45 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1273685
milestone49.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 1273685. Further reduce the message size by limiting the size of the URI to be sent. r=Gijs MozReview-Commit-ID: EMXYaUwnGR2
browser/base/content/browser.js
mobile/android/chrome/content/browser.js
toolkit/content/browser-content.js
toolkit/content/widgets/browser.xml
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -592,27 +592,28 @@ var gPopupBlockerObserver = {
     gBrowser.selectedBrowser.retrieveListOfBlockedPopups().then(blockedPopups => {
       let foundUsablePopupURI = false;
       if (blockedPopups) {
         for (let i = 0; i < blockedPopups.length; i++) {
           let blockedPopup = blockedPopups[i];
 
           // popupWindowURI will be null if the file picker popup is blocked.
           // xxxdz this should make the option say "Show file picker" and do it (Bug 590306)
-          if (!blockedPopup.popupWindowURI)
+          if (!blockedPopup.popupWindowURIspec)
             continue;
 
-          var popupURIspec = blockedPopup.popupWindowURI.spec;
+          var popupURIspec = blockedPopup.popupWindowURIspec;
 
           // Sometimes the popup URI that we get back from the blockedPopup
           // isn't useful (for instance, netscape.com's popup URI ends up
           // being "http://www.netscape.com", which isn't really the URI of
           // the popup they're trying to show).  This isn't going to be
           // useful to the user, so we won't create a menu item for it.
           if (popupURIspec == "" || popupURIspec == "about:blank" ||
+              popupURIspec == "<self>" ||
               popupURIspec == uri.spec)
             continue;
 
           // Because of the short-circuit above, we may end up in a situation
           // in which we don't have any usable popup addresses to show in
           // the menu, and therefore we shouldn't show the separator.  However,
           // since we got past the short-circuit, we must've found at least
           // one usable popup URI and thus we'll turn on the separator later.
@@ -655,17 +656,17 @@ var gPopupBlockerObserver = {
     let browser = target.popupReportBrowser;
     browser.unblockPopup(popupReportIndex);
   },
 
   showAllBlockedPopups: function (aBrowser)
   {
     let popups = aBrowser.retrieveListOfBlockedPopups().then(popups => {
       for (let i = 0; i < popups.length; i++) {
-        if (popups[i].popupWindowURI)
+        if (popups[i].popupWindowURIspec)
           aBrowser.unblockPopup(i);
       }
     }, null);
   },
 
   editPopupSettings: function ()
   {
     var host = "";
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -6030,17 +6030,17 @@ var PopupBlockerObserver = {
     dump("Allowing popups for: " + currentURI);
   },
 
   showPopupsForSite: function showPopupsForSite() {
     let uri = BrowserApp.selectedBrowser.currentURI;
     let pageReport = BrowserApp.selectedBrowser.pageReport;
     if (pageReport) {
       for (let i = 0; i < pageReport.length; ++i) {
-        let popupURIspec = pageReport[i].popupWindowURI.spec;
+        let popupURIspec = pageReport[i].popupWindowURIspec;
 
         // Sometimes the popup URI that we get back from the pageReport
         // isn't useful (for instance, netscape.com's popup URI ends up
         // being "http://www.netscape.com", which isn't really the URI of
         // the popup they're trying to show).  This isn't going to be
         // useful to the user, so we won't create a menu item for it.
         if (popupURIspec == "" || popupURIspec == "about:blank" || popupURIspec == uri.spec)
           continue;
--- a/toolkit/content/browser-content.js
+++ b/toolkit/content/browser-content.js
@@ -273,28 +273,44 @@ var PopupBlocking = {
         if (this.popupData && this.popupData[i]) {
           let data = this.popupData[i];
           let internals = this.popupDataInternal[i];
           let dwi = internals.requestingWindow;
 
           // If we have a requesting window and the requesting document is
           // still the current document, open the popup.
           if (dwi && dwi.document == internals.requestingDocument) {
-            dwi.open(data.popupWindowURI, data.popupWindowName, data.popupWindowFeatures);
+            dwi.open(data.popupWindowURIspec, data.popupWindowName, data.popupWindowFeatures);
           }
         }
         break;
       }
 
       case "PopupBlocking:GetBlockedPopupList": {
-        sendAsyncMessage("PopupBlocking:ReplyGetBlockedPopupList",
-                          // Limit 15 popup URLs to be reopened
-                         { popupData: this.popupData ?
-                                      this.popupData.slice(0, 15) :
-                                      [] });
+        let popupData = [];
+        let length = this.popupData ? this.popupData.length : 0;
+
+        // Limit 15 popup URLs to be reported through the UI
+        length = Math.min(length, 15);
+
+        for (let i = 0; i < length; i++) {
+          let popupWindowURIspec = this.popupData[i].popupWindowURIspec;
+
+          if (popupWindowURIspec == global.content.location.href) {
+            popupWindowURIspec = "<self>";
+          } else {
+            // Limit 500 chars to be sent because the URI will be cropped
+            // by the UI anyway, and data: URIs can be significantly larger.
+            popupWindowURIspec = popupWindowURIspec.substring(0, 500)
+          }
+
+          popupData.push({popupWindowURIspec});
+        }
+
+        sendAsyncMessage("PopupBlocking:ReplyGetBlockedPopupList", {popupData});
         break;
       }
     }
   },
 
   handleEvent: function(ev) {
     switch (ev.type) {
       case "DOMPopupBlocked":
@@ -309,17 +325,17 @@ var PopupBlocking = {
 
   onPopupBlocked: function(ev) {
     if (!this.popupData) {
       this.popupData = new Array();
       this.popupDataInternal = new Array();
     }
 
     let obj = {
-      popupWindowURI: ev.popupWindowURI ? ev.popupWindowURI.spec : "about:blank",
+      popupWindowURIspec: ev.popupWindowURI ? ev.popupWindowURI.spec : "about:blank",
       popupWindowFeatures: ev.popupWindowFeatures,
       popupWindowName: ev.popupWindowName
     };
 
     let internals = {
       requestingWindow: ev.requestingWindow,
       requestingDocument: ev.requestingWindow.document,
     };
--- a/toolkit/content/widgets/browser.xml
+++ b/toolkit/content/widgets/browser.xml
@@ -679,25 +679,17 @@
           <![CDATA[
           this.messageManager.sendAsyncMessage("PopupBlocking:GetBlockedPopupList", null);
           return new Promise(resolve => {
             let self = this;
             this.messageManager.addMessageListener("PopupBlocking:ReplyGetBlockedPopupList",
               function replyReceived(msg) {
                 self.messageManager.removeMessageListener("PopupBlocking:ReplyGetBlockedPopupList",
                                                           replyReceived);
-                let list = msg.data.popupData;
-                if (list.length) {
-                  for (let i = 0; i < list.length; i++) {
-                    let scope = Components.utils.import("resource://gre/modules/BrowserUtils.jsm", {});
-                    let uri = scope.BrowserUtils.makeURI(list[i].popupWindowURI);
-                    list[i].popupWindowURI = uri;
-                  }
-                }
-                resolve(list);
+                resolve(msg.data.popupData);
               }
             );
           });
           ]]>
         </body>
       </method>
 
       <method name="unblockPopup">