Bug 737122 - Attr nodes shouldn't have children; r=sicking

This commit is contained in:
Ms2ger 2012-04-03 09:25:39 +02:00
Родитель 2fe85e5d52
Коммит 3dbf2a8125
19 изменённых файлов: 27 добавлений и 571 удалений

Просмотреть файл

@ -57,7 +57,6 @@ nsIDocument.h \
nsDeprecatedOperationList.h \
nsIDocumentObserver.h \
nsIMutationObserver.h \
nsIMutationObserver2.h \
nsINameSpaceManager.h \
nsINode.h \
nsINodeInfo.h \

Просмотреть файл

@ -1,93 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Mounir Lamouri <mounir.lamouri@mozilla.com> (Original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsIMutationObserver2_h___
#define nsIMutationObserver2_h___
#include "nsIMutationObserver.h"
class nsIContent;
class nsINode;
#define NS_IMUTATION_OBSERVER_2_IID \
{0x61ac1cfd, 0xf3ef, 0x4408, \
{0x8a, 0x72, 0xee, 0xf0, 0x41, 0xbe, 0xc7, 0xe9 } }
/**
* Mutation observer interface 2 is adding AttributeChildRemoved to
* nsIMutationObserver.
*
* @see nsIMutationObserver.
*/
class nsIMutationObserver2 : public nsIMutationObserver
{
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IMUTATION_OBSERVER_2_IID)
/**
* Notification that an attribute's child has been removed.
*
* @param aContainer The attribute that had its child removed.
* @param aChild The child that was removed.
*
* @note Attributes can't have more than one child so it will be always the
* first one being removed.
*/
virtual void AttributeChildRemoved(nsINode* aAttribute,
nsIContent* aChild) = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIMutationObserver2, NS_IMUTATION_OBSERVER_2_IID)
#define NS_DECL_NSIMUTATIONOBSERVER2_ATTRIBUTECHILDREMOVED \
virtual void AttributeChildRemoved(nsINode* aAttribute, \
nsIContent* aChild);
#define NS_DECL_NSIMUTATIONOBSERVER2 \
NS_DECL_NSIMUTATIONOBSERVER \
NS_DECL_NSIMUTATIONOBSERVER2_ATTRIBUTECHILDREMOVED
#define NS_IMPL_NSIMUTATIONOBSERVER2_CONTENT(_class) \
NS_IMPL_NSIMUTATIONOBSERVER_CONTENT(_class) \
void \
_class::AttributeChildRemoved(nsINode* aAttribute, nsIContent *aChild) \
{ \
}
#endif /* nsIMutationObserver2_h___ */

Просмотреть файл

@ -70,7 +70,7 @@ bool nsDOMAttribute::sInitialized;
nsDOMAttribute::nsDOMAttribute(nsDOMAttributeMap *aAttrMap,
already_AddRefed<nsINodeInfo> aNodeInfo,
const nsAString &aValue, bool aNsAware)
: nsIAttribute(aAttrMap, aNodeInfo, aNsAware), mValue(aValue), mChild(nsnull)
: nsIAttribute(aAttrMap, aNodeInfo, aNsAware), mValue(aValue)
{
NS_ABORT_IF_FALSE(mNodeInfo, "We must get a nodeinfo here!");
NS_ABORT_IF_FALSE(mNodeInfo->NodeType() == nsIDOMNode::ATTRIBUTE_NODE,
@ -78,27 +78,6 @@ nsDOMAttribute::nsDOMAttribute(nsDOMAttributeMap *aAttrMap,
// We don't add a reference to our content. It will tell us
// to drop our reference when it goes away.
EnsureChildState();
nsIContent* content = GetContentInternal();
if (content) {
content->AddMutationObserver(this);
}
}
nsDOMAttribute::~nsDOMAttribute()
{
if (mChild) {
static_cast<nsTextNode*>(mChild)->UnbindFromAttribute();
NS_RELEASE(mChild);
mFirstChild = nsnull;
}
nsIContent* content = GetContentInternal();
if (content) {
content->RemoveMutationObserver(this);
}
}
NS_IMPL_CYCLE_COLLECTION_CLASS(nsDOMAttribute)
@ -109,8 +88,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsDOMAttribute)
if (!nsINode::Traverse(tmp, cb)) {
return NS_SUCCESS_INTERRUPTED_TRAVERSE;
}
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_RAWPTR(mChild)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(nsDOMAttribute)
@ -119,11 +96,6 @@ NS_IMPL_CYCLE_COLLECTION_TRACE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsDOMAttribute)
nsINode::Unlink(tmp);
if (tmp->mChild) {
static_cast<nsTextNode*>(tmp->mChild)->UnbindFromAttribute();
NS_RELEASE(tmp->mChild);
tmp->mFirstChild = nsnull;
}
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
DOMCI_NODE_DATA(Attr, nsDOMAttribute)
@ -131,8 +103,8 @@ DOMCI_NODE_DATA(Attr, nsDOMAttribute)
// QueryInterface implementation for nsDOMAttribute
NS_INTERFACE_TABLE_HEAD(nsDOMAttribute)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_NODE_INTERFACE_TABLE5(nsDOMAttribute, nsIDOMAttr, nsIAttribute, nsIDOMNode,
nsIDOMEventTarget, nsIMutationObserver)
NS_NODE_INTERFACE_TABLE4(nsDOMAttribute, nsIDOMAttr, nsIAttribute, nsIDOMNode,
nsIDOMEventTarget)
NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(nsDOMAttribute)
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsISupportsWeakReference,
new nsNodeSupportsWeakRefTearoff(this))
@ -154,18 +126,7 @@ nsDOMAttribute::SetMap(nsDOMAttributeMap *aMap)
GetValue(mValue);
}
nsIContent* content = GetContentInternal();
if (content) {
content->RemoveMutationObserver(this);
}
mAttrMap = aMap;
// If we have a new content, we sholud start listening to it.
content = GetContentInternal();
if (content) {
content->AddMutationObserver(this);
}
}
nsIContent*
@ -241,31 +202,18 @@ nsDOMAttribute::GetValue(nsAString& aValue)
NS_IMETHODIMP
nsDOMAttribute::SetValue(const nsAString& aValue)
{
nsresult rv = NS_OK;
nsIContent* content = GetContentInternal();
if (content) {
nsCOMPtr<nsIAtom> nameAtom = GetNameAtom(content);
rv = content->SetAttr(mNodeInfo->NamespaceID(),
if (!content) {
mValue = aValue;
return NS_OK;
}
nsCOMPtr<nsIAtom> nameAtom = GetNameAtom(content);
return content->SetAttr(mNodeInfo->NamespaceID(),
nameAtom,
mNodeInfo->GetPrefixAtom(),
aValue,
true);
}
else {
mValue = aValue;
if (mChild) {
if (mValue.IsEmpty()) {
doRemoveChild(true);
} else {
mChild->SetText(mValue, false);
}
} else {
EnsureChildState();
}
}
return rv;
}
@ -359,7 +307,7 @@ nsDOMAttribute::HasChildNodes(bool* aHasChildNodes)
{
OwnerDoc()->WarnOnceAbout(nsIDocument::eHasChildNodes);
*aHasChildNodes = mFirstChild != nsnull;
*aHasChildNodes = false;
return NS_OK;
}
@ -382,10 +330,6 @@ nsDOMAttribute::GetFirstChild(nsIDOMNode** aFirstChild)
OwnerDoc()->WarnOnceAbout(nsIDocument::eFirstChild);
if (mFirstChild) {
CallQueryInterface(mFirstChild, aFirstChild);
}
return NS_OK;
}
@ -658,30 +602,26 @@ nsDOMAttribute::IsNodeOfType(PRUint32 aFlags) const
PRUint32
nsDOMAttribute::GetChildCount() const
{
return mFirstChild ? 1 : 0;
return 0;
}
nsIContent *
nsDOMAttribute::GetChildAt(PRUint32 aIndex) const
{
return aIndex == 0 ? mFirstChild : nsnull;
return nsnull;
}
nsIContent * const *
nsDOMAttribute::GetChildArray(PRUint32* aChildCount) const
{
*aChildCount = GetChildCount();
return &mFirstChild;
*aChildCount = 0;
return NULL;
}
PRInt32
nsDOMAttribute::IndexOf(nsINode* aPossibleChild) const
{
if (!aPossibleChild || aPossibleChild != mFirstChild) {
return -1;
}
return 0;
return -1;
}
nsresult
@ -700,15 +640,6 @@ nsDOMAttribute::AppendChildTo(nsIContent* aKid, bool aNotify)
void
nsDOMAttribute::RemoveChildAt(PRUint32 aIndex, bool aNotify)
{
if (aIndex != 0 || !mChild) {
return;
}
doRemoveChild(aNotify);
nsString nullString;
SetDOMStringToNull(nullString);
SetValue(nullString);
}
nsresult
@ -718,54 +649,6 @@ nsDOMAttribute::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
return NS_OK;
}
void
nsDOMAttribute::EnsureChildState()
{
NS_PRECONDITION(!mChild, "Someone screwed up");
nsAutoString value;
GetValue(value);
if (!value.IsEmpty()) {
NS_NewTextNode(&mChild, mNodeInfo->NodeInfoManager());
static_cast<nsTextNode*>(mChild)->BindToAttribute(this);
mFirstChild = mChild;
mChild->SetText(value, false);
}
}
void
nsDOMAttribute::AttributeChanged(nsIDocument* aDocument,
Element* aElement,
PRInt32 aNameSpaceID,
nsIAtom* aAttribute,
PRInt32 aModType)
{
nsIContent* content = GetContentInternal();
if (aElement != content) {
return;
}
if (aNameSpaceID != mNodeInfo->NamespaceID()) {
return;
}
nsCOMPtr<nsIAtom> nameAtom = GetNameAtom(content);
if (nameAtom != aAttribute) {
return;
}
nsCOMPtr<nsIMutationObserver> kungFuDeathGrip(this);
// Just blow away our mChild and recreate it if needed
if (mChild) {
doRemoveChild(true);
}
EnsureChildState();
}
void
nsDOMAttribute::Initialize()
{
@ -777,24 +660,3 @@ nsDOMAttribute::Shutdown()
{
sInitialized = false;
}
void
nsDOMAttribute::doRemoveChild(bool aNotify)
{
NS_ASSERTION(mChild && mFirstChild, "Why are we here?");
NS_ASSERTION(mChild == mFirstChild, "Something got out of sync!");
nsRefPtr<nsTextNode> child = static_cast<nsTextNode*>(mChild);
nsMutationGuard::DidMutate();
mozAutoDocUpdate updateBatch(OwnerDoc(), UPDATE_CONTENT_MODEL, aNotify);
NS_RELEASE(mChild);
mFirstChild = nsnull;
if (aNotify) {
nsNodeUtils::AttributeChildRemoved(this, child);
}
child->UnbindFromAttribute();
}

Просмотреть файл

@ -56,15 +56,14 @@
// Attribute helper class used to wrap up an attribute with a dom
// object that implements nsIDOMAttr and nsIDOMNode
class nsDOMAttribute : public nsIAttribute,
public nsIDOMAttr,
public nsStubMutationObserver
public nsIDOMAttr
{
public:
nsDOMAttribute(nsDOMAttributeMap* aAttrMap,
already_AddRefed<nsINodeInfo> aNodeInfo,
const nsAString& aValue,
bool aNsAware);
virtual ~nsDOMAttribute();
virtual ~nsDOMAttribute() {}
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
@ -100,8 +99,6 @@ public:
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsDOMAttribute,
nsIAttribute)
NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED
virtual nsXPCClassInfo* GetClassInfo();
protected:
virtual mozilla::dom::Element* GetNameSpaceElement()
@ -113,24 +110,12 @@ protected:
private:
already_AddRefed<nsIAtom> GetNameAtom(nsIContent* aContent);
void EnsureChildState();
/**
* Really removing the attribute child (unbind and release).
*/
void doRemoveChild(bool aNotify);
nsString mValue;
// XXX For now, there's only a single child - a text element
// representing the value. This is strong ref, but we use a raw
// pointer so we can implement GetChildArray().
nsIContent* mChild;
mozilla::dom::Element *GetContentInternal() const
{
return mAttrMap ? mAttrMap->GetContent() : nsnull;
}
nsString mValue;
};

Просмотреть файл

@ -207,7 +207,6 @@ DOMCI_DATA(NodeIterator, nsNodeIterator)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsNodeIterator)
NS_INTERFACE_MAP_ENTRY(nsIDOMNodeIterator)
NS_INTERFACE_MAP_ENTRY(nsIMutationObserver)
NS_INTERFACE_MAP_ENTRY(nsIMutationObserver2)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMNodeIterator)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(NodeIterator)
NS_INTERFACE_MAP_END
@ -345,11 +344,3 @@ void nsNodeIterator::ContentRemoved(nsIDocument *aDocument,
mPointer.AdjustAfterRemoval(mRoot, container, aChild, aPreviousSibling);
mWorkingPointer.AdjustAfterRemoval(mRoot, container, aChild, aPreviousSibling);
}
void nsNodeIterator::AttributeChildRemoved(nsINode* aAttribute,
nsIContent* aChild)
{
mPointer.AdjustAfterRemoval(mRoot, aAttribute, aChild, 0);
mWorkingPointer.AdjustAfterRemoval(mRoot, aAttribute, aChild, 0);
}

Просмотреть файл

@ -55,7 +55,7 @@ class nsIDOMNodeFilter;
class nsNodeIterator : public nsIDOMNodeIterator,
public nsTraversal,
public nsStubMutationObserver2
public nsStubMutationObserver
{
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
@ -67,7 +67,6 @@ public:
virtual ~nsNodeIterator();
NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
NS_DECL_NSIMUTATIONOBSERVER2_ATTRIBUTECHILDREMOVED
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsNodeIterator, nsIDOMNodeIterator)

Просмотреть файл

@ -42,11 +42,9 @@
#include "nsIContent.h"
#include "mozilla/dom/Element.h"
#include "nsIMutationObserver.h"
#include "nsIMutationObserver2.h"
#include "nsIDocument.h"
#include "nsIDOMUserDataHandler.h"
#include "nsEventListenerManager.h"
#include "nsIAttribute.h"
#include "nsIXPConnect.h"
#include "nsGenericElement.h"
#include "pldhash.h"
@ -72,8 +70,6 @@ using namespace mozilla::dom;
// This macro expects the ownerDocument of content_ to be in scope as
// |nsIDocument* doc|
// NOTE: AttributeChildRemoved doesn't use this macro but has a very similar use.
// If you change how this macro behave please update AttributeChildRemoved.
#define IMPL_MUTATION_NOTIFICATION(func_, content_, params_) \
PR_BEGIN_MACRO \
bool needsEnterLeave = doc->MayHaveDOMMutationObservers(); \
@ -206,32 +202,6 @@ nsNodeUtils::ContentRemoved(nsINode* aContainer,
aPreviousSibling));
}
void
nsNodeUtils::AttributeChildRemoved(nsINode* aAttribute,
nsIContent* aChild)
{
NS_PRECONDITION(aAttribute->IsNodeOfType(nsINode::eATTRIBUTE),
"container must be a nsIAttribute");
// This is a variant of IMPL_MUTATION_NOTIFICATION.
do {
nsINode::nsSlots* slots = aAttribute->GetExistingSlots();
if (slots && !slots->mMutationObservers.IsEmpty()) {
// This is a variant of NS_OBSERVER_ARRAY_NOTIFY_OBSERVERS.
nsTObserverArray<nsIMutationObserver*>::ForwardIterator iter_ =
slots->mMutationObservers;
nsCOMPtr<nsIMutationObserver2> obs_;
while (iter_.HasMore()) {
obs_ = do_QueryInterface(iter_.GetNext());
if (obs_) {
obs_->AttributeChildRemoved(aAttribute, aChild);
}
}
}
aAttribute = aAttribute->GetNodeParent();
} while (aAttribute);
}
void
nsNodeUtils::LastRelease(nsINode* aNode)
{
@ -610,32 +580,11 @@ nsNodeUtils::CloneAndAdopt(nsINode *aNode, bool aClone, bool aDeep,
// those handlers. However we currently don't have code to do so without
// also notifying when it's not safe so we're not doing that at this time.
// The DOM spec says to always adopt/clone/import the children of attribute
// nodes.
// XXX The following block is here because our implementation of attribute
// nodes is broken when it comes to inserting children. Instead of cloning
// their children we force creation of the only child by calling
// GetChildAt(0). We can remove this when
// https://bugzilla.mozilla.org/show_bug.cgi?id=56758 is fixed.
if (aClone && aNode->IsNodeOfType(nsINode::eATTRIBUTE)) {
nsCOMPtr<nsINode> attrChildNode = aNode->GetChildAt(0);
// We only need to do this if the child node has properties (because we
// might need to call a userdata handler).
if (attrChildNode && attrChildNode->HasProperties()) {
nsCOMPtr<nsINode> clonedAttrChildNode = clone->GetChildAt(0);
if (clonedAttrChildNode) {
bool ok = aNodesWithProperties.AppendObject(attrChildNode) &&
aNodesWithProperties.AppendObject(clonedAttrChildNode);
NS_ENSURE_TRUE(ok, NS_ERROR_OUT_OF_MEMORY);
}
}
}
// XXX End of workaround for broken attribute nodes.
else if (aDeep || aNode->IsNodeOfType(nsINode::eATTRIBUTE)) {
if (aDeep && (!aClone || !aNode->IsNodeOfType(nsINode::eATTRIBUTE))) {
// aNode's children.
for (nsIContent* cloneChild = aNode->GetFirstChild();
cloneChild;
cloneChild = cloneChild->GetNextSibling()) {
cloneChild = cloneChild->GetNextSibling()) {
nsCOMPtr<nsINode> child;
rv = CloneAndAdopt(cloneChild, aClone, true, nodeInfoManager,
aCx, aNewScope, aNodesWithProperties, clone,

Просмотреть файл

@ -129,13 +129,6 @@ public:
nsIContent* aChild,
PRInt32 aIndexInContainer,
nsIContent* aPreviousSibling);
/**
* Send AttributeChildRemoved notifications to nsIMutationObservers.
* @param aAttribute Attribute from which the child has been removed.
* @param aChild Removed child.
* @see nsIMutationObserver2::AttributeChildRemoved.
*/
static void AttributeChildRemoved(nsINode* aAttribute, nsIContent* aChild);
/**
* Send ParentChainChanged notifications to nsIMutationObservers
* @param aContent The piece of content that had its parent changed.

Просмотреть файл

@ -46,6 +46,3 @@
NS_IMPL_NSIMUTATIONOBSERVER_CORE_STUB(nsStubMutationObserver)
NS_IMPL_NSIMUTATIONOBSERVER_CONTENT(nsStubMutationObserver)
NS_IMPL_NSIMUTATIONOBSERVER_CORE_STUB(nsStubMutationObserver2)
NS_IMPL_NSIMUTATIONOBSERVER2_CONTENT(nsStubMutationObserver2)

Просмотреть файл

@ -46,7 +46,6 @@
#define nsStubMutationObserver_h_
#include "nsIMutationObserver.h"
#include "nsIMutationObserver2.h"
/**
* There are two advantages to inheriting from nsStubMutationObserver
@ -63,8 +62,4 @@ class nsStubMutationObserver : public nsIMutationObserver {
NS_DECL_NSIMUTATIONOBSERVER
};
class nsStubMutationObserver2 : public nsIMutationObserver2 {
NS_DECL_NSIMUTATIONOBSERVER2
};
#endif /* !defined(nsStubMutationObserver_h_) */

Просмотреть файл

@ -43,7 +43,6 @@
#include "nsContentUtils.h"
#include "nsIDOMEventListener.h"
#include "nsIDOMMutationEvent.h"
#include "nsIAttribute.h"
#include "nsIDocument.h"
#include "nsThreadUtils.h"
#ifdef DEBUG
@ -184,29 +183,6 @@ nsTextNode::CloneDataNode(nsINodeInfo *aNodeInfo, bool aCloneText) const
return it;
}
void
nsTextNode::BindToAttribute(nsIAttribute* aAttr)
{
NS_ASSERTION(!IsInDoc(), "Unbind before binding!");
NS_ASSERTION(!GetNodeParent(), "Unbind before binding!");
NS_ASSERTION(HasSameOwnerDoc(aAttr), "Wrong owner document!");
mParent = aAttr;
SetParentIsContent(false);
ClearInDocument();
SetSubtreeRootPointer(aAttr->SubtreeRoot());
}
void
nsTextNode::UnbindFromAttribute()
{
NS_ASSERTION(GetNodeParent(), "Bind before unbinding!");
NS_ASSERTION(GetNodeParent()->IsNodeOfType(nsINode::eATTRIBUTE),
"Use this method only to unbind from an attribute!");
mParent = nsnull;
SetSubtreeRootPointer(this);
}
nsresult
nsTextNode::AppendTextForNormalize(const PRUnichar* aBuffer, PRUint32 aLength,
bool aNotify, nsIContent* aNextSibling)

Просмотреть файл

@ -42,10 +42,6 @@
#include "nsGenericDOMDataNode.h"
#include "nsIDOMText.h"
#include "nsIAttribute.h"
#include "nsIDocument.h"
#include "nsThreadUtils.h"
/**
* Class used to implement DOM text nodes
*/
@ -74,9 +70,6 @@ public:
virtual nsGenericDOMDataNode* CloneDataNode(nsINodeInfo *aNodeInfo,
bool aCloneText) const;
void BindToAttribute(nsIAttribute* aAttr);
void UnbindFromAttribute();
virtual nsXPCClassInfo* GetClassInfo();
nsresult AppendTextForNormalize(const PRUnichar* aBuffer, PRUint32 aLength,

Просмотреть файл

@ -441,11 +441,7 @@ _TEST_FILES2 = \
test_bug597345.html \
script-1_bug597345.sjs \
script-2_bug597345.js \
test_bug598877.html \
test_bug599588.html \
test_bug600466.html \
test_bug600468.html \
test_bug600471.html \
test_bug601803.html \
file_bug601803a.html \
file_bug601803b.html \
@ -463,7 +459,6 @@ _TEST_FILES2 = \
test_bug606729.html \
test_treewalker_nextsibling.xml \
test_bug614058.html \
test_bug590771.html \
test_bug622117.html \
test_base.xhtml \
file_base_xbl.xml \

Просмотреть файл

@ -1,73 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=590771
-->
<head>
<title>Test for Bug 590771</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=590771">Mozilla Bug 590771</a>
<p id="display"></p>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 590771 **/
function test1()
{
var attr = document.createAttribute("foo");
attr.value = "bar";
var ni = document.createNodeIterator(attr, -1, null, false);
ni.nextNode();
ni.nextNode();
is(ni.referenceNode, attr.firstChild,
"iterator should be on the first child attribute");
attr.removeChild(attr.firstChild);
is(ni.referenceNode, attr,
"iterator should be on the attribute now");
}
function test2()
{
var attr = document.createAttribute("foo");
attr.value = "bar";
var ni = document.createNodeIterator(attr, -1, null, false);
ni.nextNode();
ni.nextNode();
is(ni.referenceNode, attr.firstChild,
"iterator should be on the first child attribute");
attr.value = "";
is(ni.referenceNode, attr,
"iterator should be on the attribute now");
}
function test3()
{
var attr = document.createAttribute("foo");
attr.value = "bar";
var node = document.createElement("div");
node.setAttributeNode(attr);
var ni = document.createNodeIterator(attr, -1, null, false);
ni.nextNode();
ni.nextNode();
is(ni.referenceNode, attr.firstChild,
"iterator should be on the first child attribute");
node.setAttribute("foo", "");
is(ni.referenceNode, attr,
"iterator should be on the attribute now");
}
test1();
test2();
test3();
</script>
</pre>
</body>
</html>

Просмотреть файл

@ -1,27 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=598877
-->
<head>
<title>Test for Bug 598877</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=598877">Mozilla Bug 598877</a>
<p id="display"></p>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 598877 **/
var attr = document.createAttribute("foo");
attr.value = "bar";
ok(attr.firstChild, "attr.firstChild should be a text node");
is(attr.firstChild.nodeValue, "bar", "the text node value should be 'bar'");
</script>
</pre>
</body>
</html>

Просмотреть файл

@ -1,29 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=600466
-->
<head>
<title>Test for Bug 600466</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=600466">Mozilla Bug 600466</a>
<p id="display"></p>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 600466 **/
var attr = document.createAttribute("foo");
attr.value = "bar";
ok(attr.firstChild, "attr should have a first child");
attr.removeChild(attr.firstChild);
ok(!attr.firstChild, "attr should not have a first child anymore");
</script>
</pre>
</body>
</html>

Просмотреть файл

@ -1,29 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=600468
-->
<head>
<title>Test for Bug 600468</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=600468">Mozilla Bug 600468</a>
<p id="display"></p>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 600468 **/
var attr = document.createAttribute("foo");
attr.value = "bar";
ok(attr.firstChild, "attr should have a first child");
attr.value = "";
ok(!attr.firstChild, "attr should not have a first child");
</script>
</pre>
</body>
</html>

Просмотреть файл

@ -1,30 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=600471
-->
<head>
<title>Test for Bug 600471</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=600471">Mozilla Bug 600471</a>
<p id="display"></p>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 600471 **/
var attr = document.createAttribute("foo");
attr.value = "bar";
var node = document.createElement("div");
node.setAttributeNode(attr);
node.setAttribute("foo", "newvalue");
is(attr.firstChild.nodeValue, "newvalue", "the value should be updated");
</script>
</pre>
</body>
</html>

Просмотреть файл

@ -79,7 +79,10 @@ var attributeModTests = ["hc_attrappendchild1", "hc_attrappendchild3", "hc_attra
"hc_attrinsertbefore2", "hc_attrinsertbefore3", "hc_attrinsertbefore4", "hc_attrinsertbefore6",
"hc_attrnormalize", "hc_attrreplacechild1", "hc_attrreplacechild2",
"hc_attrsetvalue2", "hc_elementnormalize2", "hc_elementnotfounderr", "hc_elementremoveattribute", "hc_elementnormalize2",
"hc_elementnotfounderr", "hc_elementremoveattribute", ];
"hc_elementnotfounderr", "hc_elementremoveattribute",
"hc_attrchildnodes1", "hc_attrfirstchild",
"hc_attrhaschildnodes", "hc_attrlastchild",
"hc_attrremovechild1", "hc_attrsetvalue1"];
var modTests = ["hc_elementwrongdocumenterr", "hc_namednodemapwrongdocumenterr", "hc_nodeappendchildnewchilddiffdocument", "hc_nodeinsertbeforenewchilddiffdocument",
"hc_nodereplacechildnewchilddiffdocument", "hc_elementwrongdocumenterr", "hc_namednodemapwrongdocumenterr", "hc_nodeappendchildnewchilddiffdocument",
"hc_nodeinsertbeforenewchilddiffdocument", "hc_nodereplacechildnewchilddiffdocument", "elementwrongdocumenterr", "namednodemapwrongdocumenterr",