Bug 1584211 - Avoid false positive errors from awTestRowSequence. r=mkmelin
authorPaul Morris <paul@thunderbird.net>
Fri, 04 Oct 2019 13:43:21 -0400
changeset 37077 32aa8b8df4f3161514965078389d2fbf2df90f17
parent 37076 5462c8d4451abb572f3c36afae2e2b043100d076
child 37078 6ff5305dadb925e7904cb5d4a3368a473d46cc95
push id395
push userclokep@gmail.com
push dateMon, 02 Dec 2019 19:38:57 +0000
reviewersmkmelin
bugs1584211
Bug 1584211 - Avoid false positive errors from awTestRowSequence. r=mkmelin This debugging function is written to test UIs like the compose dialog where each row has a drop down menu (to,cc,bcc). Those menus have an ID attached that has to be kept in sequence. But in the mailing list dialog the rows have no drop down menus, so this function was generating false positive errors there. Adjust it so it works for cases where there is no drop down menu.
mail/components/compose/content/addressingWidgetOverlay.js
--- a/mail/components/compose/content/addressingWidgetOverlay.js
+++ b/mail/components/compose/content/addressingWidgetOverlay.js
@@ -485,39 +485,34 @@ function awTestRowSequence() {
   let listbox = document.getElementById("addressingWidget");
   let listitems = listbox.itemChildren;
   if (listitems.length >= top.MAX_RECIPIENTS) {
     for (let i = 1; i <= listitems.length; i++) {
       let item = listitems[i - 1];
       let inputID = item
         .querySelector(`input[is="autocomplete-input"]`)
         .id.split("#")[1];
-      let popupID = item.querySelector("menulist").id.split("#")[1];
-      if (inputID != i || popupID != i) {
+      let menulist = item.querySelector("menulist");
+      // In some places like the mailing list dialog there is no menulist,
+      // and so no popupID that needs to be kept in sequence.
+      let popupID = menulist && menulist.id.split("#")[1];
+      if (inputID != i || (popupID && popupID != i)) {
         dump(
-          "#ERROR: sequence broken at row " +
-            i +
-            ", inputID=" +
-            inputID +
-            ", popupID=" +
-            popupID +
-            "\n"
+          `#ERROR: sequence broken at row ${i}, ` +
+            `inputID=${inputID}, popupID=${popupID}\n`
         );
         return false;
       }
       dump("---SEQUENCE OK---\n");
       return true;
     }
   } else {
     dump(
-      "#ERROR: listitems.length(" +
-        listitems.length +
-        ") < top.MAX_RECIPIENTS(" +
-        top.MAX_RECIPIENTS +
-        ")\n"
+      `#ERROR: listitems.length(${listitems.length}) < ` +
+        `top.MAX_RECIPIENTS(${top.MAX_RECIPIENTS})\n`
     );
   }
 
   return false;
 }
 
 function awCleanupRows() {
   var maxRecipients = top.MAX_RECIPIENTS;