mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Bug 891952. Named getters for HTMLCollection should never return anything for "". r=smaug
This commit is contained in:
parent
9f3053ec67
commit
a06b36141b
@ -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<nsString>& 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<nsString>& 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);
|
||||
}
|
||||
|
@ -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]
|
||||
|
61
content/base/test/test_bug891952.html
Normal file
61
content/base/test/test_bug891952.html
Normal file
@ -0,0 +1,61 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=891952
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 891952</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 891952 **/
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addLoadEvent(function() {
|
||||
var all = document.all;
|
||||
is(all["content"], $("content"), "Should find the content");
|
||||
ok(!("" in all), "Should not have an empty string prop on document.all");
|
||||
ise(all[""], undefined, "Should not get empty string on document.all");
|
||||
ise(all.namedItem(""), null,
|
||||
"namedItem for empty string should return null on document.all");
|
||||
|
||||
var divs = document.getElementsByTagName("div");
|
||||
ok(!("" in divs), "Should not have an empty string prop on getElementsByTagName");
|
||||
ise(divs[""], undefined, "Should not get empty string on getElementsByTagName");
|
||||
ise(divs.namedItem(""), null,
|
||||
"namedItem for empty string should return null on getElementsByTagName");
|
||||
var forms = document.forms;
|
||||
ok(!("" in forms), "Should not have an empty string prop on document.forms");
|
||||
ise(forms[""], undefined, "Should not get empty string on document.forms");
|
||||
ise(forms.namedItem(""), null,
|
||||
"namedItem for empty string should return null on document.forms");
|
||||
|
||||
var form = $("form");
|
||||
ok(!("" in form), "Should not have an empty string prop on form");
|
||||
ise(form[""], undefined, "Should not get empty string on form");
|
||||
|
||||
var formEls = $("form").elements;
|
||||
ok(!("" in formEls), "Should not have an empty string prop on form.elements");
|
||||
ise(formEls[""], undefined, "Should not get empty string on form.elements");
|
||||
ise(formEls.namedItem(""), null,
|
||||
"namedItem for empty string should return null on form.elements");
|
||||
SimpleTest.finish();
|
||||
});
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=891952">Mozilla Bug 891952</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
<div id=""></div>
|
||||
<div name=""></div>
|
||||
<form id="form" name="">
|
||||
<input name="">
|
||||
</form>
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
@ -126,6 +126,12 @@ HTMLAllCollection::NamedGetter(const nsAString& aID,
|
||||
bool& aFound,
|
||||
Nullable<OwningNodeOrHTMLCollection>& aResult)
|
||||
{
|
||||
if (aID.IsEmpty()) {
|
||||
aFound = false;
|
||||
aResult.SetNull();
|
||||
return;
|
||||
}
|
||||
|
||||
nsContentList* docAllList = GetDocumentAllList(aID);
|
||||
if (!docAllList) {
|
||||
aFound = false;
|
||||
|
@ -1,6 +0,0 @@
|
||||
# THIS FILE IS AUTOGENERATED BY parseFailures.py - DO NOT EDIT
|
||||
[DEFAULT]
|
||||
support-files =
|
||||
|
||||
|
||||
[test_HTMLCollection-empty-name.html.json]
|
@ -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
|
||||
}
|
@ -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]
|
||||
|
@ -1,3 +0,0 @@
|
||||
{
|
||||
"The empty string should not be in the collections": true
|
||||
}
|
@ -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',
|
||||
|
Loading…
Reference in New Issue
Block a user