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
--- 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
-