mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
Bug 1017932. Don't expose the XMLDocument bits on the return value of new Document(). r=peterv
This commit is contained in:
parent
da05bf53a8
commit
8b3fd69b49
@ -138,7 +138,8 @@ typedef CallbackObjectHolder<NodeFilter, nsIDOMNodeFilter> NodeFilterHolder;
|
||||
enum DocumentFlavor {
|
||||
DocumentFlavorLegacyGuess, // compat with old code until made HTML5-compliant
|
||||
DocumentFlavorHTML, // HTMLDocument with HTMLness bit set to true
|
||||
DocumentFlavorSVG // SVGDocument
|
||||
DocumentFlavorSVG, // SVGDocument
|
||||
DocumentFlavorPlain, // Just a Document
|
||||
};
|
||||
|
||||
// Document states
|
||||
@ -2685,7 +2686,8 @@ nsresult
|
||||
NS_NewHTMLDocument(nsIDocument** aInstancePtrResult, bool aLoadedAsData = false);
|
||||
|
||||
nsresult
|
||||
NS_NewXMLDocument(nsIDocument** aInstancePtrResult, bool aLoadedAsData = false);
|
||||
NS_NewXMLDocument(nsIDocument** aInstancePtrResult, bool aLoadedAsData = false,
|
||||
bool aIsPlainDocument = false);
|
||||
|
||||
nsresult
|
||||
NS_NewSVGDocument(nsIDocument** aInstancePtrResult);
|
||||
|
@ -12067,7 +12067,7 @@ nsIDocument::Constructor(const GlobalObject& aGlobal,
|
||||
prin->GetPrincipal(),
|
||||
true,
|
||||
global,
|
||||
DocumentFlavorLegacyGuess);
|
||||
DocumentFlavorPlain);
|
||||
if (NS_FAILED(res)) {
|
||||
rv.Throw(res);
|
||||
return nullptr;
|
||||
|
@ -566,6 +566,7 @@ skip-if = buildapp == 'b2g' || toolkit == 'android' || e10s #bug 904183 # b2g(cl
|
||||
skip-if = buildapp == 'b2g' || toolkit == 'android' #bug 904183 # b2g(bug 904183) b2g-debug(bug 904183) b2g-desktop(bug 904183)
|
||||
[test_createHTMLDocument.html]
|
||||
[test_declare_stylesheet_obsolete.html]
|
||||
[test_document_constructor.html]
|
||||
[test_domparser_null_char.html]
|
||||
[test_domparsing.html]
|
||||
[test_elementTraversal.html]
|
||||
|
31
content/base/test/test_document_constructor.html
Normal file
31
content/base/test/test_document_constructor.html
Normal file
@ -0,0 +1,31 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1017932
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 1017932</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 1017932 **/
|
||||
var doc = new Document;
|
||||
ok(doc instanceof Document, "Should have a document");
|
||||
ok(!(doc instanceof XMLDocument), "Should not be an XMLDocument");
|
||||
ok(!("load" in doc), "Should not have a load() method");
|
||||
is(Object.getPrototypeOf(doc), Document.prototype,
|
||||
"Should have the right proto");
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1017932">Mozilla Bug 1017932</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
@ -50,6 +50,7 @@
|
||||
#include "mozilla/EventDispatcher.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/XMLDocumentBinding.h"
|
||||
#include "mozilla/dom/DocumentBinding.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
@ -87,7 +88,10 @@ NS_NewDOMDocument(nsIDOMDocument** aInstancePtrResult,
|
||||
} else if (aFlavor == DocumentFlavorHTML) {
|
||||
rv = NS_NewHTMLDocument(getter_AddRefs(d));
|
||||
isHTML = true;
|
||||
} else if (aFlavor == DocumentFlavorPlain) {
|
||||
rv = NS_NewXMLDocument(getter_AddRefs(d), aLoadedAsData, true);
|
||||
} else if (aDoctype) {
|
||||
MOZ_ASSERT(aFlavor == DocumentFlavorLegacyGuess);
|
||||
nsAutoString publicId, name;
|
||||
aDoctype->GetPublicId(publicId);
|
||||
if (publicId.IsEmpty()) {
|
||||
@ -117,6 +121,7 @@ NS_NewDOMDocument(nsIDOMDocument** aInstancePtrResult,
|
||||
rv = NS_NewXMLDocument(getter_AddRefs(d));
|
||||
}
|
||||
} else {
|
||||
MOZ_ASSERT(aFlavor == DocumentFlavorLegacyGuess);
|
||||
rv = NS_NewXMLDocument(getter_AddRefs(d));
|
||||
}
|
||||
|
||||
@ -172,7 +177,8 @@ NS_NewDOMDocument(nsIDOMDocument** aInstancePtrResult,
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_NewXMLDocument(nsIDocument** aInstancePtrResult, bool aLoadedAsData)
|
||||
NS_NewXMLDocument(nsIDocument** aInstancePtrResult, bool aLoadedAsData,
|
||||
bool aIsPlainDocument)
|
||||
{
|
||||
nsRefPtr<XMLDocument> doc = new XMLDocument();
|
||||
|
||||
@ -184,6 +190,7 @@ NS_NewXMLDocument(nsIDocument** aInstancePtrResult, bool aLoadedAsData)
|
||||
}
|
||||
|
||||
doc->SetLoadedAsData(aLoadedAsData);
|
||||
doc->mIsPlainDocument = aIsPlainDocument;
|
||||
doc.forget(aInstancePtrResult);
|
||||
|
||||
return NS_OK;
|
||||
@ -597,6 +604,7 @@ XMLDocument::Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const
|
||||
|
||||
// State from XMLDocument
|
||||
clone->mAsync = mAsync;
|
||||
clone->mIsPlainDocument = mIsPlainDocument;
|
||||
|
||||
return CallQueryInterface(clone.get(), aResult);
|
||||
}
|
||||
@ -604,6 +612,10 @@ XMLDocument::Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const
|
||||
JSObject*
|
||||
XMLDocument::WrapNode(JSContext *aCx)
|
||||
{
|
||||
if (mIsPlainDocument) {
|
||||
return DocumentBinding::Wrap(aCx, this);
|
||||
}
|
||||
|
||||
return XMLDocumentBinding::Wrap(aCx, this);
|
||||
}
|
||||
|
||||
|
@ -70,6 +70,9 @@ public:
|
||||
protected:
|
||||
virtual JSObject* WrapNode(JSContext *aCx) MOZ_OVERRIDE;
|
||||
|
||||
friend nsresult (::NS_NewXMLDocument)(nsIDocument**, bool, bool);
|
||||
|
||||
|
||||
// mChannelIsPending indicates whether we're currently asynchronously loading
|
||||
// data from mChannel (via document.load() or normal load). It's set to true
|
||||
// when we first find out about the channel (StartDocumentLoad) and set to
|
||||
@ -79,6 +82,9 @@ protected:
|
||||
bool mChannelIsPending;
|
||||
bool mAsync;
|
||||
bool mLoopingForSyncLoad;
|
||||
|
||||
// If true. we're really a Document, not an XMLDocument
|
||||
bool mIsPlainDocument;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
Loading…
Reference in New Issue
Block a user