Bug 1376004. P1 - include http response code in the error.message field so the UI has more details to display a proper error message. r=cpearce

MozReview-Commit-ID: CHBXZZxfPc0
This commit is contained in:
JW Wang
2017-07-14 15:17:32 +08:00
parent 0d9b23737b
commit f7b934bab5
2 changed files with 9 additions and 4 deletions

View File

@@ -534,9 +534,13 @@ HTMLMediaElement::MediaLoadListener::OnStartRequest(nsIRequest* aRequest,
nsCOMPtr<nsIHttpChannel> hc = do_QueryInterface(aRequest);
bool succeeded;
if (hc && NS_SUCCEEDED(hc->GetRequestSucceeded(&succeeded)) && !succeeded) {
element->NotifyLoadError();
uint32_t responseStatus = 0;
Unused << hc->GetResponseStatus(&responseStatus);
nsAutoCString statusText;
Unused << hc->GetResponseStatusText(statusText);
element->NotifyLoadError(
nsPrintfCString("%u: %s", responseStatus, statusText.get()));
nsAutoString code;
code.AppendInt(responseStatus);
nsAutoString src;
@@ -2046,11 +2050,12 @@ void HTMLMediaElement::SelectResource()
}
}
void HTMLMediaElement::NotifyLoadError()
void
HTMLMediaElement::NotifyLoadError(const nsACString& aErrorDetails)
{
if (!mIsLoadingFromSourceChildren) {
LOG(LogLevel::Debug, ("NotifyLoadError(), no supported media error"));
NoSupportedMediaSourceError();
NoSupportedMediaSourceError(aErrorDetails);
} else if (mSourceLoadCandidate) {
DispatchAsyncSourceError(mSourceLoadCandidate);
QueueLoadFromSourceTask();