Bug 698061 - document.importNode's deep attribute should be optional, r=sicking

This commit is contained in:
Olli Pettay 2011-10-30 23:17:53 +02:00
parent d05f3af50f
commit 79969bc6f0
7 changed files with 51 additions and 6 deletions

View File

@ -4776,9 +4776,13 @@ nsDocument::GetCharacterSet(nsAString& aCharacterSet)
NS_IMETHODIMP
nsDocument::ImportNode(nsIDOMNode* aImportedNode,
bool aDeep,
PRUint8 aArgc,
nsIDOMNode** aResult)
{
NS_ENSURE_ARG(aImportedNode);
if (aArgc == 0) {
aDeep = true;
}
*aResult = nsnull;

View File

@ -66,7 +66,7 @@ interface nsIDOMLocation;
* http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html
*/
[scriptable, uuid(256a15f4-126f-48f9-90b6-7f5b2b1e30e6)]
[scriptable, uuid(5c3bff4d-ae7f-4c93-948c-519589672c30)]
interface nsIDOMDocument : nsIDOMNode
{
readonly attribute nsIDOMDocumentType doctype;
@ -87,8 +87,8 @@ interface nsIDOMDocument : nsIDOMNode
nsIDOMNodeList getElementsByTagName(in DOMString tagname);
// Introduced in DOM Level 2:
nsIDOMNode importNode(in nsIDOMNode importedNode,
in boolean deep)
[optional_argc] nsIDOMNode importNode(in nsIDOMNode importedNode,
[optional] in boolean deep)
raises(DOMException);
// Introduced in DOM Level 2:
nsIDOMElement createElementNS(in DOMString namespaceURI,

View File

@ -38,7 +38,7 @@
#include "nsIDOMDocument.idl"
[scriptable, uuid(f349fb58-544d-4254-b1b9-902e459d7b5c)]
[scriptable, uuid(b53a4bab-0065-468b-810a-4c4659a04f00)]
interface nsIDOMXMLDocument : nsIDOMDocument
{
// DOM Level 3 Load & Save, DocumentLS

View File

@ -47,7 +47,7 @@
*/
interface nsISelection;
[scriptable, uuid(3d94491d-fd74-4710-bfa8-83724b674177)]
[scriptable, uuid(cc1af020-6543-429c-82d7-840cda3be0b9)]
interface nsIDOMHTMLDocument : nsIDOMDocument
{
readonly attribute DOMString URL;

View File

@ -39,7 +39,7 @@
interface nsIDOMSVGSVGElement;
[scriptable, uuid(872c2e8f-80cb-4405-981d-ba3474e7925e)]
[scriptable, uuid(4368b131-bfe9-4f34-848d-00139217c1d1)]
interface nsIDOMSVGDocument : nsIDOMDocument
{
readonly attribute DOMString domain;

View File

@ -150,6 +150,7 @@ _TEST_FILES = \
test_devicemotion_multiple_listeners.html \
devicemotion_outer.html \
devicemotion_inner.html \
test_bug698061.html \
$(NULL)
libs:: $(_TEST_FILES)

View File

@ -0,0 +1,40 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=698061
-->
<head>
<title>Test for Bug 698061</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=698061">Mozilla Bug 698061</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 698061 **/
var d = document.createElement("div");
d.innerHTML = "<span>hello </span><span>world</span>";
var imported = document.importNode(d);
is(imported.childNodes.length, 2, "Should have cloned child nodes!");
is(imported.textContent, "hello world", "Should have cloned text!");
imported = document.importNode(d, true);
is(imported.childNodes.length, 2, "Should have cloned child nodes!");
is(imported.textContent, "hello world", "Should have cloned text!");
imported = document.importNode(d, false);
is(imported.childNodes.length, 0, "Shouldn't have cloned child nodes!");
is(imported.textContent, "", "Shouldn't have cloned text!");
</script>
</pre>
</body>
</html>