diff --git a/content/base/src/nsContentList.cpp b/content/base/src/nsContentList.cpp index 439eec4ffb21..346ca9c9872e 100644 --- a/content/base/src/nsContentList.cpp +++ b/content/base/src/nsContentList.cpp @@ -530,6 +530,10 @@ nsContentList::Item(uint32_t aIndex, bool aDoFlush) Element* nsContentList::NamedItem(const nsAString& aName, bool aDoFlush) { + if (aName.IsEmpty()) { + return nullptr; + } + BringSelfUpToDate(aDoFlush); uint32_t i, count = mElements.Length(); @@ -574,6 +578,8 @@ nsContentList::GetSupportedNames(unsigned aFlags, nsTArray& aNames) const nsAttrValue* val = el->GetParsedAttr(nsGkAtoms::name); if (val && val->Type() == nsAttrValue::eAtom) { nsIAtom* name = val->GetAtomValue(); + MOZ_ASSERT(name != nsGkAtoms::_empty, + "Empty names don't get atomized"); if (!atoms.Contains(name)) { atoms.AppendElement(name); } @@ -581,6 +587,8 @@ nsContentList::GetSupportedNames(unsigned aFlags, nsTArray& aNames) } if (content->HasID()) { nsIAtom* id = content->GetID(); + MOZ_ASSERT(id != nsGkAtoms::_empty, + "Empty ids don't get atomized"); if (!atoms.Contains(id)) { atoms.AppendElement(id); } diff --git a/content/base/test/mochitest.ini b/content/base/test/mochitest.ini index 6a687f687e3c..9f1d738ecfa9 100644 --- a/content/base/test/mochitest.ini +++ b/content/base/test/mochitest.ini @@ -545,6 +545,7 @@ skip-if = buildapp == 'b2g' || toolkit == 'android' || e10s #needs plugin suppor [test_bug869006.html] [test_bug876282.html] [test_bug890580.html] +[test_bug891952.html] [test_bug894874.html] [test_bug895239.html] [test_bug895974.html] diff --git a/content/base/test/test_bug891952.html b/content/base/test/test_bug891952.html new file mode 100644 index 000000000000..68cdf5d64411 --- /dev/null +++ b/content/base/test/test_bug891952.html @@ -0,0 +1,61 @@ + + + + + + Test for Bug 891952 + + + + + +Mozilla Bug 891952 +

+ +
+
+ + diff --git a/content/html/document/src/HTMLAllCollection.cpp b/content/html/document/src/HTMLAllCollection.cpp index 38f7b9a007d1..ed75ace08479 100644 --- a/content/html/document/src/HTMLAllCollection.cpp +++ b/content/html/document/src/HTMLAllCollection.cpp @@ -126,6 +126,12 @@ HTMLAllCollection::NamedGetter(const nsAString& aID, bool& aFound, Nullable& aResult) { + if (aID.IsEmpty()) { + aFound = false; + aResult.SetNull(); + return; + } + nsContentList* docAllList = GetDocumentAllList(aID); if (!docAllList) { aFound = false; diff --git a/dom/imptests/failures/html/dom/collections/mochitest.ini b/dom/imptests/failures/html/dom/collections/mochitest.ini deleted file mode 100644 index 314128bb6bd6..000000000000 --- a/dom/imptests/failures/html/dom/collections/mochitest.ini +++ /dev/null @@ -1,6 +0,0 @@ -# THIS FILE IS AUTOGENERATED BY parseFailures.py - DO NOT EDIT -[DEFAULT] -support-files = - - -[test_HTMLCollection-empty-name.html.json] diff --git a/dom/imptests/failures/html/dom/collections/test_HTMLCollection-empty-name.html.json b/dom/imptests/failures/html/dom/collections/test_HTMLCollection-empty-name.html.json deleted file mode 100644 index 8529f2f1f3d7..000000000000 --- a/dom/imptests/failures/html/dom/collections/test_HTMLCollection-empty-name.html.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "Empty string as a name for Document.getElementsByTagName": true, - "Empty string as a name for Element.getElementsByTagName": true, - "Empty string as a name for Document.getElementsByTagNameNS": true, - "Empty string as a name for Element.getElementsByTagNameNS": true, - "Empty string as a name for Document.getElementsByClassName": true, - "Empty string as a name for Element.getElementsByClassName": true, - "Empty string as a name for Element.children": true -} diff --git a/dom/imptests/failures/html/html/dom/documents/dta/mochitest.ini b/dom/imptests/failures/html/html/dom/documents/dta/mochitest.ini index 59cb0fb535c0..0028d20e0661 100644 --- a/dom/imptests/failures/html/html/dom/documents/dta/mochitest.ini +++ b/dom/imptests/failures/html/html/dom/documents/dta/mochitest.ini @@ -3,7 +3,6 @@ support-files = -[test_document.images.html.json] [test_document.title-03.html.json] [test_document.title-04.xhtml.json] [test_document.title-06.html.json] diff --git a/dom/imptests/failures/html/html/dom/documents/dta/test_document.images.html.json b/dom/imptests/failures/html/html/dom/documents/dta/test_document.images.html.json deleted file mode 100644 index 28f23927ed7a..000000000000 --- a/dom/imptests/failures/html/html/dom/documents/dta/test_document.images.html.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "The empty string should not be in the collections": true -} diff --git a/dom/imptests/moz.build b/dom/imptests/moz.build index 0182e15da0a8..8290c4789aa9 100644 --- a/dom/imptests/moz.build +++ b/dom/imptests/moz.build @@ -14,7 +14,6 @@ MOCHITEST_MANIFESTS += [ MOCHITEST_MANIFESTS += [ 'failures/editing/conformancetest/mochitest.ini', 'failures/editing/selecttest/mochitest.ini', - 'failures/html/dom/collections/mochitest.ini', 'failures/html/dom/errors/mochitest.ini', 'failures/html/dom/lists/mochitest.ini', 'failures/html/dom/mochitest.ini',