Bug 869002 - DocumentFragment should be constructable, r=Ms2ger

This commit is contained in:
Andrea Marchesini 2013-05-23 03:59:00 -07:00
parent c292bec6ec
commit 30f3e235ca
5 changed files with 49 additions and 0 deletions

View File

@ -107,6 +107,18 @@ DocumentFragment::DumpContent(FILE* out, int32_t aIndent,
}
#endif
/* static */ already_AddRefed<DocumentFragment>
DocumentFragment::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv)
{
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.Get());
if (!window || !window->GetDoc()) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
return window->GetDoc()->CreateDocumentFragment();
}
// QueryInterface implementation for DocumentFragment
NS_INTERFACE_MAP_BEGIN(DocumentFragment)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY

View File

@ -141,6 +141,9 @@ public:
mHost = aHost;
}
static already_AddRefed<DocumentFragment>
Constructor(const GlobalObject& aGlobal, ErrorResult& aRv);
#ifdef DEBUG
virtual void List(FILE* out, int32_t aIndent) const;
virtual void DumpContent(FILE* out, int32_t aIndent, bool aDumpAll) const;

View File

@ -628,6 +628,7 @@ MOCHITEST_FILES_C= \
test_bug869006.html \
test_bug868999.html \
test_bug869000.html \
test_bug869002.html \
$(NULL)
# OOP tests don't work on Windows (bug 763081) or native-fennec

View File

@ -0,0 +1,32 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=868999
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 868999</title>
<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=868999">Mozilla Bug 869002</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 868999 **/
var d = new DocumentFragment();
ok(d, "DocumentFragment has been created");
document.appendChild(d);
ok(true, "DocumentFragment has been added to the document");
</script>
</pre>
</body>
</html>

View File

@ -11,6 +11,7 @@
* liability, trademark and document use rules apply.
*/
[Constructor]
interface DocumentFragment : Node {
// NEW
/*