Bug 1499567 - Do not append an empty text node when creating options from HTMLOptionCollection::SetLength. r=bzbarsky
authorEmilio Cobos Álvarez <emilio@crisal.io>
Wed, 17 Oct 2018 00:10:46 +0000
changeset 489948 ce783284cca7bb33684bf6fbf197387afcd2c3b4
parent 489947 a230ab0deaba1e1940b141c74278eb563b48e0cf
child 489949 f7d1fd195963da3c729622e97599debeb425c335
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersbzbarsky
bugs1499567
milestone64.0a1
Bug 1499567 - Do not append an empty text node when creating options from HTMLOptionCollection::SetLength. r=bzbarsky Only we do that. Align with other browsers instead. I removed the max-asserts as well because I cannot make my browser assert when running this test on a debug build. Differential Revision: https://phabricator.services.mozilla.com/D8929
dom/html/HTMLSelectElement.cpp
testing/web-platform/meta/html/semantics/forms/the-select-element/common-HTMLOptionsCollection.html.ini
--- a/dom/html/HTMLSelectElement.cpp
+++ b/dom/html/HTMLSelectElement.cpp
@@ -637,24 +637,16 @@ HTMLSelectElement::SetLength(uint32_t aL
     }
 
     RefPtr<mozilla::dom::NodeInfo> nodeInfo;
 
     nsContentUtils::QNameChanged(mNodeInfo, nsGkAtoms::option,
                                  getter_AddRefs(nodeInfo));
 
     nsCOMPtr<nsINode> node = NS_NewHTMLOptionElement(nodeInfo.forget());
-
-    RefPtr<nsTextNode> text = new nsTextNode(mNodeInfo->NodeInfoManager());
-
-    aRv = node->AppendChildTo(text, false);
-    if (aRv.Failed()) {
-      return;
-    }
-
     for (uint32_t i = curlen; i < aLength; i++) {
       nsINode::AppendChild(*node, aRv);
       if (aRv.Failed()) {
         return;
       }
 
       if (i + 1 < aLength) {
         node = node->CloneNode(true, aRv);
deleted file mode 100644
--- a/testing/web-platform/meta/html/semantics/forms/the-select-element/common-HTMLOptionsCollection.html.ini
+++ /dev/null
@@ -1,5 +0,0 @@
-[common-HTMLOptionsCollection.html]
-  max-asserts: 3
-  [Changing the length adds new nodes; The number of new nodes = new length minus old length]
-    expected: FAIL
-