Bug 1011748 - Added logic to GetStatusText to ensure the statusText is available after all redirects (if any) have been followed. r=bz
☠☠ backed out by 253101741ccc ☠ ☠
authorMichael A. Milazzo <michael.a.milazzo@gmail.com>
Mon, 09 Jun 2014 23:14:53 -0700
changeset 210790 8fc4cf38057edd256192b626cc1556eb6545712e
parent 210789 6b7c8900242a76bb444e121b9b2b99779a6560c9
child 210791 fc765663d8f81bc01644cdd977ec44bd8804466a
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1011748
milestone33.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 1011748 - Added logic to GetStatusText to ensure the statusText is available after all redirects (if any) have been followed. r=bz
content/base/src/nsXMLHttpRequest.cpp
--- a/content/base/src/nsXMLHttpRequest.cpp
+++ b/content/base/src/nsXMLHttpRequest.cpp
@@ -1164,17 +1164,27 @@ nsXMLHttpRequest::GetStatusText(nsCStrin
   }
 
   // Make sure we don't leak status information from denied cross-site
   // requests.
   if (IsDeniedCrossSiteRequest()) {
     return;
   }
 
-  httpChannel->GetResponseStatusText(aStatusText);
+
+  // Check the current XHR state to see if it is valid to obtain the statusText
+  // value.  This check is to prevent the status text for redirects from being
+  // available before all the redirects have been followed and HTTP headers have
+  // been received.
+  uint16_t readyState;
+  GetReadyState(&readyState);
+  if (readyState != OPENED && readyState != UNSENT) {
+    httpChannel->GetResponseStatusText(aStatusText);
+  }
+
 
 }
 
 void
 nsXMLHttpRequest::CloseRequestWithError(const nsAString& aType,
                                         const uint32_t aFlag)
 {
   if (mChannel) {