Bug 1389922 - Return new object each time from document.all; r?smaug draft
authorAryeh Gregor <ayg@aryeh.name>
Sun, 13 Aug 2017 16:19:32 +0300
changeset 646567 16a658986ad3d01cb27dae3b63446bd1f8291595
parent 646566 f3a6d9769c233a0e126e7b31c0733089049acbe3
child 726280 fa103a384219f5e4cd5e25eb7bf7edffc153c55d
push id74161
push userbmo:ayg@aryeh.name
push dateTue, 15 Aug 2017 12:07:31 +0000
reviewerssmaug
bugs1389922
milestone57.0a1
Bug 1389922 - Return new object each time from document.all; r?smaug In accordance with the spec, Chrome, WebKit, and Edge. We now pass all relevant wpt tests, after https://github.com/w3c/web-platform-tests/pull/6820 is merged upstream. MozReview-Commit-ID: LoPtBsAXkWn
dom/html/HTMLAllCollection.cpp
testing/web-platform/meta/html/infrastructure/common-dom-interfaces/collections/htmlallcollection.html.ini
--- a/dom/html/HTMLAllCollection.cpp
+++ b/dom/html/HTMLAllCollection.cpp
@@ -186,17 +186,21 @@ HTMLAllCollection::NamedGetter(const nsA
     return;
   }
 
   // Check if there are more than 1 entries. Do this by getting the second one
   // rather than the length since getting the length always requires walking
   // the entire document.
   if (docAllList->Item(1, true)) {
     aFound = true;
-    aResult.SetValue().SetAsHTMLCollection() = docAllList;
+    // We need to return a different value for each call per spec
+    nsCOMPtr<nsIAtom> id = NS_Atomize(aID);
+    aResult.SetValue().SetAsHTMLCollection() =
+      new nsContentList(mDocument, DocAllResultMatch, nullptr, nullptr, true,
+                        id);
     return;
   }
 
   // There's only 0 or 1 items. Return the first one or null.
   if (nsIContent* node = docAllList->Item(0, true)) {
     aFound = true;
     aResult.SetValue().SetAsElement() = node->AsElement();
     return;
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
-  [collections are new live HTMLCollection instances]
-    expected: FAIL
-