Bug 592410 - WebConsole: Reloading page while requests are not done causes exception r=sdwilsh a=gavin.sharp
authorPatrick Walton <pcwalton@mozilla.com>
Thu, 02 Sep 2010 14:30:48 -0700
changeset 51929 520233ed37c19cae6d5799c76058350bade5aea8
parent 51928 6160fe29dd370a5b13f339c8679504fdada84c86
child 51930 af19a8b6501ae9879de7d4856bb47a1c51589f08
push idunknown
push userunknown
push dateunknown
reviewerssdwilsh, gavin.sharp
bugs592410
milestone2.0b6pre
Bug 592410 - WebConsole: Reloading page while requests are not done causes exception r=sdwilsh a=gavin.sharp
toolkit/components/console/hudservice/HUDService.jsm
--- a/toolkit/components/console/hudservice/HUDService.jsm
+++ b/toolkit/components/console/hudservice/HUDService.jsm
@@ -160,24 +160,33 @@ ResponseListener.prototype =
    *
    * @param nsIRequest aRequest
    */
   setResponseHeader: function RL_setResponseHeader(aRequest)
   {
     let httpActivity = this.httpActivity;
     // Check if the header isn't set yet.
     if (!httpActivity.response.header) {
+      if (aRequest instanceof Ci.nsIHttpChannel) {
       httpActivity.response.header = {};
-      if (aRequest instanceof Ci.nsIHttpChannel) {
+        try {
         aRequest.visitResponseHeaders({
           visitHeader: function(aName, aValue) {
             httpActivity.response.header[aName] = aValue;
           }
         });
       }
+        // Accessing the response header can throw an NS_ERROR_NOT_AVAILABLE
+        // exception. Catch it and stop it to make it not show up in the.
+        // This can happen if the response is not finished yet and the user
+        // reloades the page.
+        catch (ex) {
+          delete httpActivity.response.header;
+        }
+      }
     }
   },
 
   /**
    * See documention at
    * https://developer.mozilla.org/en/XPCOM_Interface_Reference/nsIStreamListener
    *
    * Grabs a copy of the original data and passes it on to the original listener.