Bug 592829: Make parsing code able to deal with element creation failing. r=jst/peterv a=blocker
This commit is contained in:
@@ -59,6 +59,9 @@
|
|||||||
#include "nsDOMError.h"
|
#include "nsDOMError.h"
|
||||||
#include "nsIDOMWindow.h"
|
#include "nsIDOMWindow.h"
|
||||||
#include "nsPIDOMWindow.h"
|
#include "nsPIDOMWindow.h"
|
||||||
|
#include "mozilla/AutoRestore.h"
|
||||||
|
|
||||||
|
using namespace mozilla;
|
||||||
|
|
||||||
// nsIDOMEventListener
|
// nsIDOMEventListener
|
||||||
nsresult
|
nsresult
|
||||||
@@ -263,6 +266,7 @@ nsDOMParser::ParseFromStream(nsIInputStream *stream,
|
|||||||
// Tell the document to start loading
|
// Tell the document to start loading
|
||||||
nsCOMPtr<nsIStreamListener> listener;
|
nsCOMPtr<nsIStreamListener> listener;
|
||||||
|
|
||||||
|
AutoRestore<PRPackedBool> restoreSyncLoop(mLoopingForSyncLoad);
|
||||||
mLoopingForSyncLoad = PR_TRUE;
|
mLoopingForSyncLoad = PR_TRUE;
|
||||||
|
|
||||||
// Have to pass PR_FALSE for reset here, else the reset will remove
|
// Have to pass PR_FALSE for reset here, else the reset will remove
|
||||||
|
|||||||
@@ -260,6 +260,7 @@ _TEST_FILES1 = test_bug5141.html \
|
|||||||
test_bug505783.html \
|
test_bug505783.html \
|
||||||
test_bug457746.html \
|
test_bug457746.html \
|
||||||
test_bug587931.html \
|
test_bug587931.html \
|
||||||
|
test_bug592829.html \
|
||||||
test_bug518104.html \
|
test_bug518104.html \
|
||||||
bug457746.sjs \
|
bug457746.sjs \
|
||||||
test_CrossSiteXHR.html \
|
test_CrossSiteXHR.html \
|
||||||
|
|||||||
42
content/base/test/test_bug592829.html
Normal file
42
content/base/test/test_bug592829.html
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
<!--
|
||||||
|
https://bugzilla.mozilla.org/show_bug.cgi?id=592829
|
||||||
|
-->
|
||||||
|
<head>
|
||||||
|
<title>Test for Bug 592829</title>
|
||||||
|
<script type="application/javascript" src="/MochiKit/packed.js"></script>
|
||||||
|
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||||
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=592829">Mozilla Bug 592829</a>
|
||||||
|
<pre id="test">
|
||||||
|
<script type="application/javascript">
|
||||||
|
/** Test for Bug 592829 **/
|
||||||
|
|
||||||
|
// NOTE! It's imperative that we don't call .init() here. Otherwise we're not
|
||||||
|
// testing what happens if parsing fails.
|
||||||
|
// If we ever change how DOMParser initilization works, just update this code
|
||||||
|
// to create a DOMParser which is not allowed to parse XUL.
|
||||||
|
|
||||||
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||||
|
|
||||||
|
var isXUL = true;
|
||||||
|
try {
|
||||||
|
var x =
|
||||||
|
Components.classes["@mozilla.org/xmlextras/domparser;1"]
|
||||||
|
.getService(Components.interfaces.nsIDOMParser)
|
||||||
|
.parseFromString('<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"/>', "text/xml");
|
||||||
|
isXUL = x.documentElement.namespaceURI ==
|
||||||
|
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
||||||
|
}
|
||||||
|
catch (ex) {
|
||||||
|
isXUL = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
is(isXUL, false, "We didn't create XUL and we didn't crash!");
|
||||||
|
</script>
|
||||||
|
</pre>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -871,15 +871,14 @@ nsXMLContentSink::GetCurrentContent()
|
|||||||
if (mContentStack.Length() == 0) {
|
if (mContentStack.Length() == 0) {
|
||||||
return nsnull;
|
return nsnull;
|
||||||
}
|
}
|
||||||
return GetCurrentStackNode().mContent;
|
return GetCurrentStackNode()->mContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
StackNode &
|
StackNode*
|
||||||
nsXMLContentSink::GetCurrentStackNode()
|
nsXMLContentSink::GetCurrentStackNode()
|
||||||
{
|
{
|
||||||
PRInt32 count = mContentStack.Length();
|
PRInt32 count = mContentStack.Length();
|
||||||
NS_ASSERTION(count > 0, "Bogus Length()");
|
return count != 0 ? &mContentStack[count-1] : nsnull;
|
||||||
return mContentStack[count-1];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1116,11 +1115,14 @@ nsXMLContentSink::HandleEndElement(const PRUnichar *aName,
|
|||||||
|
|
||||||
FlushText();
|
FlushText();
|
||||||
|
|
||||||
StackNode & sn = GetCurrentStackNode();
|
StackNode* sn = GetCurrentStackNode();
|
||||||
|
if (!sn) {
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIContent> content;
|
nsCOMPtr<nsIContent> content;
|
||||||
sn.mContent.swap(content);
|
sn->mContent.swap(content);
|
||||||
PRUint32 numFlushed = sn.mNumFlushed;
|
PRUint32 numFlushed = sn->mNumFlushed;
|
||||||
|
|
||||||
PopContent();
|
PopContent();
|
||||||
NS_ASSERTION(content, "failed to pop content");
|
NS_ASSERTION(content, "failed to pop content");
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ protected:
|
|||||||
nsresult AddContentAsLeaf(nsIContent *aContent);
|
nsresult AddContentAsLeaf(nsIContent *aContent);
|
||||||
|
|
||||||
nsIContent* GetCurrentContent();
|
nsIContent* GetCurrentContent();
|
||||||
StackNode & GetCurrentStackNode();
|
StackNode* GetCurrentStackNode();
|
||||||
nsresult PushContent(nsIContent *aContent);
|
nsresult PushContent(nsIContent *aContent);
|
||||||
void PopContent();
|
void PopContent();
|
||||||
PRBool HaveNotifiedForCurrentContent() const;
|
PRBool HaveNotifiedForCurrentContent() const;
|
||||||
|
|||||||
@@ -1414,7 +1414,10 @@ nsExpatDriver::MaybeStopParser(nsresult aState)
|
|||||||
mInternalState == NS_ERROR_HTMLPARSER_INTERRUPTED ||
|
mInternalState == NS_ERROR_HTMLPARSER_INTERRUPTED ||
|
||||||
(mInternalState == NS_ERROR_HTMLPARSER_BLOCK &&
|
(mInternalState == NS_ERROR_HTMLPARSER_BLOCK &&
|
||||||
aState != NS_ERROR_HTMLPARSER_INTERRUPTED)) {
|
aState != NS_ERROR_HTMLPARSER_INTERRUPTED)) {
|
||||||
mInternalState = aState;
|
mInternalState = (aState == NS_ERROR_HTMLPARSER_INTERRUPTED ||
|
||||||
|
aState == NS_ERROR_HTMLPARSER_BLOCK) ?
|
||||||
|
aState :
|
||||||
|
NS_ERROR_HTMLPARSER_STOPPARSING;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we get an error then we need to stop Expat (by calling XML_StopParser
|
// If we get an error then we need to stop Expat (by calling XML_StopParser
|
||||||
|
|||||||
Reference in New Issue
Block a user