mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:18:48 +00:00
Suppress spurious console errors for XHR response codes 201, 202, 204, 205 and 304.
Parse errors for XML data are already handled in 4d8f9a9add1805a5cb3b7fd1cc1ff8dd4b020fe4 -- this is a follow-up to suppress unnecessary console errors.
This commit is contained in:
@@ -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).
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user