Backout e9237d1ae5ff (bug 790201), 0ecee5121681 (bug 766616), d8ec55d3b98e (bug 796218), c4bb09009a54 (bug 798437), 6a8bb5834090 (bug 766616) for bustage
authorPhil Ringnalda <philringnalda@gmail.com>
Fri, 05 Oct 2012 20:11:45 -0700
changeset 109480 9b9678df767268bee3aceef3c09a422909be458d
parent 109479 9e582b26b6b1a4a94d139e0607d479c8eca94702
child 109481 abf6515b8c85b76b7d2975739a027e9422aaf7b4
push id16049
push userphilringnalda@gmail.com
push dateSat, 06 Oct 2012 03:23:55 +0000
treeherdermozilla-inbound@9b9678df7672 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs790201, 766616, 796218, 798437
milestone18.0a1
backs oute9237d1ae5ff3642cd6a52a045671b0e3d7f843b
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
Backout e9237d1ae5ff (bug 790201), 0ecee5121681 (bug 766616), d8ec55d3b98e (bug 796218), c4bb09009a54 (bug 798437), 6a8bb5834090 (bug 766616) for bustage on a CLOSED TREE
browser/base/content/aboutSocialError.xhtml
browser/base/content/browser-social.js
toolkit/components/social/FrameWorker.jsm
toolkit/components/social/MozSocialAPI.jsm
--- a/browser/base/content/aboutSocialError.xhtml
+++ b/browser/base/content/aboutSocialError.xhtml
@@ -22,52 +22,40 @@
 
   <body>
     <div id="error-box">
       <p id="main-error-msg"></p>
       <p id="helper-error-msg"></p>
     </div>
     <div id="button-box">
       <button id="btnTryAgain" onclick="tryAgainButton()"/>
-      <button id="btnCloseSidebar" onclick="closeSidebarButton()"/>
+      <button id="btnCloseSidebar" onclick="closeSidebar()"/>
     </div>
   </body>
 
   <script type="text/javascript;version=1.8"><![CDATA[
     const Cu = Components.utils;
 
     Cu.import("resource://gre/modules/Services.jsm");
-    Cu.import("resource:///modules/Social.jsm");
+    Cu.import("resource://gre/modules/Social.jsm");
 
     let config = {
       tryAgainCallback: reloadProvider
     }
 
     function parseQueryString() {
       let url = document.documentURI;
       let queryString = url.replace(/^about:socialerror\??/, "");
 
       let modeMatch = queryString.match(/mode=([^&]+)/);
       let mode = modeMatch && modeMatch[1] ? modeMatch[1] : "";
 
       switch (mode) {
-        case "compactInfo":
-          document.getElementById("btnTryAgain").style.display = 'none';
-          document.getElementById("btnCloseSidebar").style.display = 'none';
-          break;
-        case "tryAgainOnly":
-          document.getElementById("btnCloseSidebar").style.display = 'none';
-          //intentional fall-through
-        case "tryAgain":
-          let urlMatch = queryString.match(/url=([^&]+)/);
-          let encodedURL = urlMatch && urlMatch[1] ? urlMatch[1] : "";
-          let url = decodeURIComponent(encodedURL);
-
-          config.tryAgainCallback = loadQueryURL;
-          config.queryURL = url;
+        case "onlyRefreshSidebar":
+          config.tryAgainCallback = refreshSidebar;
           break;
         default:
           break;
       }
     }
 
     function setUpStrings() {
       let brandBundle = Services.strings.createBundle("chrome://branding/locale/brand.properties");
@@ -85,28 +73,28 @@
       btnTryAgain.textContent = browserBundle.GetStringFromName("social.error.tryAgain.label");
       btnTryAgain.accessKey = browserBundle.GetStringFromName("social.error.tryAgain.accesskey");
 
       let btnCloseSidebar = document.getElementById("btnCloseSidebar");
       btnCloseSidebar.textContent = browserBundle.GetStringFromName("social.error.closeSidebar.label");
       btnCloseSidebar.accessKey = browserBundle.GetStringFromName("social.error.closeSidebar.accesskey");
     }
 
-    function closeSidebarButton() {
+    function closeSidebar() {
       Social.toggleSidebar();
     }
 
+    function refreshSidebar() {
+      window.location.href = Social.provider.sidebarURL;
+    }
+
+    function reloadProvider() {
+      Social.provider.reload();
+    }
+
     function tryAgainButton() {
       config.tryAgainCallback();
     }
 
-    function loadQueryURL() {
-      window.location.href = config.queryURL;
-    }
-
-    function reloadProvider() {
-      Social.provider.reload();
-    }
-
     parseQueryString();
     setUpStrings();
   ]]></script>
 </html>
--- a/browser/base/content/browser-social.js
+++ b/browser/base/content/browser-social.js
@@ -271,40 +271,16 @@ let SocialFlyout = {
     let iframe = document.createElement("iframe");
     iframe.setAttribute("type", "content");
     iframe.setAttribute("class", "social-panel-frame");
     iframe.setAttribute("flex", "1");
     iframe.setAttribute("origin", Social.provider.origin);
     panel.appendChild(iframe);
   },
 
-  setUpProgressListener: function SF_setUpProgressListener() {
-    if (!this._progressListenerSet) {
-      this._progressListenerSet = true;
-      // Force a layout flush by calling .clientTop so
-      // that the docShell of this frame is created
-      this.panel.firstChild.clientTop;
-      this.panel.firstChild.docShell.QueryInterface(Ci.nsIInterfaceRequestor)
-                                    .getInterface(Ci.nsIWebProgress)
-                                    .addProgressListener(new SocialErrorListener("flyout"),
-                                                         Ci.nsIWebProgress.NOTIFY_STATE_REQUEST |
-                                                         Ci.nsIWebProgress.NOTIFY_LOCATION);
-    }
-  },
-
-  setFlyoutErrorMessage: function SF_setFlyoutErrorMessage() {
-    let iframe = this.panel.firstChild;
-    if (!iframe)
-      return;
-
-    iframe.removeAttribute("src");
-    iframe.webNavigation.loadURI("about:socialerror?mode=compactInfo", null, null, null, null);
-    sizeSocialPanelToContent(iframe);
-  },
-
   unload: function() {
     let panel = this.panel;
     panel.hidePopup();
     if (!panel.firstChild)
       return
     panel.removeChild(panel.firstChild);
   },
 
@@ -373,17 +349,16 @@ let SocialFlyout = {
       // only "move to new screen pos".  So we remember the last yOffset,
       // calculate the adjustment needed to the new yOffset, then calc the
       // screen Y position.
       let yAdjust = yOffset - this.yOffset;
       let box = panel.boxObject;
       panel.moveTo(box.screenX, box.screenY + yAdjust);
     } else {
       panel.openPopup(anchor, "start_before", 0, yOffset, false, false);
-      this.setUpProgressListener();
     }
     this.yOffset = yOffset;
   }
 }
 
 let SocialShareButton = {
   // promptImages and promptMessages being null means we are yet to get the
   // message back from the provider with the images and icons (or that we got
@@ -627,18 +602,16 @@ var SocialToolbar = {
     let iconNames = Object.keys(provider.ambientNotificationIcons);
     let iconBox = document.getElementById("social-toolbar-item");
     let notifBox = document.getElementById("social-notification-box");
     let panel = document.getElementById("social-notification-panel");
     panel.hidden = false;
     let notificationFrames = document.createDocumentFragment();
     let iconContainers = document.createDocumentFragment();
 
-    let createdFrames = [];
-
     let command = document.getElementById("Social:ToggleNotifications");
     command.setAttribute("checked", Services.prefs.getBoolPref("social.toast-notifications.enabled"));
 
     for each(let name in iconNames) {
       let icon = provider.ambientNotificationIcons[name];
 
       let notificationFrameId = "social-status-" + icon.name;
       let notificationFrame = document.getElementById(notificationFrameId);
@@ -646,18 +619,16 @@ var SocialToolbar = {
         notificationFrame = document.createElement("iframe");
         notificationFrame.setAttribute("type", "content");
         notificationFrame.setAttribute("class", "social-panel-frame");
         notificationFrame.setAttribute("id", notificationFrameId);
         notificationFrame.setAttribute("mozbrowser", "true");
         // work around bug 793057 - by making the panel roughly the final size
         // we are more likely to have the anchor in the correct position.
         notificationFrame.style.width = PANEL_MIN_WIDTH + "px";
-
-        createdFrames.push(notificationFrame);
         notificationFrames.appendChild(notificationFrame);
       }
       notificationFrame.setAttribute("origin", provider.origin);
       if (notificationFrame.getAttribute("src") != icon.contentPanel)
         notificationFrame.setAttribute("src", icon.contentPanel);
 
       let iconId = "social-notification-icon-" + icon.name;
       let imageId = iconId + "-image";
@@ -703,27 +674,16 @@ var SocialToolbar = {
       if (!label.hasAttribute("value") || label.getAttribute("value") != labelValue)
         label.setAttribute("value", labelValue);
 
       if (image.getAttribute("src") != icon.iconURL)
         image.setAttribute("src", icon.iconURL);
     }
     notifBox.appendChild(notificationFrames);
     iconBox.appendChild(iconContainers);
-
-    for (let frame of createdFrames) {
-      if (frame.docShell) {
-        frame.docShell.isActive = false;
-        frame.docShell.QueryInterface(Ci.nsIInterfaceRequestor)
-                      .getInterface(Ci.nsIWebProgress)
-                      .addProgressListener(new SocialErrorListener("notification-panel"),
-                                           Ci.nsIWebProgress.NOTIFY_STATE_REQUEST |
-                                           Ci.nsIWebProgress.NOTIFY_LOCATION);
-      }
-    }
   },
 
   showAmbientPopup: function SocialToolbar_showAmbientPopup(aToolbarButtonBox) {
     let panel = document.getElementById("social-notification-panel");
     let notifBox = document.getElementById("social-notification-box");
     let notificationFrameId = aToolbarButtonBox.getAttribute("notificationFrameId");
     let notificationFrame = document.getElementById(notificationFrameId);
 
@@ -768,39 +728,26 @@ var SocialToolbar = {
           }, 0);
         }, true);
       }
     });
 
     let imageId = aToolbarButtonBox.getAttribute("id") + "-image";
     let toolbarButtonImage = document.getElementById(imageId);
     panel.openPopup(toolbarButtonImage, "bottomcenter topleft", 0, 0, false, false);
-  },
-
-  setPanelErrorMessage: function SocialToolbar_setPanelErrorMessage(aNotificationFrame) {
-    if (!aNotificationFrame)
-      return;
-
-    let src = aNotificationFrame.getAttribute("src");
-    aNotificationFrame.removeAttribute("src");
-    aNotificationFrame.webNavigation.loadURI("about:socialerror?mode=tryAgainOnly&url=" +
-                                             encodeURIComponent(src), null, null, null, null);
-    sizeSocialPanelToContent(aNotificationFrame);
   }
 }
 
 var SocialSidebar = {
   // Called once, after window load, when the Social.provider object is initialized
   init: function SocialSidebar_init() {
     let sbrowser = document.getElementById("social-sidebar-browser");
     // setting isAppTab causes clicks on untargeted links to open new tabs
     sbrowser.docShell.isAppTab = true;
-    sbrowser.webProgress.addProgressListener(new SocialErrorListener("sidebar"),
-                                             Ci.nsIWebProgress.NOTIFY_STATE_REQUEST |
-                                             Ci.nsIWebProgress.NOTIFY_LOCATION);
+  
     this.updateSidebar();
   },
 
   // Whether the sidebar can be shown for this window.
   get canShow() {
     return Social.uiVisible && Social.provider.sidebarURL && !this.chromeless;
   },
 
@@ -856,81 +803,10 @@ var SocialSidebar = {
           setTimeout(function () {
             SocialSidebar.dispatchEvent("socialFrameShow");
           }, 0);
         });
       } else {
         this.dispatchEvent("socialFrameShow");
       }
     }
-  },
-
-  setSidebarErrorMessage: function() {
-    let sbrowser = document.getElementById("social-sidebar-browser");
-    let url = encodeURIComponent(Social.provider.sidebarURL);
-    sbrowser.loadURI("about:socialerror?mode=tryAgain&url=" + url, null, null);
   }
 }
-
-// Error handling class used to listen for network errors in the social frames
-// and replace them with a social-specific error page
-function SocialErrorListener(aType) {
-  this.type = aType;
-}
-
-SocialErrorListener.prototype = {
-  QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebProgressListener,
-                                         Ci.nsISupportsWeakReference,
-                                         Ci.nsISupports]),
-
-  onStateChange: function SPL_onStateChange(aWebProgress, aRequest, aState, aStatus) {
-    let failure = false;
-    if ((aState & Ci.nsIWebProgressListener.STATE_STOP)) {
-      if (aRequest instanceof Ci.nsIHttpChannel) {
-        try {
-          // Change the frame to an error page on 4xx (client errors)
-          // and 5xx (server errors)
-          failure = aRequest.responseStatus >= 400 &&
-                    aRequest.responseStatus < 600;
-        } catch (e) {}
-      }
-    }
-
-    // Calling cancel() will raise some OnStateChange notifications by itself,
-    // so avoid doing that more than once
-    if (failure && aStatus != Components.results.NS_BINDING_ABORTED) {
-      aRequest.cancel(Components.results.NS_BINDING_ABORTED);
-      this.setErrorMessage(aWebProgress);
-    }
-  },
-
-  onLocationChange: function SPL_onLocationChange(aWebProgress, aRequest, aLocation, aFlags) {
-    let failure = aFlags & Ci.nsIWebProgressListener.LOCATION_CHANGE_ERROR_PAGE;
-    if (failure) {
-      aRequest.cancel(Components.results.NS_BINDING_ABORTED);
-      window.setTimeout(function(self) {
-        self.setErrorMessage(aWebProgress);
-      }, 0, this);
-    }
-  },
-
-  onProgressChange: function SPL_onProgressChange() {},
-  onStatusChange: function SPL_onStatusChange() {},
-  onSecurityChange: function SPL_onSecurityChange() {},
-
-  setErrorMessage: function(aWebProgress) {
-    switch (this.type) {
-      case "flyout":
-        SocialFlyout.setFlyoutErrorMessage();
-        break;
-
-      case "sidebar":
-        SocialSidebar.setSidebarErrorMessage();
-        break;
-
-      case "notification-panel":
-        let frame = aWebProgress.QueryInterface(Ci.nsIDocShell)
-                                .chromeEventHandler;
-        SocialToolbar.setPanelErrorMessage(frame);
-        break;
-    }
-  }
-};
--- a/toolkit/components/social/FrameWorker.jsm
+++ b/toolkit/components/social/FrameWorker.jsm
@@ -72,17 +72,17 @@ function FrameWorker(url, name) {
 
   this.frame = makeHiddenFrame();
 
   var self = this;
   Services.obs.addObserver(function injectController(doc, topic, data) {
     if (!doc.defaultView || doc.defaultView != self.frame.contentWindow) {
       return;
     }
-    Services.obs.removeObserver(injectController, "document-element-inserted");
+    Services.obs.removeObserver(injectController, "document-element-inserted", false);
     try {
       self.createSandbox();
     } catch (e) {
       Cu.reportError("FrameWorker: failed to create sandbox for " + url + ". " + e);
     }
   }, "document-element-inserted", false);
 
   this.frame.setAttribute("src", url);
@@ -98,21 +98,18 @@ FrameWorker.prototype = {
     // safe to import this way
     let workerAPI = ['MozWebSocket', 'WebSocket', 'localStorage',
                      'atob', 'btoa', 'clearInterval', 'clearTimeout', 'dump',
                      'setInterval', 'setTimeout', 'XMLHttpRequest',
                      'MozBlobBuilder', 'FileReader', 'Blob',
                      'location'];
     workerAPI.forEach(function(fn) {
       try {
-        sandbox[fn] = workerWindow[fn];
-        // Bug 798660 - XHR has issues in a sandbox and need
-        // to be unwrapped to work
-        if (fn == "XMLHttpRequest")
-          sandbox[fn] = XPCNativeWrapper.unwrap(workerWindow)[fn];
+        // XXX Need to unwrap for this to work - find out why!
+        sandbox[fn] = XPCNativeWrapper.unwrap(workerWindow)[fn];
       }
       catch(e) {
         Cu.reportError("FrameWorker: failed to import API "+fn+"\n"+e+"\n");
       }
     });
     // the "navigator" object in a worker is a subset of the full navigator;
     // specifically, just the interfaces 'NavigatorID' and 'NavigatorOnLine'
     let navigator = {
@@ -151,24 +148,18 @@ FrameWorker.prototype = {
 
     sandbox._postMessage = function fw_postMessage(d, o) {
       workerWindow.postMessage(d, o)
     };
     sandbox._addEventListener = function fw_addEventListener(t, l, c) {
       workerWindow.addEventListener(t, l, c)
     };
 
-    // This is necessary to keep the sandbox alive
     this.sandbox = sandbox;
 
-    Services.obs.addObserver(function cleanupSandbox () {
-      Services.obs.removeObserver(cleanupSandbox, "xpcom-shutdown");
-      Cu.nukeSandbox(sandbox);
-    }, "xpcom-shutdown", false);
-
     let worker = this;
 
     workerWindow.addEventListener("load", function loadListener() {
       workerWindow.removeEventListener("load", loadListener);
       // the iframe has loaded the js file as text - first inject the magic
       // port-handling code into the sandbox.
       try {
         Services.scriptloader.loadSubScript("resource://gre/modules/MessagePortBase.jsm", sandbox);
@@ -230,18 +221,16 @@ FrameWorker.prototype = {
 
     delete workerCache[this.url];
 
     // let pending events get delivered before actually removing the frame
     Services.tm.mainThread.dispatch(function deleteWorkerFrame() {
       // now nuke the iframe itself and forget everything about this worker.
       this.frame.parentNode.removeChild(this.frame);
     }.bind(this), Ci.nsIThread.DISPATCH_NORMAL);
-
-    Cu.nukeSandbox(this.sandbox);
   }
 };
 
 function makeHiddenFrame() {
   let hiddenDoc = Services.appShell.hiddenDOMWindow.document;
   let iframe = hiddenDoc.createElementNS("http://www.w3.org/1999/xhtml", "iframe");
   iframe.setAttribute("mozframetype", "content");
   // allow-same-origin is necessary for localStorage to work in the sandbox.
--- a/toolkit/components/social/MozSocialAPI.jsm
+++ b/toolkit/components/social/MozSocialAPI.jsm
@@ -38,21 +38,16 @@ var MozSocialAPI = {
 // Called on document-element-inserted, checks that the API should be injected,
 // and then calls attachToWindow as appropriate
 function injectController(doc, topic, data) {
   try {
     let window = doc.defaultView;
     if (!window)
       return;
 
-    // Do not attempt to load the API into about: error pages
-    if (doc.documentURIObject.scheme == "about") {
-      return;
-    }
-
     var containingBrowser = window.QueryInterface(Ci.nsIInterfaceRequestor)
                                   .getInterface(Ci.nsIWebNavigation)
                                   .QueryInterface(Ci.nsIDocShell)
                                   .chromeEventHandler;
 
     let origin = containingBrowser.getAttribute("origin");
     if (!origin) {
       return;