diff --git a/dom/base/test/chrome/test_bug884693.xul b/dom/base/test/chrome/test_bug884693.xul index 6a2be9d733b9..6400cc681745 100644 --- a/dom/base/test/chrome/test_bug884693.xul +++ b/dom/base/test/chrome/test_bug884693.xul @@ -55,8 +55,14 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=884693 } SimpleTest.waitForExplicitFinish(); - runTest(204, "No content", "", "", []). - then(() => { return runTest(204, "No content", INVALID_XML, "", []); }). + runTest(201, "Created", "", "", []). + then(() => { return runTest(201, "Created", INVALID_XML, INVALID_XML, []); }). + then(() => { return runTest(202, "Accepted", "", "", []); }). + then(() => { return runTest(202, "Accepted", INVALID_XML, INVALID_XML, []); }). + then(() => { return runTest(204, "No Content", "", "", []); }). + then(() => { return runTest(204, "No Content", INVALID_XML, "", []); }). + then(() => { return runTest(205, "Reset Content", "", "", []); }). + then(() => { return runTest(205, "Reset Content", INVALID_XML, "", []); }). then(() => { return runTest(304, "Not modified", "", "", []); }). then(() => { return runTest(304, "Not modified", INVALID_XML, "", []); }). then(() => { return runTest(200, "OK", "", "", ["no root element found"]); }). diff --git a/dom/xhr/XMLHttpRequestMainThread.cpp b/dom/xhr/XMLHttpRequestMainThread.cpp index 77610a307663..2aaaea61a892 100644 --- a/dom/xhr/XMLHttpRequestMainThread.cpp +++ b/dom/xhr/XMLHttpRequestMainThread.cpp @@ -2012,6 +2012,16 @@ XMLHttpRequestMainThread::OnStartRequest(nsIRequest *request, nsISupports *ctxt) mResponseXML->SetChromeXHRDocURI(chromeXHRDocURI); mResponseXML->SetChromeXHRDocBaseURI(chromeXHRDocBaseURI); + // suppress parsing failure messages to console for statuses which + // can have empty bodies (see bug 884693). + uint32_t responseStatus; + if (NS_SUCCEEDED(GetStatus(&responseStatus)) && + (responseStatus == 201 || responseStatus == 202 || + responseStatus == 204 || responseStatus == 205 || + responseStatus == 304)) { + mResponseXML->SetSuppressParserErrorConsoleMessages(true); + } + if (nsContentUtils::IsSystemPrincipal(mPrincipal)) { mResponseXML->ForceEnableXULXBL(); } @@ -2077,15 +2087,6 @@ XMLHttpRequestMainThread::OnStopRequest(nsIRequest *request, nsISupports *ctxt, mRequestObserver->OnStopRequest(request, ctxt, status); } - // suppress parsing failure messages to console for status 204/304 (see bug 884693). - if (mResponseXML) { - uint32_t responseStatus; - if (NS_SUCCEEDED(GetStatus(&responseStatus)) && - (responseStatus == 204 || responseStatus == 304)) { - mResponseXML->SetSuppressParserErrorConsoleMessages(true); - } - } - // make sure to notify the listener if we were aborted // XXX in fact, why don't we do the cleanup below in this case?? // State::unsent is for abort calls. See OnStartRequest above.