mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-16 22:04:36 +00:00
Back out 75ace50df008 to try to fix failures after last central/inbound merge on a CLOSED TREE
This commit is contained in:
parent
0427306100
commit
e851f37192
@ -1109,7 +1109,7 @@ public:
|
|||||||
* @param aPrincipal Prinicpal of the document. Must not be null.
|
* @param aPrincipal Prinicpal of the document. Must not be null.
|
||||||
* @param aScriptObject The object from which the context for event handling
|
* @param aScriptObject The object from which the context for event handling
|
||||||
* can be got.
|
* can be got.
|
||||||
* @param aFlavor Select the kind of document to create.
|
* @param aSVGDocument Force SVG Document creation.
|
||||||
* @param aResult [out] The document that was created.
|
* @param aResult [out] The document that was created.
|
||||||
*/
|
*/
|
||||||
static nsresult CreateDocument(const nsAString& aNamespaceURI,
|
static nsresult CreateDocument(const nsAString& aNamespaceURI,
|
||||||
@ -1119,7 +1119,7 @@ public:
|
|||||||
nsIURI* aBaseURI,
|
nsIURI* aBaseURI,
|
||||||
nsIPrincipal* aPrincipal,
|
nsIPrincipal* aPrincipal,
|
||||||
nsIScriptGlobalObject* aScriptObject,
|
nsIScriptGlobalObject* aScriptObject,
|
||||||
DocumentFlavor aFlavor,
|
bool aSVGDocument,
|
||||||
nsIDOMDocument** aResult);
|
nsIDOMDocument** aResult);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -130,13 +130,6 @@ class Element;
|
|||||||
// Flag for AddStyleSheet().
|
// Flag for AddStyleSheet().
|
||||||
#define NS_STYLESHEET_FROM_CATALOG (1 << 0)
|
#define NS_STYLESHEET_FROM_CATALOG (1 << 0)
|
||||||
|
|
||||||
// Enum for requesting a particular type of document when creating a doc
|
|
||||||
enum DocumentFlavor {
|
|
||||||
DocumentFlavorLegacyGuess, // compat with old code until made HTML5-compliant
|
|
||||||
DocumentFlavorHTML, // HTMLDocument with HTMLness bit set to true
|
|
||||||
DocumentFlavorSVG // SVGDocument
|
|
||||||
};
|
|
||||||
|
|
||||||
// Document states
|
// Document states
|
||||||
|
|
||||||
// RTL locale: specific to the XUL localedir attribute
|
// RTL locale: specific to the XUL localedir attribute
|
||||||
@ -1898,7 +1891,7 @@ NS_NewDOMDocument(nsIDOMDocument** aInstancePtrResult,
|
|||||||
nsIPrincipal* aPrincipal,
|
nsIPrincipal* aPrincipal,
|
||||||
bool aLoadedAsData,
|
bool aLoadedAsData,
|
||||||
nsIScriptGlobalObject* aEventObject,
|
nsIScriptGlobalObject* aEventObject,
|
||||||
DocumentFlavor aFlavor);
|
bool aSVGDocument);
|
||||||
|
|
||||||
// This is used only for xbl documents created from the startup cache.
|
// This is used only for xbl documents created from the startup cache.
|
||||||
// Non-cached documents are created in the same manner as xml documents.
|
// Non-cached documents are created in the same manner as xml documents.
|
||||||
|
@ -3706,12 +3706,12 @@ nsContentUtils::CreateDocument(const nsAString& aNamespaceURI,
|
|||||||
nsIURI* aDocumentURI, nsIURI* aBaseURI,
|
nsIURI* aDocumentURI, nsIURI* aBaseURI,
|
||||||
nsIPrincipal* aPrincipal,
|
nsIPrincipal* aPrincipal,
|
||||||
nsIScriptGlobalObject* aEventObject,
|
nsIScriptGlobalObject* aEventObject,
|
||||||
DocumentFlavor aFlavor,
|
bool aSVGDocument,
|
||||||
nsIDOMDocument** aResult)
|
nsIDOMDocument** aResult)
|
||||||
{
|
{
|
||||||
nsresult rv = NS_NewDOMDocument(aResult, aNamespaceURI, aQualifiedName,
|
nsresult rv = NS_NewDOMDocument(aResult, aNamespaceURI, aQualifiedName,
|
||||||
aDoctype, aDocumentURI, aBaseURI, aPrincipal,
|
aDoctype, aDocumentURI, aBaseURI, aPrincipal,
|
||||||
true, aEventObject, aFlavor);
|
true, aEventObject, aSVGDocument);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
nsCOMPtr<nsIDocument> document = do_QueryInterface(*aResult);
|
nsCOMPtr<nsIDocument> document = do_QueryInterface(*aResult);
|
||||||
|
@ -188,9 +188,7 @@ nsDOMParser::ParseFromStream(nsIInputStream *stream,
|
|||||||
rv = nsContentUtils::CreateDocument(EmptyString(), EmptyString(), nsnull,
|
rv = nsContentUtils::CreateDocument(EmptyString(), EmptyString(), nsnull,
|
||||||
mDocumentURI, mBaseURI,
|
mDocumentURI, mBaseURI,
|
||||||
mOriginalPrincipal,
|
mOriginalPrincipal,
|
||||||
scriptHandlingObject,
|
scriptHandlingObject, svg,
|
||||||
svg ? DocumentFlavorSVG :
|
|
||||||
DocumentFlavorLegacyGuess,
|
|
||||||
getter_AddRefs(domDocument));
|
getter_AddRefs(domDocument));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
|
@ -1447,9 +1447,7 @@ nsDOMImplementation::CreateDocument(const nsAString& aNamespaceURI,
|
|||||||
return nsContentUtils::CreateDocument(aNamespaceURI, aQualifiedName, aDoctype,
|
return nsContentUtils::CreateDocument(aNamespaceURI, aQualifiedName, aDoctype,
|
||||||
mDocumentURI, mBaseURI,
|
mDocumentURI, mBaseURI,
|
||||||
mOwner->NodePrincipal(),
|
mOwner->NodePrincipal(),
|
||||||
scriptHandlingObject,
|
scriptHandlingObject, false, aReturn);
|
||||||
DocumentFlavorLegacyGuess,
|
|
||||||
aReturn);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
@ -1481,8 +1479,7 @@ nsDOMImplementation::CreateHTMLDocument(const nsAString& aTitle,
|
|||||||
rv = nsContentUtils::CreateDocument(EmptyString(), EmptyString(),
|
rv = nsContentUtils::CreateDocument(EmptyString(), EmptyString(),
|
||||||
doctype, mDocumentURI, mBaseURI,
|
doctype, mDocumentURI, mBaseURI,
|
||||||
mOwner->NodePrincipal(),
|
mOwner->NodePrincipal(),
|
||||||
scriptHandlingObject,
|
scriptHandlingObject, false,
|
||||||
DocumentFlavorLegacyGuess,
|
|
||||||
getter_AddRefs(document));
|
getter_AddRefs(document));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
nsCOMPtr<nsIDocument> doc = do_QueryInterface(document);
|
nsCOMPtr<nsIDocument> doc = do_QueryInterface(document);
|
||||||
|
@ -70,6 +70,7 @@
|
|||||||
#include "nsCExternalHandlerService.h"
|
#include "nsCExternalHandlerService.h"
|
||||||
#include "nsIVariant.h"
|
#include "nsIVariant.h"
|
||||||
#include "xpcprivate.h"
|
#include "xpcprivate.h"
|
||||||
|
#include "nsIParser.h"
|
||||||
#include "XPCQuickStubs.h"
|
#include "XPCQuickStubs.h"
|
||||||
#include "nsStringStream.h"
|
#include "nsStringStream.h"
|
||||||
#include "nsIStreamConverterService.h"
|
#include "nsIStreamConverterService.h"
|
||||||
@ -154,8 +155,6 @@ using namespace mozilla;
|
|||||||
|
|
||||||
#define NS_PROGRESS_EVENT_INTERVAL 50
|
#define NS_PROGRESS_EVENT_INTERVAL 50
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS1(nsXHRParseEndListener, nsIDOMEventListener)
|
|
||||||
|
|
||||||
class nsResumeTimeoutsEvent : public nsRunnable
|
class nsResumeTimeoutsEvent : public nsRunnable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -431,10 +430,7 @@ nsXMLHttpRequest::nsXMLHttpRequest()
|
|||||||
mUploadProgress(0), mUploadProgressMax(0),
|
mUploadProgress(0), mUploadProgressMax(0),
|
||||||
mErrorLoad(false), mTimerIsActive(false),
|
mErrorLoad(false), mTimerIsActive(false),
|
||||||
mProgressEventWasDelayed(false),
|
mProgressEventWasDelayed(false),
|
||||||
mLoadLengthComputable(false),
|
mLoadLengthComputable(false), mLoadTotal(0),
|
||||||
mIsHtml(false),
|
|
||||||
mWarnAboutMultipartHtml(false),
|
|
||||||
mLoadTotal(0),
|
|
||||||
mFirstStartRequestSeen(false),
|
mFirstStartRequestSeen(false),
|
||||||
mInLoadProgressEvent(false),
|
mInLoadProgressEvent(false),
|
||||||
mResultJSON(JSVAL_VOID),
|
mResultJSON(JSVAL_VOID),
|
||||||
@ -724,20 +720,7 @@ nsXMLHttpRequest::GetResponseXML(nsIDOMDocument **aResponseXML)
|
|||||||
*aResponseXML = mResponseXML;
|
*aResponseXML = mResponseXML;
|
||||||
NS_ADDREF(*aResponseXML);
|
NS_ADDREF(*aResponseXML);
|
||||||
}
|
}
|
||||||
if (mWarnAboutMultipartHtml) {
|
|
||||||
mWarnAboutMultipartHtml = false;
|
|
||||||
nsContentUtils::ReportToConsole(nsContentUtils::eDOM_PROPERTIES,
|
|
||||||
"HTMLMultipartXHRWarning",
|
|
||||||
nsnull,
|
|
||||||
0,
|
|
||||||
nsnull, // Response URL not kept around
|
|
||||||
EmptyString(),
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
nsIScriptError::warningFlag,
|
|
||||||
"DOM Events",
|
|
||||||
mOwner->WindowID());
|
|
||||||
}
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -868,7 +851,7 @@ NS_IMETHODIMP nsXMLHttpRequest::GetResponseText(nsAString& aResponseText)
|
|||||||
// We only decode text lazily if we're also parsing to a doc.
|
// We only decode text lazily if we're also parsing to a doc.
|
||||||
// Also, if we've decoded all current data already, then no need to decode
|
// Also, if we've decoded all current data already, then no need to decode
|
||||||
// more.
|
// more.
|
||||||
if (IsWaitingForHTMLCharset() || !mResponseXML ||
|
if (!mResponseXML ||
|
||||||
mResponseBodyDecodedPos == mResponseBody.Length()) {
|
mResponseBodyDecodedPos == mResponseBody.Length()) {
|
||||||
aResponseText = mResponseText;
|
aResponseText = mResponseText;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
@ -1457,16 +1440,6 @@ nsXMLHttpRequest::IsSystemXHR()
|
|||||||
return !!nsContentUtils::IsSystemPrincipal(mPrincipal);
|
return !!nsContentUtils::IsSystemPrincipal(mPrincipal);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
|
||||||
nsXMLHttpRequest::IsWaitingForHTMLCharset()
|
|
||||||
{
|
|
||||||
if (!mIsHtml) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
nsCOMPtr<nsIDocument> doc = do_QueryInterface(mResponseXML);
|
|
||||||
return doc->GetDocumentCharacterSetSource() < kCharsetFromDocTypeDefault;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsXMLHttpRequest::CheckChannelForCrossSiteRequest(nsIChannel* aChannel)
|
nsXMLHttpRequest::CheckChannelForCrossSiteRequest(nsIChannel* aChannel)
|
||||||
{
|
{
|
||||||
@ -1899,8 +1872,6 @@ nsXMLHttpRequest::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
|
|||||||
parseBody = !method.EqualsLiteral("HEAD");
|
parseBody = !method.EqualsLiteral("HEAD");
|
||||||
}
|
}
|
||||||
|
|
||||||
mIsHtml = false;
|
|
||||||
mWarnAboutMultipartHtml = false;
|
|
||||||
if (parseBody && NS_SUCCEEDED(status)) {
|
if (parseBody && NS_SUCCEEDED(status)) {
|
||||||
// We can gain a huge performance win by not even trying to
|
// We can gain a huge performance win by not even trying to
|
||||||
// parse non-XML data. This also protects us from the situation
|
// parse non-XML data. This also protects us from the situation
|
||||||
@ -1909,25 +1880,7 @@ nsXMLHttpRequest::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
|
|||||||
nsCAutoString type;
|
nsCAutoString type;
|
||||||
channel->GetContentType(type);
|
channel->GetContentType(type);
|
||||||
|
|
||||||
if (type.EqualsLiteral("text/html")) {
|
if (type.Find("xml") == kNotFound) {
|
||||||
if (mState & XML_HTTP_REQUEST_MULTIPART) {
|
|
||||||
// HTML parsing is supported only for non-multipart responses. The
|
|
||||||
// multipart implementation assumes that it's OK to start the next part
|
|
||||||
// immediately after the last part. That doesn't work with the HTML
|
|
||||||
// parser, because when OnStopRequest for one part has fired, the
|
|
||||||
// parser thread still hasn't posted back the runnables that make the
|
|
||||||
// parsing appear finished.
|
|
||||||
//
|
|
||||||
// On the other hand, multipart support seems to be a legacy feature,
|
|
||||||
// so it isn't clear that use cases justify adding support for deferring
|
|
||||||
// the multipart stream events between parts to accommodate the
|
|
||||||
// asynchronous nature of the HTML parser.
|
|
||||||
mWarnAboutMultipartHtml = true;
|
|
||||||
mState &= ~XML_HTTP_REQUEST_PARSEBODY;
|
|
||||||
} else {
|
|
||||||
mIsHtml = true;
|
|
||||||
}
|
|
||||||
} else if (type.Find("xml") == kNotFound) {
|
|
||||||
mState &= ~XML_HTTP_REQUEST_PARSEBODY;
|
mState &= ~XML_HTTP_REQUEST_PARSEBODY;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -1952,9 +1905,7 @@ nsXMLHttpRequest::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
|
|||||||
const nsAString& emptyStr = EmptyString();
|
const nsAString& emptyStr = EmptyString();
|
||||||
nsCOMPtr<nsIScriptGlobalObject> global = do_QueryInterface(mOwner);
|
nsCOMPtr<nsIScriptGlobalObject> global = do_QueryInterface(mOwner);
|
||||||
rv = nsContentUtils::CreateDocument(emptyStr, emptyStr, nsnull, docURI,
|
rv = nsContentUtils::CreateDocument(emptyStr, emptyStr, nsnull, docURI,
|
||||||
baseURI, mPrincipal, global,
|
baseURI, mPrincipal, global, false,
|
||||||
mIsHtml ? DocumentFlavorHTML :
|
|
||||||
DocumentFlavorLegacyGuess,
|
|
||||||
getter_AddRefs(mResponseXML));
|
getter_AddRefs(mResponseXML));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
nsCOMPtr<nsIDocument> responseDoc = do_QueryInterface(mResponseXML);
|
nsCOMPtr<nsIDocument> responseDoc = do_QueryInterface(mResponseXML);
|
||||||
@ -2039,8 +1990,12 @@ nsXMLHttpRequest::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsCOMPtr<nsIParser> parser;
|
||||||
|
|
||||||
// Is this good enough here?
|
// Is this good enough here?
|
||||||
if (mState & XML_HTTP_REQUEST_PARSEBODY && mXMLParserStreamListener) {
|
if (mState & XML_HTTP_REQUEST_PARSEBODY && mXMLParserStreamListener) {
|
||||||
|
parser = do_QueryInterface(mXMLParserStreamListener);
|
||||||
|
NS_ABORT_IF_FALSE(parser, "stream listener was expected to be a parser");
|
||||||
mXMLParserStreamListener->OnStopRequest(request, ctxt, status);
|
mXMLParserStreamListener->OnStopRequest(request, ctxt, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2049,11 +2004,8 @@ nsXMLHttpRequest::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult
|
|||||||
mContext = nsnull;
|
mContext = nsnull;
|
||||||
|
|
||||||
// If we're received data since the last progress event, make sure to fire
|
// If we're received data since the last progress event, make sure to fire
|
||||||
// an event for it, except in the HTML case, defer the last progress event
|
// an event for it.
|
||||||
// until the parser is done.
|
MaybeDispatchProgressEvents(true);
|
||||||
if (!mIsHtml) {
|
|
||||||
MaybeDispatchProgressEvents(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
nsCOMPtr<nsIChannel> channel(do_QueryInterface(request));
|
nsCOMPtr<nsIChannel> channel(do_QueryInterface(request));
|
||||||
NS_ENSURE_TRUE(channel, NS_ERROR_UNEXPECTED);
|
NS_ENSURE_TRUE(channel, NS_ERROR_UNEXPECTED);
|
||||||
@ -2088,6 +2040,8 @@ nsXMLHttpRequest::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult
|
|||||||
mChannelEventSink = nsnull;
|
mChannelEventSink = nsnull;
|
||||||
mProgressEventSink = nsnull;
|
mProgressEventSink = nsnull;
|
||||||
|
|
||||||
|
mState &= ~XML_HTTP_REQUEST_SYNCLOOPING;
|
||||||
|
|
||||||
if (NS_FAILED(status)) {
|
if (NS_FAILED(status)) {
|
||||||
// This can happen if the server is unreachable. Other possible
|
// This can happen if the server is unreachable. Other possible
|
||||||
// reasons are that the user leaves the page or hits the ESC key.
|
// reasons are that the user leaves the page or hits the ESC key.
|
||||||
@ -2096,51 +2050,29 @@ nsXMLHttpRequest::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult
|
|||||||
mResponseXML = nsnull;
|
mResponseXML = nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_ASSERTION(!parser || parser->IsParserEnabled(),
|
||||||
|
"Parser blocked somehow?");
|
||||||
|
|
||||||
// If we're uninitialized at this point, we encountered an error
|
// If we're uninitialized at this point, we encountered an error
|
||||||
// earlier and listeners have already been notified. Also we do
|
// earlier and listeners have already been notified. Also we do
|
||||||
// not want to do this if we already completed.
|
// not want to do this if we already completed.
|
||||||
if (mState & (XML_HTTP_REQUEST_UNSENT |
|
if (mState & (XML_HTTP_REQUEST_UNSENT |
|
||||||
XML_HTTP_REQUEST_DONE)) {
|
XML_HTTP_REQUEST_DONE)) {
|
||||||
// If we never get far enough to call ChangeStateToDone(), we must be
|
|
||||||
// careful to stop sync looping.
|
|
||||||
mState &= ~XML_HTTP_REQUEST_SYNCLOOPING;
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mIsHtml) {
|
// We might have been sent non-XML data. If that was the case,
|
||||||
nsCOMPtr<nsIDOMEventTarget> eventTarget = do_QueryInterface(mResponseXML);
|
// we should null out the document member. The idea in this
|
||||||
nsEventListenerManager* manager = eventTarget->GetListenerManager(true);
|
// check here is that if there is no document element it is not
|
||||||
manager->AddEventListenerByType(new nsXHRParseEndListener(this),
|
// an XML document. We might need a fancier check...
|
||||||
NS_LITERAL_STRING("DOMContentLoaded"),
|
if (mResponseXML) {
|
||||||
NS_EVENT_FLAG_BUBBLE |
|
nsCOMPtr<nsIDOMElement> root;
|
||||||
NS_EVENT_FLAG_SYSTEM_EVENT);
|
mResponseXML->GetDocumentElement(getter_AddRefs(root));
|
||||||
} else {
|
if (!root) {
|
||||||
// We might have been sent non-XML data. If that was the case,
|
mResponseXML = nsnull;
|
||||||
// we should null out the document member. The idea in this
|
|
||||||
// check here is that if there is no document element it is not
|
|
||||||
// an XML document. We might need a fancier check...
|
|
||||||
if (!mIsHtml && mResponseXML) {
|
|
||||||
nsCOMPtr<nsIDOMElement> root;
|
|
||||||
mResponseXML->GetDocumentElement(getter_AddRefs(root));
|
|
||||||
if (!root) {
|
|
||||||
mResponseXML = nsnull;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ChangeStateToDone();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
nsXMLHttpRequest::ChangeStateToDone()
|
|
||||||
{
|
|
||||||
mState &= ~XML_HTTP_REQUEST_SYNCLOOPING;
|
|
||||||
if (mIsHtml) {
|
|
||||||
// In the HTML case, this has to be deferred, because the parser doesn't
|
|
||||||
// do it's job synchronously.
|
|
||||||
MaybeDispatchProgressEvents(true);
|
|
||||||
}
|
|
||||||
ChangeState(XML_HTTP_REQUEST_DONE, true);
|
ChangeState(XML_HTTP_REQUEST_DONE, true);
|
||||||
|
|
||||||
NS_NAMED_LITERAL_STRING(errorStr, ERROR_STR);
|
NS_NAMED_LITERAL_STRING(errorStr, ERROR_STR);
|
||||||
@ -2166,6 +2098,8 @@ nsXMLHttpRequest::ChangeStateToDone()
|
|||||||
// We're a multipart request, so we're not done. Reset to opened.
|
// We're a multipart request, so we're not done. Reset to opened.
|
||||||
ChangeState(XML_HTTP_REQUEST_OPENED);
|
ChangeState(XML_HTTP_REQUEST_OPENED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
@ -3113,13 +3047,11 @@ nsXMLHttpRequest::MaybeDispatchProgressEvents(bool aFinalProgress)
|
|||||||
mLoadTotal = mLoadTransferred;
|
mLoadTotal = mLoadTransferred;
|
||||||
mLoadLengthComputable = true;
|
mLoadLengthComputable = true;
|
||||||
}
|
}
|
||||||
if (aFinalProgress || !IsWaitingForHTMLCharset()) {
|
mInLoadProgressEvent = true;
|
||||||
mInLoadProgressEvent = true;
|
DispatchProgressEvent(this, NS_LITERAL_STRING(PROGRESS_STR),
|
||||||
DispatchProgressEvent(this, NS_LITERAL_STRING(PROGRESS_STR),
|
true, mLoadLengthComputable, mLoadTransferred,
|
||||||
true, mLoadLengthComputable, mLoadTransferred,
|
mLoadTotal, mLoadTransferred, mLoadTotal);
|
||||||
mLoadTotal, mLoadTransferred, mLoadTotal);
|
mInLoadProgressEvent = false;
|
||||||
mInLoadProgressEvent = false;
|
|
||||||
}
|
|
||||||
if (mResponseType == XML_HTTP_RESPONSE_TYPE_CHUNKED_TEXT ||
|
if (mResponseType == XML_HTTP_RESPONSE_TYPE_CHUNKED_TEXT ||
|
||||||
mResponseType == XML_HTTP_RESPONSE_TYPE_CHUNKED_ARRAYBUFFER) {
|
mResponseType == XML_HTTP_RESPONSE_TYPE_CHUNKED_ARRAYBUFFER) {
|
||||||
mResponseBody.Truncate();
|
mResponseBody.Truncate();
|
||||||
|
@ -123,7 +123,6 @@ class nsXMLHttpRequest : public nsXHREventTarget,
|
|||||||
public nsIJSNativeInitializer,
|
public nsIJSNativeInitializer,
|
||||||
public nsITimerCallback
|
public nsITimerCallback
|
||||||
{
|
{
|
||||||
friend class nsXHRParseEndListener;
|
|
||||||
public:
|
public:
|
||||||
nsXMLHttpRequest();
|
nsXMLHttpRequest();
|
||||||
virtual ~nsXMLHttpRequest();
|
virtual ~nsXMLHttpRequest();
|
||||||
@ -236,10 +235,6 @@ protected:
|
|||||||
|
|
||||||
bool IsSystemXHR();
|
bool IsSystemXHR();
|
||||||
|
|
||||||
bool IsWaitingForHTMLCharset();
|
|
||||||
|
|
||||||
void ChangeStateToDone();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if aChannel is ok for a cross-site request by making sure no
|
* Check if aChannel is ok for a cross-site request by making sure no
|
||||||
* inappropriate headers are set, and no username/password is set.
|
* inappropriate headers are set, and no username/password is set.
|
||||||
@ -352,8 +347,6 @@ protected:
|
|||||||
bool mTimerIsActive;
|
bool mTimerIsActive;
|
||||||
bool mProgressEventWasDelayed;
|
bool mProgressEventWasDelayed;
|
||||||
bool mLoadLengthComputable;
|
bool mLoadLengthComputable;
|
||||||
bool mIsHtml;
|
|
||||||
bool mWarnAboutMultipartHtml;
|
|
||||||
PRUint64 mLoadTotal; // 0 if not known.
|
PRUint64 mLoadTotal; // 0 if not known.
|
||||||
PRUint64 mLoadTransferred;
|
PRUint64 mLoadTransferred;
|
||||||
nsCOMPtr<nsITimer> mProgressNotifier;
|
nsCOMPtr<nsITimer> mProgressNotifier;
|
||||||
@ -439,24 +432,4 @@ protected:
|
|||||||
PRUint64 mMaxProgress;
|
PRUint64 mMaxProgress;
|
||||||
};
|
};
|
||||||
|
|
||||||
class nsXHRParseEndListener : public nsIDOMEventListener
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
NS_DECL_ISUPPORTS
|
|
||||||
NS_IMETHOD HandleEvent(nsIDOMEvent *event)
|
|
||||||
{
|
|
||||||
nsCOMPtr<nsIXMLHttpRequest> xhr = do_QueryReferent(mXHR);
|
|
||||||
if (xhr) {
|
|
||||||
static_cast<nsXMLHttpRequest*>(xhr.get())->ChangeStateToDone();
|
|
||||||
}
|
|
||||||
mXHR = nsnull;
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
nsXHRParseEndListener(nsIXMLHttpRequest* aXHR)
|
|
||||||
: mXHR(do_GetWeakReference(aXHR)) {}
|
|
||||||
virtual ~nsXHRParseEndListener() {}
|
|
||||||
private:
|
|
||||||
nsWeakPtr mXHR;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -505,12 +505,6 @@ _TEST_FILES2 = \
|
|||||||
somedatas.resource \
|
somedatas.resource \
|
||||||
somedatas.resource^headers^ \
|
somedatas.resource^headers^ \
|
||||||
delayedServerEvents.sjs \
|
delayedServerEvents.sjs \
|
||||||
test_html_in_xhr.html \
|
|
||||||
file_html_in_xhr.html \
|
|
||||||
file_html_in_xhr2.html \
|
|
||||||
file_html_in_xhr3.html \
|
|
||||||
file_html_in_xhr.sjs \
|
|
||||||
file_html_in_xhr_slow.sjs \
|
|
||||||
test_bug664916.html \
|
test_bug664916.html \
|
||||||
test_bug666604.html \
|
test_bug666604.html \
|
||||||
test_bug675121.html \
|
test_bug675121.html \
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html><!-- Þ -->
|
|
||||||
<meta charset="Windows-1251">
|
|
||||||
<script>
|
|
||||||
document.documentElement.setAttribute("data-fail", "FAIL");
|
|
||||||
</script>
|
|
||||||
<script src="file_html_in_xhr.sjs"></script>
|
|
||||||
<script src="file_html_in_xhr.sjs" defer></script>
|
|
||||||
<script src="file_html_in_xhr.sjs" async></script>
|
|
||||||
<link type="stylesheet" href="file_html_in_xhr.sjs">
|
|
||||||
<body onload='document.documentElement.setAttribute("data-fail", "FAIL");'>
|
|
||||||
<img src="file_html_in_xhr.sjs">
|
|
||||||
<iframe src="file_html_in_xhr.sjs"></iframe>
|
|
||||||
<video poster="file_html_in_xhr.sjs" src="file_html_in_xhr.sjs"></video>
|
|
||||||
<object data="file_html_in_xhr.sjs"></object>
|
|
||||||
<noscript><div></div></noscript>
|
|
@ -1,15 +0,0 @@
|
|||||||
function handleRequest(request, response)
|
|
||||||
{
|
|
||||||
response.setHeader("Content-Type", "text/javascript", false);
|
|
||||||
if (request.queryString.indexOf("report") != -1) {
|
|
||||||
if (getState("loaded") == "loaded") {
|
|
||||||
response.write("ok(false, 'This script was not supposed to get fetched.'); continueAfterReport();");
|
|
||||||
} else {
|
|
||||||
response.write("ok(true, 'This script was not supposed to get fetched.'); continueAfterReport();");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
setState("loaded", "loaded");
|
|
||||||
response.write('document.documentElement.setAttribute("data-fail", "FAIL");');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1 +0,0 @@
|
|||||||
<meta charset="windows-1251">Þ
|
|
@ -1 +0,0 @@
|
|||||||
SUCCESS
|
|
@ -1,24 +0,0 @@
|
|||||||
var timer;
|
|
||||||
|
|
||||||
function handleRequest(request, response)
|
|
||||||
{
|
|
||||||
var converter = Components.classes["@mozilla.org/intl/scriptableunicodeconverter"]
|
|
||||||
.createInstance(Components.interfaces.nsIScriptableUnicodeConverter);
|
|
||||||
converter.charset = "windows-1251";
|
|
||||||
var stream = converter.convertToInputStream("\u042E");
|
|
||||||
var out = response.bodyOutputStream;
|
|
||||||
response.setHeader("Cache-Control", "no-cache", false);
|
|
||||||
response.setHeader("Content-Type", "text/html", false);
|
|
||||||
out.writeFrom(stream, 1);
|
|
||||||
var firstPart = "<meta charset='windows";
|
|
||||||
out.write(firstPart, firstPart.length);
|
|
||||||
out.flush();
|
|
||||||
response.processAsync();
|
|
||||||
timer = Components.classes["@mozilla.org/timer;1"]
|
|
||||||
.createInstance(Components.interfaces.nsITimer);
|
|
||||||
timer.initWithCallback(function() {
|
|
||||||
response.write("-1251'>");
|
|
||||||
response.finish();
|
|
||||||
}, 500, Components.interfaces.nsITimer.TYPE_ONE_SHOT);
|
|
||||||
}
|
|
||||||
|
|
@ -1,118 +0,0 @@
|
|||||||
<!DOCTYPE HTML>
|
|
||||||
<html>
|
|
||||||
<!--
|
|
||||||
https://bugzilla.mozilla.org/show_bug.cgi?id=651072
|
|
||||||
-->
|
|
||||||
<head>
|
|
||||||
<title>Test for Bug 651072</title>
|
|
||||||
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
|
||||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
||||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
|
||||||
</head>
|
|
||||||
<body onload=runTest();>
|
|
||||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=651072">Mozilla Bug 651072</a>
|
|
||||||
<p id="display"></p>
|
|
||||||
<div id="content" style="display: none">
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<pre id="test">
|
|
||||||
<script class="testbody" type="text/javascript">
|
|
||||||
|
|
||||||
/** Test for Bug 651072 **/
|
|
||||||
SimpleTest.waitForExplicitFinish();
|
|
||||||
|
|
||||||
var xhr = new XMLHttpRequest();
|
|
||||||
var runNumber = 0;
|
|
||||||
|
|
||||||
function runTest() {
|
|
||||||
runNumber++;
|
|
||||||
xhr.onreadystatechange = function() {
|
|
||||||
if (this.readyState == 4) {
|
|
||||||
ok(this.responseXML, "Should have gotten responseXML");
|
|
||||||
is(this.responseXML.characterSet, "windows-1251", "Wrong character encoding");
|
|
||||||
is(this.responseXML.documentElement.firstChild.data, " \u042E ", "Decoded using the wrong encoding.");
|
|
||||||
is(this.responseText.indexOf("\u042E"), 27, "Bad responseText");
|
|
||||||
is(this.responseXML.getElementsByTagName("div").length, 1, "There should be one div.");
|
|
||||||
ok(!this.responseXML.documentElement.hasAttribute("data-fail"), "Should not have a data-fail attribute.");
|
|
||||||
var scripts = this.responseXML.getElementsByTagName("script");
|
|
||||||
is(scripts.length, 4, "Unexpected number of scripts.");
|
|
||||||
while (scripts.length) {
|
|
||||||
// These should not run when moved to another doc
|
|
||||||
document.body.appendChild(scripts[0]);
|
|
||||||
}
|
|
||||||
if (runNumber == 1) {
|
|
||||||
runTest();
|
|
||||||
} else {
|
|
||||||
var s = document.createElement("script");
|
|
||||||
s.src = "file_html_in_xhr.sjs?report=1";
|
|
||||||
document.body.appendChild(s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
xhr.open("GET", "file_html_in_xhr.html", runNumber == 1);
|
|
||||||
xhr.send();
|
|
||||||
}
|
|
||||||
|
|
||||||
function continueAfterReport() {
|
|
||||||
ok(!document.documentElement.hasAttribute("data-fail"), "Should not have a data-fail attribute on mochitest doc.");
|
|
||||||
xhr = new XMLHttpRequest();
|
|
||||||
xhr.onprogress = function() {
|
|
||||||
ok(this.responseText, "Got falsy responseText");
|
|
||||||
if (this.responseText) {
|
|
||||||
ok(this.responseText.length, "Got zero-length responseText");
|
|
||||||
if (this.responseText.length) {
|
|
||||||
is(this.responseText.charCodeAt(0), 0x042E, "Wrong character encoding for slow text");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
xhr.onreadystatechange = function() {
|
|
||||||
if (this.readyState == 4) {
|
|
||||||
testNonParsingText();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
xhr.open("GET", "file_html_in_xhr_slow.sjs");
|
|
||||||
xhr.send();
|
|
||||||
}
|
|
||||||
|
|
||||||
function testNonParsingText() {
|
|
||||||
xhr = new XMLHttpRequest();
|
|
||||||
xhr.onreadystatechange = function() {
|
|
||||||
if (this.readyState == 4) {
|
|
||||||
is(this.responseText.indexOf("\u042E"), -1, "Honored meta in text mode.");
|
|
||||||
is(this.responseText.indexOf("\uFFFD"), 29, "Honored meta in text mode 2.");
|
|
||||||
testChunkedText();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
xhr.open("GET", "file_html_in_xhr2.html");
|
|
||||||
xhr.responseType = "text";
|
|
||||||
xhr.send();
|
|
||||||
}
|
|
||||||
|
|
||||||
function testChunkedText() {
|
|
||||||
xhr = new XMLHttpRequest();
|
|
||||||
xhr.onprogress = function() {
|
|
||||||
is(this.responseText.indexOf("\u042E"), -1, "Honored meta in chunked text mode.");
|
|
||||||
}
|
|
||||||
xhr.onreadystatechange = function() {
|
|
||||||
if (this.readyState == 4) {
|
|
||||||
testSyncXHR();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
xhr.open("GET", "file_html_in_xhr2.html");
|
|
||||||
xhr.responseType = "moz-chunked-text";
|
|
||||||
xhr.send();
|
|
||||||
}
|
|
||||||
|
|
||||||
function testSyncXHR() {
|
|
||||||
xhr = new XMLHttpRequest();
|
|
||||||
xhr.open("GET", "file_html_in_xhr3.html", false);
|
|
||||||
xhr.send();
|
|
||||||
is(xhr.responseText, "SUCCESS\n", "responseText should be ready by now");
|
|
||||||
SimpleTest.finish();
|
|
||||||
}
|
|
||||||
|
|
||||||
</script>
|
|
||||||
</pre>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
@ -699,7 +699,7 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Proper about:blank treatment is bug 543435
|
// TODO: Proper about:blank treatment is bug 543435
|
||||||
if (loadAsHtml5 && aCommand && !nsCRT::strcmp(aCommand, "view")) {
|
if (loadAsHtml5 && !viewSource) {
|
||||||
// mDocumentURI hasn't been set, yet, so get the URI from the channel
|
// mDocumentURI hasn't been set, yet, so get the URI from the channel
|
||||||
nsCOMPtr<nsIURI> uri;
|
nsCOMPtr<nsIURI> uri;
|
||||||
aChannel->GetOriginalURI(getter_AddRefs(uri));
|
aChannel->GetOriginalURI(getter_AddRefs(uri));
|
||||||
@ -771,6 +771,9 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
|
|||||||
// and parentContentViewer
|
// and parentContentViewer
|
||||||
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(aContainer));
|
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(aContainer));
|
||||||
|
|
||||||
|
// No support yet for docshell-less HTML
|
||||||
|
NS_ENSURE_TRUE(docShell || !IsHTML(), NS_ERROR_FAILURE);
|
||||||
|
|
||||||
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(docShell));
|
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(docShell));
|
||||||
|
|
||||||
nsCOMPtr<nsIDocShellTreeItem> parentAsItem;
|
nsCOMPtr<nsIDocShellTreeItem> parentAsItem;
|
||||||
@ -807,6 +810,9 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsCAutoString scheme;
|
||||||
|
uri->GetScheme(scheme);
|
||||||
|
|
||||||
nsCAutoString urlSpec;
|
nsCAutoString urlSpec;
|
||||||
uri->GetSpec(urlSpec);
|
uri->GetSpec(urlSpec);
|
||||||
#ifdef DEBUG_charset
|
#ifdef DEBUG_charset
|
||||||
@ -824,9 +830,8 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
|
|||||||
|
|
||||||
nsCOMPtr<nsIWyciwygChannel> wyciwygChannel;
|
nsCOMPtr<nsIWyciwygChannel> wyciwygChannel;
|
||||||
|
|
||||||
if (!IsHTML() || !docShell) { // no docshell for text/html XHR
|
if (!IsHTML()) {
|
||||||
charsetSource = IsHTML() ? kCharsetFromWeakDocTypeDefault
|
charsetSource = kCharsetFromDocTypeDefault;
|
||||||
: kCharsetFromDocTypeDefault;
|
|
||||||
charset.AssignLiteral("UTF-8");
|
charset.AssignLiteral("UTF-8");
|
||||||
TryChannelCharset(aChannel, charsetSource, charset);
|
TryChannelCharset(aChannel, charsetSource, charset);
|
||||||
parserCharsetSource = charsetSource;
|
parserCharsetSource = charsetSource;
|
||||||
|
@ -105,7 +105,7 @@ NS_NewDOMDocument(nsIDOMDocument** aInstancePtrResult,
|
|||||||
nsIPrincipal* aPrincipal,
|
nsIPrincipal* aPrincipal,
|
||||||
bool aLoadedAsData,
|
bool aLoadedAsData,
|
||||||
nsIScriptGlobalObject* aEventObject,
|
nsIScriptGlobalObject* aEventObject,
|
||||||
DocumentFlavor aFlavor)
|
bool aSVGDocument)
|
||||||
{
|
{
|
||||||
// Note: can't require that aDocumentURI/aBaseURI/aPrincipal be non-null,
|
// Note: can't require that aDocumentURI/aBaseURI/aPrincipal be non-null,
|
||||||
// since at least one caller (XMLHttpRequest) doesn't have decent args to
|
// since at least one caller (XMLHttpRequest) doesn't have decent args to
|
||||||
@ -118,11 +118,8 @@ NS_NewDOMDocument(nsIDOMDocument** aInstancePtrResult,
|
|||||||
nsCOMPtr<nsIDocument> d;
|
nsCOMPtr<nsIDocument> d;
|
||||||
bool isHTML = false;
|
bool isHTML = false;
|
||||||
bool isXHTML = false;
|
bool isXHTML = false;
|
||||||
if (aFlavor == DocumentFlavorSVG) {
|
if (aSVGDocument) {
|
||||||
rv = NS_NewSVGDocument(getter_AddRefs(d));
|
rv = NS_NewSVGDocument(getter_AddRefs(d));
|
||||||
} else if (aFlavor == DocumentFlavorHTML) {
|
|
||||||
rv = NS_NewHTMLDocument(getter_AddRefs(d));
|
|
||||||
isHTML = true;
|
|
||||||
} else if (aDoctype) {
|
} else if (aDoctype) {
|
||||||
nsAutoString publicId, name;
|
nsAutoString publicId, name;
|
||||||
aDoctype->GetPublicId(publicId);
|
aDoctype->GetPublicId(publicId);
|
||||||
@ -232,7 +229,7 @@ NS_NewXBLDocument(nsIDOMDocument** aInstancePtrResult,
|
|||||||
NS_LITERAL_STRING("http://www.mozilla.org/xbl"),
|
NS_LITERAL_STRING("http://www.mozilla.org/xbl"),
|
||||||
NS_LITERAL_STRING("bindings"), nsnull,
|
NS_LITERAL_STRING("bindings"), nsnull,
|
||||||
aDocumentURI, aBaseURI, aPrincipal, false,
|
aDocumentURI, aBaseURI, aPrincipal, false,
|
||||||
nsnull, DocumentFlavorLegacyGuess);
|
nsnull, false);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
nsCOMPtr<nsIDocument> idoc = do_QueryInterface(*aInstancePtrResult);
|
nsCOMPtr<nsIDocument> idoc = do_QueryInterface(*aInstancePtrResult);
|
||||||
|
@ -115,4 +115,3 @@ nsIJSONEncodeDeprecatedWarning=nsIJSON.encode is deprecated. Please use JSON.st
|
|||||||
nsIDOMWindowInternalWarning=Use of nsIDOMWindowInternal is deprecated. Use nsIDOMWindow instead.
|
nsIDOMWindowInternalWarning=Use of nsIDOMWindowInternal is deprecated. Use nsIDOMWindow instead.
|
||||||
InputEncodingWarning=Use of inputEncoding is deprecated.
|
InputEncodingWarning=Use of inputEncoding is deprecated.
|
||||||
GlobalStorageWarning=Use of globalStorage is deprecated. Please use localStorage instead.
|
GlobalStorageWarning=Use of globalStorage is deprecated. Please use localStorage instead.
|
||||||
HTMLMultipartXHRWarning=HTML parsing in XMLHttpRequest is not supported for multipart responses.
|
|
@ -128,10 +128,8 @@ nsHtml5Parser::GetCommand(nsCString& aCommand)
|
|||||||
NS_IMETHODIMP_(void)
|
NS_IMETHODIMP_(void)
|
||||||
nsHtml5Parser::SetCommand(const char* aCommand)
|
nsHtml5Parser::SetCommand(const char* aCommand)
|
||||||
{
|
{
|
||||||
NS_ASSERTION(!strcmp(aCommand, "view") ||
|
NS_ASSERTION(!strcmp(aCommand, "view") || !strcmp(aCommand, "view-source"),
|
||||||
!strcmp(aCommand, "view-source") ||
|
"Parser command was not view");
|
||||||
!strcmp(aCommand, kLoadAsData),
|
|
||||||
"Unsupported parser command");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP_(void)
|
NS_IMETHODIMP_(void)
|
||||||
@ -714,8 +712,6 @@ nsHtml5Parser::MarkAsNotScriptCreated(const char* aCommand)
|
|||||||
mode = VIEW_SOURCE_XML;
|
mode = VIEW_SOURCE_XML;
|
||||||
} else if (!nsCRT::strcmp(aCommand, "plain-text")) {
|
} else if (!nsCRT::strcmp(aCommand, "plain-text")) {
|
||||||
mode = PLAIN_TEXT;
|
mode = PLAIN_TEXT;
|
||||||
} else if (!nsCRT::strcmp(aCommand, kLoadAsData)) {
|
|
||||||
mode = LOAD_AS_DATA;
|
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
else {
|
else {
|
||||||
@ -833,9 +829,6 @@ nsHtml5Parser::Initialize(nsIDocument* aDoc,
|
|||||||
|
|
||||||
void
|
void
|
||||||
nsHtml5Parser::StartTokenizer(bool aScriptingEnabled) {
|
nsHtml5Parser::StartTokenizer(bool aScriptingEnabled) {
|
||||||
if (!aScriptingEnabled) {
|
|
||||||
mExecutor->PreventScriptExecution();
|
|
||||||
}
|
|
||||||
mTreeBuilder->setScriptingEnabled(aScriptingEnabled);
|
mTreeBuilder->setScriptingEnabled(aScriptingEnabled);
|
||||||
mTokenizer->start();
|
mTokenizer->start();
|
||||||
}
|
}
|
||||||
|
@ -356,10 +356,6 @@ void
|
|||||||
nsHtml5StreamParser::SniffBOMlessUTF16BasicLatin(const PRUint8* aFromSegment,
|
nsHtml5StreamParser::SniffBOMlessUTF16BasicLatin(const PRUint8* aFromSegment,
|
||||||
PRUint32 aCountToSniffingLimit)
|
PRUint32 aCountToSniffingLimit)
|
||||||
{
|
{
|
||||||
// Avoid underspecified heuristic craziness for XHR
|
|
||||||
if (mMode == LOAD_AS_DATA) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Make sure there's enough data. Require room for "<title></title>"
|
// Make sure there's enough data. Require room for "<title></title>"
|
||||||
if (mSniffingLength + aCountToSniffingLimit < 30) {
|
if (mSniffingLength + aCountToSniffingLimit < 30) {
|
||||||
return;
|
return;
|
||||||
@ -613,15 +609,6 @@ nsHtml5StreamParser::FinalizeSniffing(const PRUint8* aFromSegment, // can be nul
|
|||||||
mCharset.AssignLiteral("windows-1252");
|
mCharset.AssignLiteral("windows-1252");
|
||||||
mCharsetSource = kCharsetFromWeakDocTypeDefault;
|
mCharsetSource = kCharsetFromWeakDocTypeDefault;
|
||||||
mTreeBuilder->SetDocumentCharset(mCharset, mCharsetSource);
|
mTreeBuilder->SetDocumentCharset(mCharset, mCharsetSource);
|
||||||
} else if (mMode == LOAD_AS_DATA &&
|
|
||||||
mCharsetSource == kCharsetFromWeakDocTypeDefault) {
|
|
||||||
NS_ASSERTION(mReparseForbidden, "Reparse should be forbidden for XHR");
|
|
||||||
NS_ASSERTION(!mFeedChardet, "Should not feed chardet for XHR");
|
|
||||||
NS_ASSERTION(mCharset.EqualsLiteral("UTF-8"),
|
|
||||||
"XHR should default to UTF-8");
|
|
||||||
// Now mark charset source as non-weak to signal that we have a decision
|
|
||||||
mCharsetSource = kCharsetFromDocTypeDefault;
|
|
||||||
mTreeBuilder->SetDocumentCharset(mCharset, mCharsetSource);
|
|
||||||
}
|
}
|
||||||
return SetupDecodingAndWriteSniffingBufferAndCurrentSegment(aFromSegment, aCount, aWriteCount);
|
return SetupDecodingAndWriteSniffingBufferAndCurrentSegment(aFromSegment, aCount, aWriteCount);
|
||||||
}
|
}
|
||||||
@ -703,9 +690,7 @@ nsHtml5StreamParser::SniffStreamBytes(const PRUint8* aFromSegment,
|
|||||||
}
|
}
|
||||||
// if we get here, there either was no BOM or the BOM sniffing isn't complete yet
|
// if we get here, there either was no BOM or the BOM sniffing isn't complete yet
|
||||||
|
|
||||||
if (!mMetaScanner && (mMode == NORMAL ||
|
if (!mMetaScanner && (mMode == NORMAL || mMode == VIEW_SOURCE_HTML)) {
|
||||||
mMode == VIEW_SOURCE_HTML ||
|
|
||||||
mMode == LOAD_AS_DATA)) {
|
|
||||||
mMetaScanner = new nsHtml5MetaScanner();
|
mMetaScanner = new nsHtml5MetaScanner();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -713,7 +698,7 @@ nsHtml5StreamParser::SniffStreamBytes(const PRUint8* aFromSegment,
|
|||||||
// this is the last buffer
|
// this is the last buffer
|
||||||
PRUint32 countToSniffingLimit =
|
PRUint32 countToSniffingLimit =
|
||||||
NS_HTML5_STREAM_PARSER_SNIFFING_BUFFER_SIZE - mSniffingLength;
|
NS_HTML5_STREAM_PARSER_SNIFFING_BUFFER_SIZE - mSniffingLength;
|
||||||
if (mMode == NORMAL || mMode == VIEW_SOURCE_HTML || mMode == LOAD_AS_DATA) {
|
if (mMode == NORMAL || mMode == VIEW_SOURCE_HTML) {
|
||||||
nsHtml5ByteReadable readable(aFromSegment, aFromSegment +
|
nsHtml5ByteReadable readable(aFromSegment, aFromSegment +
|
||||||
countToSniffingLimit);
|
countToSniffingLimit);
|
||||||
mMetaScanner->sniff(&readable, getter_AddRefs(mUnicodeDecoder), mCharset);
|
mMetaScanner->sniff(&readable, getter_AddRefs(mUnicodeDecoder), mCharset);
|
||||||
@ -734,7 +719,7 @@ nsHtml5StreamParser::SniffStreamBytes(const PRUint8* aFromSegment,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// not the last buffer
|
// not the last buffer
|
||||||
if (mMode == NORMAL || mMode == VIEW_SOURCE_HTML || mMode == LOAD_AS_DATA) {
|
if (mMode == NORMAL || mMode == VIEW_SOURCE_HTML) {
|
||||||
nsHtml5ByteReadable readable(aFromSegment, aFromSegment + aCount);
|
nsHtml5ByteReadable readable(aFromSegment, aFromSegment + aCount);
|
||||||
mMetaScanner->sniff(&readable, getter_AddRefs(mUnicodeDecoder), mCharset);
|
mMetaScanner->sniff(&readable, getter_AddRefs(mUnicodeDecoder), mCharset);
|
||||||
if (mUnicodeDecoder) {
|
if (mUnicodeDecoder) {
|
||||||
@ -884,8 +869,7 @@ nsHtml5StreamParser::OnStartRequest(nsIRequest* aRequest, nsISupports* aContext)
|
|||||||
}
|
}
|
||||||
// For View Source, the parser should run with scripts "enabled" if a normal
|
// For View Source, the parser should run with scripts "enabled" if a normal
|
||||||
// load would have scripts enabled.
|
// load would have scripts enabled.
|
||||||
bool scriptingEnabled = mMode == LOAD_AS_DATA ?
|
bool scriptingEnabled = mExecutor->IsScriptEnabled();
|
||||||
false : mExecutor->IsScriptEnabled();
|
|
||||||
mOwner->StartTokenizer(scriptingEnabled);
|
mOwner->StartTokenizer(scriptingEnabled);
|
||||||
mTreeBuilder->setScriptingEnabled(scriptingEnabled);
|
mTreeBuilder->setScriptingEnabled(scriptingEnabled);
|
||||||
mTokenizer->start();
|
mTokenizer->start();
|
||||||
|
@ -79,12 +79,7 @@ enum eParserMode {
|
|||||||
/**
|
/**
|
||||||
* View document as plain text
|
* View document as plain text
|
||||||
*/
|
*/
|
||||||
PLAIN_TEXT,
|
PLAIN_TEXT
|
||||||
|
|
||||||
/**
|
|
||||||
* Load as data (XHR)
|
|
||||||
*/
|
|
||||||
LOAD_AS_DATA
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum eBomState {
|
enum eBomState {
|
||||||
|
@ -737,10 +737,10 @@ nsHtml5TreeOpExecutor::RunScript(nsIContent* aScriptElement)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mPreventScriptExecution) {
|
|
||||||
sele->PreventExecution();
|
|
||||||
}
|
|
||||||
if (mFragmentMode) {
|
if (mFragmentMode) {
|
||||||
|
if (mPreventScriptExecution) {
|
||||||
|
sele->PreventExecution();
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,7 +153,7 @@ class nsHtml5TreeOpExecutor : public nsContentSink,
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
NS_IMETHOD WillBuildModel(nsDTDMode aDTDMode) {
|
NS_IMETHOD WillBuildModel(nsDTDMode aDTDMode) {
|
||||||
NS_ASSERTION(!mDocShell || GetDocument()->GetScriptGlobalObject(),
|
NS_ASSERTION(GetDocument()->GetScriptGlobalObject(),
|
||||||
"Script global object not ready");
|
"Script global object not ready");
|
||||||
mDocument->AddObserver(this);
|
mDocument->AddObserver(this);
|
||||||
WillBuildModelImpl();
|
WillBuildModelImpl();
|
||||||
@ -253,10 +253,6 @@ class nsHtml5TreeOpExecutor : public nsContentSink,
|
|||||||
mPreventScriptExecution = aPreventScriptExecution;
|
mPreventScriptExecution = aPreventScriptExecution;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreventScriptExecution() {
|
|
||||||
mPreventScriptExecution = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IsFragmentMode() {
|
bool IsFragmentMode() {
|
||||||
return mFragmentMode;
|
return mFragmentMode;
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ enum eParserDocType {
|
|||||||
#define kCharsetUninitialized 0
|
#define kCharsetUninitialized 0
|
||||||
#define kCharsetFromWeakDocTypeDefault 1
|
#define kCharsetFromWeakDocTypeDefault 1
|
||||||
#define kCharsetFromUserDefault 2
|
#define kCharsetFromUserDefault 2
|
||||||
#define kCharsetFromDocTypeDefault 3 // This and up confident for XHR
|
#define kCharsetFromDocTypeDefault 3
|
||||||
#define kCharsetFromCache 4
|
#define kCharsetFromCache 4
|
||||||
#define kCharsetFromParentFrame 5
|
#define kCharsetFromParentFrame 5
|
||||||
#define kCharsetFromAutoDetection 6
|
#define kCharsetFromAutoDetection 6
|
||||||
|
Loading…
x
Reference in New Issue
Block a user