diff --git a/content/base/src/nsXMLHttpRequest.cpp b/content/base/src/nsXMLHttpRequest.cpp index 658efa0b1e7..24bedc2f953 100644 --- a/content/base/src/nsXMLHttpRequest.cpp +++ b/content/base/src/nsXMLHttpRequest.cpp @@ -1169,7 +1169,17 @@ nsXMLHttpRequest::GetStatusText(nsCString& aStatusText) 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); + } + }