Bug 1253591. HTMLAllCollection should be rooted at the document, not the root element, so it can find the root element. r=peterv

This commit is contained in:
Boris Zbarsky 2016-03-08 17:21:40 -05:00
Родитель 3c61c287f2
Коммит d29c2409f0
3 изменённых файлов: 15 добавлений и 13 удалений

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

@ -114,14 +114,9 @@ HTMLAllCollection::GetDocumentAllList(const nsAString& aID)
return docAllList;
}
Element* root = mDocument->GetRootElement();
if (!root) {
return nullptr;
}
nsCOMPtr<nsIAtom> id = do_GetAtom(aID);
RefPtr<nsContentList> docAllList =
new nsContentList(root, DocAllResultMatch, nullptr, nullptr, true, id);
new nsContentList(mDocument, DocAllResultMatch, nullptr, nullptr, true, id);
mNamedMap.Put(aID, docAllList);
return docAllList;
}

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

@ -1,5 +0,0 @@
[htmlallcollection.html]
type: testharness
[Test for multiple occurence 3 <script> found]
expected: FAIL

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

@ -1,5 +1,5 @@
<!DOCTYPE HTML>
<html>
<html id="root">
<head>
<title>HTMLAllCollection Tests</title>
<link rel="author" title="Dan Druta" href="mailto:dan.druta@att.com"/>
@ -11,8 +11,10 @@
</head>
<body id="tags">
<img src="../../../../images/green.png" name="picture">
<a name="foo"></a>
<a name="foo"></a>
<script>
test(function(){ assert_equals(document.all.length,12)}, "Test for HTMLAllCollection size");
test(function(){ assert_equals(document.all.length,14)}, "Test for HTMLAllCollection size");
test(function(){ assert_equals(document.all.item(0).tagName,"HTML")}, "Test lookup by index using ()");
@ -29,6 +31,16 @@ test(function(){ assert_equals(document.all["picture"].nodeName,"IMG")}, "Test l
test(function(){ assert_equals(document.all.picture.nodeName,"IMG")}, "Test lookup IMG in collection using .");
test(function(){ assert_equals(document.all.tags.id,"tags")}, "Test lookup tags in collection using .");
test(function() {
assert_equals(document.all["root"], document.documentElement);
}, "Should find root element too");
test(function() {
assert_equals(document.all["foo"].length, 2);
}, "Should find both anchors and produce a list");
test
</script>
<div id="log"></div>
</body>