diff options
-rw-r--r-- | dom/base/nsIDocument.h | 3 | ||||
-rw-r--r-- | dom/base/nsXMLHttpRequest.cpp | 10 | ||||
-rw-r--r-- | dom/xml/XMLDocument.cpp | 12 | ||||
-rw-r--r-- | dom/xml/XMLDocument.h | 6 | ||||
-rw-r--r-- | parser/htmlparser/nsExpatDriver.cpp | 5 |
5 files changed, 36 insertions, 0 deletions
diff --git a/dom/base/nsIDocument.h b/dom/base/nsIDocument.h index a8b8c405c..0f3877939 100644 --- a/dom/base/nsIDocument.h +++ b/dom/base/nsIDocument.h @@ -237,6 +237,9 @@ public: virtual void SetSuppressParserErrorElement(bool aSuppress) {} virtual bool SuppressParserErrorElement() { return false; } + virtual void SetSuppressParserErrorConsoleMessages(bool aSuppress) {} + virtual bool SuppressParserErrorConsoleMessages() { return false; } + /** * Signal that the document title may have changed * (see nsDocument::GetTitle). diff --git a/dom/base/nsXMLHttpRequest.cpp b/dom/base/nsXMLHttpRequest.cpp index f13564db3..f0bedfe70 100644 --- a/dom/base/nsXMLHttpRequest.cpp +++ b/dom/base/nsXMLHttpRequest.cpp @@ -2158,6 +2158,16 @@ nsXMLHttpRequest::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 bugs 884693 + 1329365). + 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(); } diff --git a/dom/xml/XMLDocument.cpp b/dom/xml/XMLDocument.cpp index 56bf2e019..3f85d3964 100644 --- a/dom/xml/XMLDocument.cpp +++ b/dom/xml/XMLDocument.cpp @@ -524,6 +524,18 @@ XMLDocument::SuppressParserErrorElement() return mSuppressParserErrorElement; } +void +XMLDocument::SetSuppressParserErrorConsoleMessages(bool aSuppress) +{ + mSuppressParserErrorConsoleMessages = aSuppress; +} + +bool +XMLDocument::SuppressParserErrorConsoleMessages() +{ + return mSuppressParserErrorConsoleMessages; +} + nsresult XMLDocument::StartDocumentLoad(const char* aCommand, nsIChannel* aChannel, diff --git a/dom/xml/XMLDocument.h b/dom/xml/XMLDocument.h index 6eaa32a4b..560aad1f6 100644 --- a/dom/xml/XMLDocument.h +++ b/dom/xml/XMLDocument.h @@ -33,6 +33,9 @@ public: virtual void SetSuppressParserErrorElement(bool aSuppress) override; virtual bool SuppressParserErrorElement() override; + virtual void SetSuppressParserErrorConsoleMessages(bool aSuppress) override; + virtual bool SuppressParserErrorConsoleMessages() override; + virtual nsresult StartDocumentLoad(const char* aCommand, nsIChannel* channel, nsILoadGroup* aLoadGroup, nsISupports* aContainer, @@ -93,6 +96,9 @@ protected: // If true, do not output <parsererror> elements. Per spec, XMLHttpRequest // shouldn't output them, whereas DOMParser/others should (see bug 918703). bool mSuppressParserErrorElement; + + // If true, do not log parsing errors to the web console (see bug 884693). + bool mSuppressParserErrorConsoleMessages; }; } // namespace dom diff --git a/parser/htmlparser/nsExpatDriver.cpp b/parser/htmlparser/nsExpatDriver.cpp index 039dc201c..c144a2100 100644 --- a/parser/htmlparser/nsExpatDriver.cpp +++ b/parser/htmlparser/nsExpatDriver.cpp @@ -988,6 +988,11 @@ nsExpatDriver::HandleError() } } + nsCOMPtr<nsIDocument> doc = do_QueryInterface(mOriginalSink->GetTarget()); + if (doc && doc->SuppressParserErrorConsoleMessages()) { + shouldReportError = false; + } + if (shouldReportError) { nsCOMPtr<nsIConsoleService> cs (do_GetService(NS_CONSOLESERVICE_CONTRACTID)); |