Bug 1236329. Back out the patch for bug 492933 (revision d8012b35413b) because it's not web-compatible in practice. r=smaug

This commit is contained in:
Boris Zbarsky 2016-01-05 15:05:23 -05:00
parent f1705741f0
commit e7df3e8700
36 changed files with 125 additions and 71 deletions

View File

@ -37,7 +37,6 @@
#include "mozilla/dom/WindowBinding.h"
#include "mozilla/dom/ElementBinding.h"
#include "Units.h"
#include "nsContentListDeclarations.h"
class nsIFrame;
class nsIDOMMozNamedAttrMap;
@ -62,6 +61,11 @@ namespace dom {
} // namespace mozilla
already_AddRefed<nsContentList>
NS_GetContentList(nsINode* aRootNode,
int32_t aMatchNameSpaceId,
const nsAString& aTagname);
#define ELEMENT_FLAG_BIT(n_) NODE_FLAG_BIT(NODE_TYPE_SPECIFIC_BITS_OFFSET + (n_))
// Element-specific flags

View File

@ -845,11 +845,11 @@ nsContentList::Match(Element *aElement)
return false;
NodeInfo *ni = aElement->NodeInfo();
bool wildcard = mMatchNameSpaceId == kNameSpaceID_Wildcard ||
mMatchNameSpaceId == kNameSpaceID_Unknown;
bool unknown = mMatchNameSpaceId == kNameSpaceID_Unknown;
bool wildcard = mMatchNameSpaceId == kNameSpaceID_Wildcard;
bool toReturn = mMatchAll;
if (!wildcard)
if (!unknown && !wildcard)
toReturn &= ni->NamespaceEquals(mMatchNameSpaceId);
if (toReturn)
@ -858,6 +858,11 @@ nsContentList::Match(Element *aElement)
bool matchHTML =
mIsHTMLDocument && aElement->GetNameSpaceID() == kNameSpaceID_XHTML;
if (unknown) {
return matchHTML ? ni->QualifiedNameEquals(mHTMLMatchAtom) :
ni->QualifiedNameEquals(mXMLMatchAtom);
}
if (wildcard) {
return matchHTML ? ni->Equals(mHTMLMatchAtom) :
ni->Equals(mXMLMatchAtom);

View File

@ -218,7 +218,7 @@ public:
* The special value "*" always matches whatever aMatchAtom
* is matched against.
* @param aMatchNameSpaceId If kNameSpaceID_Unknown, then aMatchAtom is the
* localName to match.
* tagName to match.
* If kNameSpaceID_Wildcard, then aMatchAtom is the
* localName to match.
* Otherwise we match nodes whose namespace is
@ -246,8 +246,7 @@ public:
* deeper. If true, then look at the whole subtree rooted at
* our root.
* @param aMatchAtom an atom to be passed back to aFunc
* @param aMatchNameSpaceId a namespace id to be passed back to aFunc. Is
allowed to be kNameSpaceID_Unknown.
* @param aMatchNameSpaceId a namespace id to be passed back to aFunc
* @param aFuncMayDependOnAttr a boolean that indicates whether this list is
* sensitive to attribute changes.
*/

View File

@ -44,9 +44,8 @@ typedef void* (*nsFuncStringContentListDataAllocator)(nsINode* aRootNode,
// If aMatchNameSpaceId is kNameSpaceID_Unknown, this will return a
// content list which matches ASCIIToLower(aTagname) against HTML
// elements in HTML documents and aTagname against everything else.
// The comparison is done to the element's localName. For any
// other value of aMatchNameSpaceId, the list will match aTagname
// against all elements, again comparing to the localName.
// For any other value of aMatchNameSpaceId, the list will match
// aTagname against all elements.
already_AddRefed<nsContentList>
NS_GetContentList(nsINode* aRootNode,
int32_t aMatchNameSpaceId,

View File

@ -32,7 +32,7 @@ function test_getElementsByTagName()
do_check_eq(doc.getElementById("test2").getElementsByTagName("*").length,
8);
do_check_eq(doc.getElementById("test2").getElementsByTagName("test").length,
7);
3);
// Check that the first element of getElementsByTagName on the document is
// the right thing.
@ -40,7 +40,7 @@ function test_getElementsByTagName()
// Check that we get the right things in the right order
var numTests = doc.getElementsByTagName("test").length;
do_check_eq(numTests, 14);
do_check_eq(numTests, 5);
for (var i = 1; i <= numTests; ++i) {
do_check_true(doc.getElementById("test" + i) instanceof nsIDOMElement);
@ -51,15 +51,15 @@ function test_getElementsByTagName()
// Check that we handle tagnames containing ':' correctly
do_check_true(doc.getElementsByTagName("foo:test")
instanceof nsIDOMNodeList);
do_check_eq(doc.getElementsByTagName("foo:test").length, 0);
do_check_eq(doc.getElementsByTagName("foo:test").length, 2);
do_check_true(doc.getElementsByTagName("foo2:test")
instanceof nsIDOMNodeList);
do_check_eq(doc.getElementsByTagName("foo2:test").length, 0);
do_check_eq(doc.getElementsByTagName("foo2:test").length, 3);
do_check_true(doc.getElementsByTagName("bar:test")
instanceof nsIDOMNodeList);
do_check_eq(doc.getElementsByTagName("bar:test").length, 0);
do_check_eq(doc.getElementsByTagName("bar:test").length, 4);
}
function test_getElementsByTagNameNS()

View File

@ -5,7 +5,9 @@ support-files =
[test_Document-createElement-namespace.html.json]
[test_Document-createElementNS.html.json]
[test_Document-getElementsByTagName.html.json]
[test_Node-properties.html.json]
[test_attributes.html.json]
[test_case.html.json]
[test_getElementsByClassName-10.xml.json]
[test_getElementsByClassName-11.xml.json]

View File

@ -0,0 +1,4 @@
{
"Document.getElementsByTagName 1": true,
"Document.getElementsByTagName 2": true
}

View File

@ -1,5 +1,7 @@
{
"getElementsByTagName abc": true,
"getElementsByTagName Abc": true,
"getElementsByTagName ABC": true
"getElementsByTagName ABC": true,
"getElementsByTagName \u00e4": true,
"getElementsByTagName \u00c4": true
}

View File

@ -0,0 +1,3 @@
{
"document.getElementsByClassName(): compound": true
}

View File

@ -100,8 +100,7 @@ function elementsetattributens03() {
docRef = this.doc;
}
doc = load(docRef, "doc", "staffNS");
// Changed for bug 492933.
elementList = doc.getElementsByTagName("employee");
elementList = doc.getElementsByTagName("emp:employee");
element = elementList.item(0);
assertNotNull("empEmployeeNotNull",element);
element.setAttributeNS("http://www.w3.org/DOM/Test/1","defaultAttr","default1");

View File

@ -105,13 +105,11 @@ function getAttributeNS02() {
}
doc = load(docRef, "doc", "staffNS");
newAttribute = doc.createAttributeNS(namespaceURI,qualifiedName);
// Changed for bug 492933.
elementList = doc.getElementsByTagName("address");
elementList = doc.getElementsByTagName("emp:address");
testAddr = elementList.item(0);
assertNotNull("empAddrNotNull",testAddr);
districtAttr = testAddr.setAttributeNodeNS(newAttribute);
// Changed for bug 492933.
elementList = doc.getElementsByTagName("address");
elementList = doc.getElementsByTagName("emp:address");
testAddr = elementList.item(0);
attrValue = testAddr.getAttributeNS(namespaceURI,localName);
assertEquals("throw_Equals","",attrValue);

View File

@ -100,8 +100,7 @@ function getAttributeNS03() {
docRef = this.doc;
}
doc = load(docRef, "doc", "staffNS");
// Changed for bug 492933.
elementList = doc.getElementsByTagName("address");
elementList = doc.getElementsByTagName("emp:address");
testAddr = elementList.item(0);
assertNotNull("empAddrNotNull",testAddr);
testAddr.removeAttributeNS(namespaceURI,localName);

View File

@ -105,8 +105,7 @@ function getAttributeNS04() {
}
doc = load(docRef, "doc", "staffNS");
newAttribute = doc.createAttributeNS(namespaceURI,qualifiedName);
// Changed for bug 492933.
elementList = doc.getElementsByTagName("address");
elementList = doc.getElementsByTagName("emp:address");
testAddr = elementList.item(0);
assertNotNull("empAddrNotNull",testAddr);
testAddr.setAttributeNS(namespaceURI,qualifiedName,"NewValue");

View File

@ -99,9 +99,8 @@ function getAttributeNS05() {
docRef = this.doc;
}
doc = load(docRef, "doc", "staffNS");
// Changed for bug 492933.
elementList = doc.getElementsByTagName("address");
testAddr = elementList.item(3);
elementList = doc.getElementsByTagName("emp:address");
testAddr = elementList.item(0);
assertNotNull("empAddrNotNull",testAddr);
attrValue = testAddr.getAttributeNS("http://www.nist.gov","domestic");
assertEquals("attrValue","Yes",attrValue);

View File

@ -101,8 +101,7 @@ function getAttributeNodeNS01() {
docRef = this.doc;
}
doc = load(docRef, "doc", "staffNS");
// Changed for bug 492933.
elementList = doc.getElementsByTagName("address");
elementList = doc.getElementsByTagName("emp:address");
testAddr = elementList.item(0);
assertNotNull("empAddrNotNull",testAddr);
attribute = testAddr.getAttributeNodeNS(namespaceURI,localName);

View File

@ -100,9 +100,8 @@ function getAttributeNodeNS02() {
docRef = this.doc;
}
doc = load(docRef, "doc", "staffNS");
// Changed for bug 492933.
elementList = doc.getElementsByTagName("address");
testAddr = elementList.item(3);
elementList = doc.getElementsByTagName("emp:address");
testAddr = elementList.item(0);
assertNotNull("empAddrNotNull",testAddr);
attribute = testAddr.getAttributeNodeNS("http://www.nist.gov","domestic");
attrName = attribute.nodeName;

View File

@ -100,8 +100,7 @@ function hasAttributeNS03() {
docRef = this.doc;
}
doc = load(docRef, "doc", "staffNS");
// Changed for bug 492933.
elementList = doc.getElementsByTagName("address");
elementList = doc.getElementsByTagName("emp:address");
testNode = elementList.item(0);
assertNotNull("empAddrNotNull",testNode);
state = testNode.hasAttributeNS(namespaceURI,localName);

View File

@ -102,8 +102,7 @@ function hasAttributeNS04() {
docRef = this.doc;
}
doc = load(docRef, "doc", "staffNS");
// Changed for bug 492933.
elementList = doc.getElementsByTagName("address");
elementList = doc.getElementsByTagName("emp:address");
testNode = elementList.item(0);
assertNotNull("empAddressNotNull",testNode);
state = testNode.hasAttributeNS(namespaceURI,localName);

View File

@ -119,9 +119,8 @@ function importNode05() {
aNewDocRef = this.aNewDoc;
}
aNewDoc = load(aNewDocRef, "aNewDoc", "staffNS");
// Changed for bug 492933.
addresses = aNewDoc.getElementsByTagName("address");
element = addresses.item(3);
addresses = aNewDoc.getElementsByTagName("emp:address");
element = addresses.item(0);
assertNotNull("empAddressNotNull",element);
aNode = doc.importNode(element,false);
hasChild = aNode.hasChildNodes();

View File

@ -117,9 +117,8 @@ function importNode06() {
aNewDocRef = this.aNewDoc;
}
aNewDoc = load(aNewDocRef, "aNewDoc", "staffNS");
// Changed for bug 492933.
addresses = aNewDoc.getElementsByTagName("address");
element = addresses.item(3);
addresses = aNewDoc.getElementsByTagName("emp:address");
element = addresses.item(0);
assertNotNull("empAddressNotNull",element);
aNode = doc.importNode(element,true);
hasChild = aNode.hasChildNodes();

View File

@ -101,9 +101,8 @@ function localName01() {
docRef = this.doc;
}
doc = load(docRef, "doc", "staffNS");
// Changed for bug 492933.
elementList = doc.getElementsByTagName("address");
testAddr = elementList.item(3);
elementList = doc.getElementsByTagName("emp:address");
testAddr = elementList.item(0);
assertNotNull("empAddrNotNull",testAddr);
addrAttr = testAddr.getAttributeNode("emp:domestic");
localName = addrAttr.localName;

View File

@ -99,9 +99,8 @@ function namespaceURI02() {
docRef = this.doc;
}
doc = load(docRef, "doc", "staffNS");
// Changed for bug 492933.
elementList = doc.getElementsByTagName("address");
testAddr = elementList.item(3);
elementList = doc.getElementsByTagName("emp:address");
testAddr = elementList.item(0);
assertNotNull("empAddressNotNull",testAddr);
addrAttr = testAddr.getAttributeNodeNS("http://www.nist.gov","domestic");
attrNamespaceURI = addrAttr.namespaceURI;

View File

@ -94,8 +94,7 @@ function nodehasattributes03() {
docRef = this.doc;
}
doc = load(docRef, "doc", "staffNS");
// Changed for bug 492933.
elementList = doc.getElementsByTagName("employee");
elementList = doc.getElementsByTagName("emp:employee");
element = elementList.item(0);
assertNotNull("empEmployeeNotNull",element);
hasAttributes = element.hasAttributes();

View File

@ -100,8 +100,7 @@ function prefix02() {
docRef = this.doc;
}
doc = load(docRef, "doc", "staffNS");
// Changed for bug 492933.
elementList = doc.getElementsByTagName("employeeId");
elementList = doc.getElementsByTagName("emp:employeeId");
testEmployee = elementList.item(0);
assertNotNull("empEmployeeNotNull",testEmployee);
textNode = testEmployee.firstChild;

View File

@ -97,9 +97,8 @@ function prefix03() {
docRef = this.doc;
}
doc = load(docRef, "doc", "staffNS");
// Changed for bug 492933.
elementList = doc.getElementsByTagName("employee");
testEmployee = elementList.item(3);
elementList = doc.getElementsByTagName("emp:employee");
testEmployee = elementList.item(0);
assertNotNull("empEmployeeNotNull",testEmployee);
prefix = testEmployee.prefix;

View File

@ -100,8 +100,7 @@ function setAttributeNS02() {
docRef = this.doc;
}
doc = load(docRef, "doc", "staffNS");
// Changed for bug 492933.
elementList = doc.getElementsByTagName("employee");
elementList = doc.getElementsByTagName("emp:employee");
testAddr = elementList.item(0);
{

View File

@ -108,8 +108,7 @@ function setAttributeNS04() {
docRef = this.doc;
}
doc = load(docRef, "doc", "staffNS");
// Changed for bug 492933.
elementList = doc.getElementsByTagName("address");
elementList = doc.getElementsByTagName("emp:address");
testAddr = elementList.item(0);
assertNotNull("empAddrNotNull",testAddr);
testAddr.setAttributeNS("http://www.nist.gov","newprefix:zone","newValue");

View File

@ -106,8 +106,7 @@ function setAttributeNS05() {
docRef = this.doc;
}
doc = load(docRef, "doc", "staffNS");
// Changed for bug 492933.
elementList = doc.getElementsByTagName("address");
elementList = doc.getElementsByTagName("emp:address");
testAddr = elementList.item(0);
assertNotNull("empAddrNotNull",testAddr);
testAddr.setAttributeNS(namespaceURI,qualifiedName,"<newValue>");

View File

@ -108,8 +108,7 @@ function setAttributeNS09() {
docRef = this.doc;
}
doc = load(docRef, "doc", "staffNS");
// Changed for bug 492933.
elementList = doc.getElementsByTagName("address");
elementList = doc.getElementsByTagName("emp:address");
testAddr = elementList.item(0);
assertNotNull("empAddrNotNull",testAddr);
testAddr.setAttributeNS(namespaceURI,qualifiedName,"newValue");

View File

@ -111,8 +111,7 @@ function setAttributeNodeNS01() {
docRef = this.doc;
}
doc = load(docRef, "doc", "staffNS");
// Changed for bug 492933.
elementList = doc.getElementsByTagName("address");
elementList = doc.getElementsByTagName("emp:address");
testAddr = elementList.item(0);
assertNotNull("empAddrNotNull",testAddr);
newElement = doc.createElement("newElement");

View File

@ -104,8 +104,7 @@ function setAttributeNodeNS03() {
docRef = this.doc;
}
doc = load(docRef, "doc", "staffNS");
// Changed for bug 492933.
elementList = doc.getElementsByTagName("address");
elementList = doc.getElementsByTagName("emp:address");
testAddr = elementList.item(0);
assertNotNull("empAddrNotNull",testAddr);
newAttr = doc.createAttributeNS(namespaceURI,qualifiedName);

View File

@ -18,7 +18,7 @@
document.head.appendChild(newSheet);
/* Now, append a frame to our children element, causing the pending restyle to descend into it. */
var children = document.getElementsByTagName("children")[0];
var children = document.getElementsByTagName("xbl:children")[0];
var span = document.createElementNS("http://www.w3.org/1999/xhtml", "span");
span.appendChild(document.createTextNode("PASS"));
children.appendChild(span);

View File

@ -0,0 +1,14 @@
[Document-getElementsByTagName-xhtml.xhtml]
type: testharness
[Element in non-HTML namespace, prefix, lowercase name]
expected: FAIL
[Element in non-HTML namespace, prefix, uppercase name]
expected: FAIL
[Element in HTML namespace, prefix, non-ascii characters in name]
expected: FAIL
[Element in non-HTML namespace, prefix, non-ascii characters in name]
expected: FAIL

View File

@ -0,0 +1,14 @@
[Document-getElementsByTagName.html]
type: testharness
[Element in non-HTML namespace, prefix, lowercase name]
expected: FAIL
[Element in non-HTML namespace, prefix, uppercase name]
expected: FAIL
[Element in HTML namespace, prefix, non-ascii characters in name]
expected: FAIL
[Element in non-HTML namespace, prefix, non-ascii characters in name]
expected: FAIL

View File

@ -0,0 +1,14 @@
[Element-getElementsByTagName.html]
type: testharness
[Element in non-HTML namespace, prefix, lowercase name]
expected: FAIL
[Element in non-HTML namespace, prefix, uppercase name]
expected: FAIL
[Element in HTML namespace, prefix, non-ascii characters in name]
expected: FAIL
[Element in non-HTML namespace, prefix, non-ascii characters in name]
expected: FAIL

View File

@ -0,0 +1,17 @@
[case.html]
type: testharness
[getElementsByTagName a:abc]
expected: FAIL
[getElementsByTagName a:Abc]
expected: FAIL
[getElementsByTagName a:ABC]
expected: FAIL
[getElementsByTagName a:ä]
expected: FAIL
[getElementsByTagName a:Ä]
expected: FAIL