mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1165851 part 1. Back out bug 1060938 and bug 1075702 pending spec changes because they are implementing a spec that's not web compatible. r=smaug
This commit is contained in:
parent
98d54ae561
commit
a05ed5f7a8
@ -184,7 +184,7 @@ Attr::GetValue(nsAString& aValue)
|
||||
{
|
||||
Element* element = GetElement();
|
||||
if (element) {
|
||||
nsCOMPtr<nsIAtom> nameAtom = mNodeInfo->NameAtom();
|
||||
nsCOMPtr<nsIAtom> nameAtom = GetNameAtom(element);
|
||||
element->GetAttr(mNodeInfo->NamespaceID(), nameAtom, aValue);
|
||||
}
|
||||
else {
|
||||
@ -203,7 +203,7 @@ Attr::SetValue(const nsAString& aValue, ErrorResult& aRv)
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAtom> nameAtom = mNodeInfo->NameAtom();
|
||||
nsCOMPtr<nsIAtom> nameAtom = GetNameAtom(element);
|
||||
aRv = element->SetAttr(mNodeInfo->NamespaceID(),
|
||||
nameAtom,
|
||||
mNodeInfo->GetPrefixAtom(),
|
||||
|
@ -1235,9 +1235,7 @@ Element::RemoveAttributeNode(Attr& aAttribute,
|
||||
}
|
||||
|
||||
OwnerDoc()->WarnOnceAbout(nsIDocument::eRemoveAttributeNode);
|
||||
nsAutoString nameSpaceURI;
|
||||
aAttribute.NodeInfo()->GetNamespaceURI(nameSpaceURI);
|
||||
return Attributes()->RemoveNamedItemNS(nameSpaceURI, aAttribute.NodeInfo()->LocalName(), aError);
|
||||
return Attributes()->RemoveNamedItem(aAttribute.NodeName(), aError);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -300,51 +300,46 @@ nsDOMAttributeMap::SetNamedItemInternal(Attr& aAttr,
|
||||
}
|
||||
|
||||
// Get nodeinfo and preexisting attribute (if it exists)
|
||||
nsRefPtr<NodeInfo> oldNi;
|
||||
|
||||
if (!aWithNS) {
|
||||
nsAutoString name;
|
||||
aAttr.GetName(name);
|
||||
oldNi = mContent->GetExistingAttrNameFromQName(name);
|
||||
}
|
||||
else {
|
||||
uint32_t i, count = mContent->GetAttrCount();
|
||||
for (i = 0; i < count; ++i) {
|
||||
const nsAttrName* name = mContent->GetAttrNameAt(i);
|
||||
int32_t attrNS = name->NamespaceID();
|
||||
nsIAtom* nameAtom = name->LocalName();
|
||||
|
||||
// we're purposefully ignoring the prefix.
|
||||
if (aAttr.NodeInfo()->Equals(nameAtom, attrNS)) {
|
||||
oldNi = mContent->NodeInfo()->NodeInfoManager()->
|
||||
GetNodeInfo(nameAtom, name->GetPrefix(), aAttr.NodeInfo()->NamespaceID(),
|
||||
nsIDOMNode::ATTRIBUTE_NODE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
nsAutoString name;
|
||||
nsRefPtr<mozilla::dom::NodeInfo> ni;
|
||||
|
||||
nsRefPtr<Attr> attr;
|
||||
// SetNamedItemNS()
|
||||
if (aWithNS) {
|
||||
// Return existing attribute, if present
|
||||
ni = aAttr.NodeInfo();
|
||||
|
||||
if (oldNi) {
|
||||
nsRefPtr<Attr> oldAttr = GetAttribute(oldNi, true);
|
||||
|
||||
if (oldAttr == &aAttr) {
|
||||
return oldAttr.forget();
|
||||
if (mContent->HasAttr(ni->NamespaceID(), ni->NameAtom())) {
|
||||
attr = RemoveAttribute(ni);
|
||||
}
|
||||
} else { // SetNamedItem()
|
||||
aAttr.GetName(name);
|
||||
|
||||
if (oldAttr) {
|
||||
attr = RemoveNamedItem(oldNi, aError);
|
||||
NS_ASSERTION(attr->NodeInfo()->NameAndNamespaceEquals(oldNi),
|
||||
"RemoveNamedItem() called, attr->NodeInfo() should be equal to oldNi!");
|
||||
// get node-info of old attribute
|
||||
ni = mContent->GetExistingAttrNameFromQName(name);
|
||||
if (ni) {
|
||||
attr = RemoveAttribute(ni);
|
||||
}
|
||||
else {
|
||||
if (mContent->IsInHTMLDocument() &&
|
||||
mContent->IsHTMLElement()) {
|
||||
nsContentUtils::ASCIIToLower(name);
|
||||
}
|
||||
|
||||
rv = mContent->NodeInfo()->NodeInfoManager()->
|
||||
GetNodeInfo(name, nullptr, kNameSpaceID_None,
|
||||
nsIDOMNode::ATTRIBUTE_NODE, getter_AddRefs(ni));
|
||||
if (NS_FAILED(rv)) {
|
||||
aError.Throw(rv);
|
||||
return nullptr;
|
||||
}
|
||||
// value is already empty
|
||||
}
|
||||
}
|
||||
|
||||
nsAutoString value;
|
||||
aAttr.GetValue(value);
|
||||
|
||||
nsRefPtr<NodeInfo> ni = aAttr.NodeInfo();
|
||||
|
||||
// Add the new attribute to the attribute map before updating
|
||||
// its value in the element. @see bug 364413.
|
||||
nsAttrKey attrkey(ni->NamespaceID(), ni->NameAtom());
|
||||
@ -361,15 +356,6 @@ nsDOMAttributeMap::SetNamedItemInternal(Attr& aAttr,
|
||||
return attr.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<Attr>
|
||||
nsDOMAttributeMap::RemoveNamedItem(NodeInfo* aNodeInfo, ErrorResult& aError)
|
||||
{
|
||||
nsRefPtr<Attr> attribute = GetAttribute(aNodeInfo, true);
|
||||
// This removes the attribute node from the attribute map.
|
||||
aError = mContent->UnsetAttr(aNodeInfo->NamespaceID(), aNodeInfo->NameAtom(), true);
|
||||
return attribute.forget();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttributeMap::RemoveNamedItem(const nsAString& aName,
|
||||
nsIDOMAttr** aReturn)
|
||||
@ -395,7 +381,11 @@ nsDOMAttributeMap::RemoveNamedItem(const nsAString& aName, ErrorResult& aError)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return RemoveNamedItem(ni, aError);
|
||||
nsRefPtr<Attr> attribute = GetAttribute(ni, true);
|
||||
|
||||
// This removes the attribute node from the attribute map.
|
||||
aError = mContent->UnsetAttr(ni->NamespaceID(), ni->NameAtom(), true);
|
||||
return attribute.forget();
|
||||
}
|
||||
|
||||
|
||||
@ -493,7 +483,6 @@ nsDOMAttributeMap::GetAttrNodeInfo(const nsAString& aNamespaceURI,
|
||||
int32_t attrNS = name->NamespaceID();
|
||||
nsIAtom* nameAtom = name->LocalName();
|
||||
|
||||
// we're purposefully ignoring the prefix.
|
||||
if (nameSpaceID == attrNS &&
|
||||
nameAtom->Equals(aLocalName)) {
|
||||
nsRefPtr<mozilla::dom::NodeInfo> ni;
|
||||
@ -530,7 +519,11 @@ nsDOMAttributeMap::RemoveNamedItemNS(const nsAString& aNamespaceURI,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return RemoveNamedItem(ni, aError);
|
||||
nsRefPtr<Attr> attr = RemoveAttribute(ni);
|
||||
mozilla::dom::NodeInfo* attrNi = attr->NodeInfo();
|
||||
mContent->UnsetAttr(attrNi->NamespaceID(), attrNi->NameAtom(), true);
|
||||
|
||||
return attr.forget();
|
||||
}
|
||||
|
||||
uint32_t
|
||||
|
@ -152,8 +152,6 @@ public:
|
||||
return SetNamedItemInternal(aAttr, false, aError);
|
||||
}
|
||||
already_AddRefed<Attr>
|
||||
RemoveNamedItem(mozilla::dom::NodeInfo* aNodeInfo, ErrorResult& aError);
|
||||
already_AddRefed<Attr>
|
||||
RemoveNamedItem(const nsAString& aName, ErrorResult& aError);
|
||||
|
||||
Attr* Item(uint32_t aIndex);
|
||||
|
@ -260,7 +260,6 @@ skip-if = buildapp == 'mulet'
|
||||
[test_bug999456.html]
|
||||
[test_bug1022229.html]
|
||||
[test_bug1043106.html]
|
||||
[test_bug1060938.html]
|
||||
[test_bug1064481.html]
|
||||
[test_clearTimeoutIntervalNoArg.html]
|
||||
[test_consoleEmptyStack.html]
|
||||
@ -666,7 +665,6 @@ skip-if = buildapp == 'mulet' || buildapp == 'b2g' || toolkit == 'android' || e1
|
||||
[test_bug982153.html]
|
||||
[test_bug1057176.html]
|
||||
[test_bug1070015.html]
|
||||
[test_bug1075702.html]
|
||||
[test_bug1101364.html]
|
||||
skip-if = buildapp == 'mulet' || buildapp == 'b2g' || toolkit == 'android'
|
||||
[test_bug1163743.html]
|
||||
|
@ -1,44 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1060938
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title> Test for Bug 1060938 </title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"> </script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.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=1060938"> Mozilla Bug 1060938 </a>
|
||||
<p id="display"></p>
|
||||
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 1060938 **/
|
||||
// test: Element.removeAttributeNode()
|
||||
|
||||
parent = document.getElementsByTagName("p")[0];
|
||||
parent.setAttributeNS("www.test1.com", "ID", "Test1");
|
||||
parent.setAttributeNS("www.test2.com", "Class", "Test2");
|
||||
parent.setAttribute("id", "www.test3.com");
|
||||
parent.className = "www.test4.com";
|
||||
|
||||
allAttributes = parent.attributes;
|
||||
|
||||
function removeAttr(iter){
|
||||
var removed_attribute = allAttributes[0];
|
||||
is(removed_attribute, parent.removeAttributeNode(removed_attribute),
|
||||
"(" + iter + ")" + " Returned attribute and remove attribute should be same.");
|
||||
}
|
||||
|
||||
removeAttr(1);
|
||||
removeAttr(2);
|
||||
removeAttr(3);
|
||||
removeAttr(4);
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,69 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1075702
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title> Test for Bug 1075702 </title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"> </script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.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=1075702"> Mozilla Bug 1075702 </a>
|
||||
<p id="display"></p>
|
||||
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 1075702 **/
|
||||
// test: Element.removeAttributeNode()
|
||||
|
||||
var a1 = document.createAttribute("aa");
|
||||
a1.nodeValue = "lowercase";
|
||||
|
||||
var a2 = document.createAttribute("AA");
|
||||
a2.nodeValue = "UPPERCASE";
|
||||
|
||||
document.documentElement.setAttributeNode(a1);
|
||||
document.documentElement.setAttributeNode(a2);
|
||||
|
||||
is(document.documentElement.getAttributeNS("", "aa"), null, "Should be NULL!");
|
||||
is(document.documentElement.getAttributeNS("", "AA"), "UPPERCASE", "Should be UPPERCASE!");
|
||||
|
||||
var removedNodeAccordingToEvent;
|
||||
|
||||
function mutationHandler(aEvent) {
|
||||
removedNodeAccordingToEvent = aEvent.relatedNode;
|
||||
}
|
||||
|
||||
var test1 = document.createElement("div");
|
||||
test1.setAttribute("x", "y");
|
||||
removedNodeAccordingToEvent = null;
|
||||
|
||||
function testremoveNamedItemNS() {
|
||||
test1.addEventListener("DOMAttrModified", mutationHandler, true);
|
||||
var removedNodeAccordingToRemoveNamedItemNS = test1.attributes.removeNamedItemNS(null, "x");
|
||||
test1.removeEventListener("DOMAttrModified", mutationHandler, true);
|
||||
is(removedNodeAccordingToEvent, removedNodeAccordingToRemoveNamedItemNS, "Node removed according to event is not same as node removed by removeNamedItemNS.");
|
||||
}
|
||||
|
||||
testremoveNamedItemNS();
|
||||
|
||||
var test2 = document.createElement("div");
|
||||
test2.setAttribute("x", "y");
|
||||
removedNodeAccordingToEvent = null;
|
||||
|
||||
function testremoveNamedItem() {
|
||||
test2.addEventListener("DOMAttrModified", mutationHandler, true);
|
||||
var removedNodeAccordingToRemoveNamedItem = test2.attributes.removeNamedItem("x");
|
||||
test2.removeEventListener("DOMAttrModified", mutationHandler, true);
|
||||
is(removedNodeAccordingToEvent, removedNodeAccordingToRemoveNamedItem, "Node removed according to event is not same as node removed by removeNamedItem.");
|
||||
}
|
||||
|
||||
testremoveNamedItem();
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -27,10 +27,8 @@ function testGetAttribute() {
|
||||
document.body.setAttributeNode(a1);
|
||||
document.body.setAttributeNode(a2);
|
||||
var log = document.getElementById("log");
|
||||
is(document.body.getAttribute('aa'), null, "Attribute has the localName AA and not aa.");
|
||||
is(document.body.getAttribute('AA'), null, "Attribute has the localName AA and not aa.");
|
||||
is(document.body.getAttributeNS("", "aa"), null, "Attribute should have localName AA.");
|
||||
is(document.body.getAttributeNS("", "AA"), "UPPERCASE", "Attribute should have value UPPERCASE!");
|
||||
is(document.body.getAttribute('aa'), "UPPERCASE", "Wrong value (1)");
|
||||
is(document.body.getAttribute('AA'), "UPPERCASE", "Wrong value (2)");
|
||||
|
||||
var s = "";
|
||||
for (var i = 0; i < document.body.attributes.length; ++i) {
|
||||
@ -42,11 +40,13 @@ function testGetAttribute() {
|
||||
is(document.body.getAttributeNode("aa"), document.body.getAttributeNode("AA"),
|
||||
"Wrong node!");
|
||||
|
||||
document.body.getAttributeNodeNS("", "AA").nodeValue = "FOO";
|
||||
is(document.body.getAttributeNS("", "AA"), "FOO", "Wrong value!");
|
||||
document.body.getAttributeNode("AA").nodeValue = "FOO";
|
||||
is(document.body.getAttribute("AA"), "FOO", "Wrong value!");
|
||||
|
||||
document.body.removeAttributeNode(document.body.getAttributeNodeNS("", "AA"));
|
||||
document.body.removeAttributeNode(document.body.getAttributeNode("AA"));
|
||||
ok(!document.body.hasAttribute("AA"), "Should not have attribute!");
|
||||
ok(!document.body.getAttributeNode("AA"), "Should not have attribute node!");
|
||||
ok(!document.body.hasAttribute("aa"), "Should not have attribute!");
|
||||
ok(!document.body.getAttributeNode("aa"), "Should not have attribute node!");
|
||||
|
||||
is(a2.nodeValue, "FOO", "Wrong value!");
|
||||
@ -54,10 +54,10 @@ function testGetAttribute() {
|
||||
is(a2.nodeValue, "UPPERCASE", "Wrong value!");
|
||||
|
||||
document.body.setAttributeNode(a2);
|
||||
is(document.body.getAttributeNS("", "AA"), "UPPERCASE", "Wrong value!");
|
||||
ok(document.body.getAttributeNodeNS("", "AA"), "Should have attribute node!");
|
||||
is(document.body.getAttributeNS("", "aa"), null, "No attribute has the localName aa.");
|
||||
ok(!document.body.getAttributeNodeNS("", "aa"), "Should not have attribute node!");
|
||||
is(document.body.getAttribute("AA"), "UPPERCASE", "wrong value!");
|
||||
ok(document.body.getAttributeNode("AA"), "Should have attribute node!");
|
||||
is(document.body.getAttribute("aa"), "UPPERCASE", "wrong value!");
|
||||
ok(document.body.getAttributeNode("aa"), "Should have attribute node!");
|
||||
}
|
||||
testGetAttribute();
|
||||
|
||||
@ -75,7 +75,7 @@ function testGetAttributeNodeMixedCase() {
|
||||
var a = div.ownerDocument.createAttribute("mixedCaseAttrib");
|
||||
a.nodeValue = "x";
|
||||
div.setAttributeNode(a);
|
||||
return div.getAttributeNS("", "mixedCaseAttrib");
|
||||
return div.getAttribute("mixedCaseAttrib");
|
||||
}
|
||||
is(testGetAttributeNodeMixedCase(), "x", "(2)");
|
||||
|
||||
@ -114,7 +114,7 @@ function testAttribNodeNamePreservesCaseGetNode() {
|
||||
var a = body.ownerDocument.createAttribute("A");
|
||||
a.nodeValue = "x";
|
||||
body.setAttributeNode(a);
|
||||
a = document.body.getAttributeNodeNS("", "A");
|
||||
a = document.body.getAttributeNode("A");
|
||||
if (!a)
|
||||
return "FAIL";
|
||||
var result = [ a.name, a.nodeName ];
|
||||
@ -127,14 +127,14 @@ function testAttribNodeNamePreservesCaseGetNode2() {
|
||||
var a = body.ownerDocument.createAttribute("B");
|
||||
a.nodeValue = "x";
|
||||
body.setAttributeNode(a);
|
||||
a = document.body.getAttributeNodeNS("", "B");
|
||||
a = document.body.getAttributeNode("B");
|
||||
if (!a)
|
||||
return "FAIL";
|
||||
// Now create node second time
|
||||
a = body.ownerDocument.createAttribute("B");
|
||||
a.nodeValue = "x";
|
||||
body.setAttributeNode(a);
|
||||
a = document.body.getAttributeNodeNS("", "B");
|
||||
a = document.body.getAttributeNode("B");
|
||||
var result = [ a.name, a.nodeName ];
|
||||
return result.join(",");
|
||||
}
|
||||
@ -158,9 +158,9 @@ attrib.nodeValue = "XXX";
|
||||
node.setAttributeNode(attrib);
|
||||
// Note, this is different to what WebKit does
|
||||
is((new XMLSerializer).serializeToString(node),
|
||||
"<div xmlns=\"http://www.w3.org/1999/xhtml\" myAttrib=\"XXX\"></div>", "(9)");
|
||||
is(node.getAttributeNodeNS("", "myAttrib").name, "myAttrib", "(10)");
|
||||
is(node.getAttributeNodeNS("", "myattrib"), null, "(11)");
|
||||
"<div xmlns=\"http://www.w3.org/1999/xhtml\" myattrib=\"XXX\"></div>", "(9)");
|
||||
is(node.getAttributeNode('myAttrib').name, "myAttrib", "(10)");
|
||||
is(node.getAttributeNode('myattrib').name, "myAttrib", "(11)");
|
||||
is(attrib.name, "myAttrib", "(12)");
|
||||
|
||||
var o = document.createElement("div");
|
||||
|
Loading…
Reference in New Issue
Block a user