Bug 1253591. HTMLAllCollection should be rooted at the document, not the root element, so it can find the root element. r=peterv
authorBoris Zbarsky <bzbarsky@mit.edu>
Tue, 08 Mar 2016 17:21:40 -0500
changeset 287360 b8d25e9ce8d4c15f4507b159187d54ab8defc6a2
parent 287359 078fdc1a2e270bb42e9b28f40f24efe4fbe75fa3
child 287361 3ec41d5331ac09f7ceb6815e5c831d6289abe9b3
push id73154
push userbzbarsky@mozilla.com
push dateWed, 09 Mar 2016 00:25:53 +0000
treeherdermozilla-inbound@f31818f56cd2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspeterv
bugs1253591
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1253591. HTMLAllCollection should be rooted at the document, not the root element, so it can find the root element. r=peterv
dom/html/HTMLAllCollection.cpp
testing/web-platform/meta/html/infrastructure/common-dom-interfaces/collections/htmlallcollection.html.ini
testing/web-platform/tests/html/infrastructure/common-dom-interfaces/collections/htmlallcollection.html
--- a/dom/html/HTMLAllCollection.cpp
+++ b/dom/html/HTMLAllCollection.cpp
@@ -109,24 +109,19 @@ DocAllResultMatch(nsIContent* aContent, 
 
 nsContentList*
 HTMLAllCollection::GetDocumentAllList(const nsAString& aID)
 {
   if (nsContentList* docAllList = mNamedMap.GetWeak(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;
 }
 
 void
 HTMLAllCollection::NamedGetter(const nsAString& aID,
                                bool& aFound,
                                Nullable<OwningNodeOrHTMLCollection>& aResult)
deleted file mode 100644
--- a/testing/web-platform/meta/html/infrastructure/common-dom-interfaces/collections/htmlallcollection.html.ini
+++ /dev/null
@@ -1,5 +0,0 @@
-[htmlallcollection.html]
-  type: testharness
-  [Test for multiple occurence 3 <script> found]
-    expected: FAIL
-
--- a/testing/web-platform/tests/html/infrastructure/common-dom-interfaces/collections/htmlallcollection.html
+++ b/testing/web-platform/tests/html/infrastructure/common-dom-interfaces/collections/htmlallcollection.html
@@ -1,35 +1,47 @@
 <!DOCTYPE HTML>
-<html>
+<html id="root">
 <head>
 <title>HTMLAllCollection Tests</title>
 <link rel="author" title="Dan Druta" href="mailto:dan.druta@att.com"/>
 <link rel="help" href="2.7.2.1 - Common Infrastructure/Common DOM Interfaces/Collections/HTMLAllCollection"/>
 <meta name="flags" content="TOKENS" />
 <meta name="assert" content="TEST ASSERTION"/>
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 </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 ()");
 
 test(function(){ assert_equals(document.all[0].tagName,"HTML")}, "Test lookup by index using []");
 
 test(function(){ assert_equals(document.all.item("picture").nodeName,"IMG")}, "Test lookup IMG by name");
 
 test(function(){ assert_equals(document.all.namedItem("picture").nodeName,"IMG")}, "Test lookup IMG by namedItem ");
 
 test(function(){ assert_equals(document.all("picture").nodeName,"IMG")}, "Test lookup IMG in collection using ()");
 
 test(function(){ assert_equals(document.all["picture"].nodeName,"IMG")}, "Test lookup IMG in collection using []");
 
 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>
 </html>