Bug 1510616 - fix getting treecolpicker element on folder tree after bug 1503824. r=mkmelin
authoraceman <acelists@atlas.sk>
Fri, 30 Nov 2018 18:30:00 +0100
changeset 33833 f93942f170c422356fc66624dc70c08ebdd53df5
parent 33832 120405ddc5daffb395b2e691f13df5b3e8c41c7e
child 33834 e4612d760fefe9e52c9df8edafbf1d56605483c3
push id388
push userclokep@gmail.com
push dateMon, 28 Jan 2019 20:54:56 +0000
reviewersmkmelin
bugs1510616, 1503824
Bug 1510616 - fix getting treecolpicker element on folder tree after bug 1503824. r=mkmelin
mail/base/content/mailContextMenus.js
mail/base/content/nsContextMenu.js
mail/test/mozmill/folder-display/test-columns.js
mail/test/mozmill/folder-display/test-right-click-middle-click-messages.js
mail/test/mozmill/shared-modules/test-window-helpers.js
--- a/mail/base/content/mailContextMenus.js
+++ b/mail/base/content/mailContextMenus.js
@@ -284,24 +284,17 @@ function folderPaneOnPopupHiding() {
 }
 
 /* eslint-disable complexity */
 function fillFolderPaneContextMenu(aEvent) {
   let target = document.popupNode;
   // If a column header was clicked, show the column picker.
   if (target.localName == "treecol") {
     let treecols = target.parentNode;
-    let nodeList = document.getAnonymousNodes(treecols);
-    let treeColPicker = null;
-    for (let i = 0; i < nodeList.length; i++) {
-      if (nodeList.item(i).localName == "treecolpicker") {
-        treeColPicker = nodeList.item(i);
-        break;
-      }
-    }
+    let treeColPicker = treecols.querySelector("treecolpicker");
     if (treeColPicker) {
       let popup = document.getAnonymousElementByAttribute(treeColPicker, "anonid", "popup");
       treeColPicker.buildPopup(popup);
       popup.openPopup(target, "after_start", 0, 0, true);
     }
     return false;
   }
 
--- a/mail/base/content/nsContextMenu.js
+++ b/mail/base/content/nsContextMenu.js
@@ -438,24 +438,17 @@ nsContextMenu.prototype = {
     gSpellChecker.uninit();
 
     const xulNS =
       "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
     if (aNode.namespaceURI == xulNS) {
       if (aNode.localName == "treecol") {
         // The column header was clicked, show the column picker.
         let treecols = aNode.parentNode;
-        let nodeList = document.getAnonymousNodes(treecols);
-        let treeColPicker;
-        for (let i = 0; i < nodeList.length; i++) {
-          if (nodeList.item(i).localName == "treecolpicker") {
-            treeColPicker = nodeList.item(i);
-            break;
-          }
-        }
+        let treeColPicker = treecols.querySelector("treecolpicker");
         let popup = document.getAnonymousElementByAttribute(treeColPicker, "anonid", "popup");
         treeColPicker.buildPopup(popup);
         popup.openPopup(aNode, "before_start", 0, 0, true);
         this.shouldDisplay = false;
       }
       return;
     }
     this.onImage        = false;
--- a/mail/test/mozmill/folder-display/test-columns.js
+++ b/mail/test/mozmill/folder-display/test-columns.js
@@ -348,30 +348,29 @@ function test_column_reordering_persists
 
 function invoke_column_picker_option(aActions) {
   // The treecolpicker element itself doesn't have an id, so we have to walk
   // down from the parent to find it.
   //  treadCols
   //   |- hbox                item 0
   //   |- treecolpicker   <-- item 1 this is the one we want
   let threadCols = mc.window.document.getElementById("threadCols");
-  let colPicker = mc.window.document.getAnonymousNodes(threadCols).item(1);
+  let colPicker = threadCols.querySelector("treecolpicker");
   let colPickerPopup = mc.window.document.getAnonymousElementByAttribute(
                          colPicker, "anonid", "popup");
 
   mc.click(new elib.Elem(colPicker));
   mc.click_menus_in_sequence(colPickerPopup, aActions);
 }
 
 
 /**
  * The column picker's "reset columns to default" option should set our state
  *  back to inbox state.
  */
-test_reset_to_inbox.__force_skip__ = true;
 function test_reset_to_inbox() {
   // create the source
   folderSource = create_folder("ColumnsApplySource");
   // it better have INBOX defaults
   assert_visible_columns(INBOX_DEFAULTS);
 
   // permute them
   let conExtra = INBOX_DEFAULTS.concat(["sizeCol"]);
@@ -401,17 +400,16 @@ function _apply_to_folder_common(aChildr
   if (aChildrenToo)
     wait_for_observable_event("msg-folder-columns-propagated");
 }
 
 /**
  * Change settings in a folder, apply them to another folder that also has
  *  children.  Make sure the folder changes but the children do not.
  */
-test_apply_to_folder_no_children.__force_skip__ = true;
 function test_apply_to_folder_no_children() {
   folderParent = create_folder("ColumnsApplyParent");
   folderParent.createSubfolder("Child1", null);
   folderChild1 = folderParent.getChildNamed("Child1");
   folderParent.createSubfolder("Child2", null);
   folderChild2 = folderParent.getChildNamed("Child2");
 
   be_in_folder(folderSource);
@@ -437,17 +435,16 @@ function test_apply_to_folder_no_childre
   be_in_folder(folderChild2);
   assert_visible_columns(INBOX_DEFAULTS);
 }
 
 /**
  * Change settings in a folder, apply them to another folder and its children.
  *  Make sure the folder and its children change.
  */
-test_apply_to_folder_and_children.__force_skip__ = true;
 function test_apply_to_folder_and_children() {
   // no need to throttle ourselves during testing.
   MailUtils.INTER_FOLDER_PROCESSING_DELAY_MS = 0;
 
   be_in_folder(folderSource);
 
   // reset!
   invoke_column_picker_option([{anonid: "reset"}]);
@@ -469,17 +466,16 @@ function test_apply_to_folder_and_childr
   assert_visible_columns(conExtra);
 }
 test_apply_to_folder_and_children.EXCLUDED_PLATFORMS = ['linux'];  // See bug 1406717.
 
 /**
  * Change settings in an incoming folder, apply them to an outgoing folder that
  * also has children. Make sure the folder changes but the children do not.
  */
-test_apply_to_folder_no_children_swapped.__force_skip__ = true;
 function test_apply_to_folder_no_children_swapped() {
   folderParent = create_folder("ColumnsApplyParentOutgoing");
   folderParent.setFlag(Ci.nsMsgFolderFlags.SentMail);
   folderParent.createSubfolder("Child1", null);
   folderChild1 = folderParent.getChildNamed("Child1");
   folderParent.createSubfolder("Child2", null);
   folderChild2 = folderParent.getChildNamed("Child2");
 
@@ -517,17 +513,16 @@ function test_apply_to_folder_no_childre
   assert_visible_columns(SENT_DEFAULTS);
 }
 test_apply_to_folder_no_children_swapped.EXCLUDED_PLATFORMS = ['linux'];  // See bug 1406717.
 
 /**
  * Change settings in an incoming folder, apply them to an outgoing folder and
  * its children. Make sure the folder and its children change.
  */
-test_apply_to_folder_and_children_swapped.__force_skip__ = true;
 function test_apply_to_folder_and_children_swapped() {
   // No need to throttle ourselves during testing.
   MailUtils.INTER_FOLDER_PROCESSING_DELAY_MS = 0;
 
   be_in_folder(folderSource);
 
   // reset!
   invoke_column_picker_option([{anonid: "reset"}]);
@@ -605,17 +600,16 @@ function test_persist_columns_gloda_coll
   glodaColumns = GLODA_DEFAULTS.slice(0, -1);
   glodaColumns.push("accountCol");
 
   mc.tabmail.openTab("glodaList", { collection: fakeCollection });
   wait_for_all_messages_to_load();
   assert_visible_columns(glodaColumns);
 }
 
-test_reset_columns_gloda_collection.__force_skip__ = true;
 function test_reset_columns_gloda_collection() {
   let fakeCollection = new FakeCollection();
   mc.tabmail.openTab("glodaList", { collection: fakeCollection });
   wait_for_all_messages_to_load();
   assert_visible_columns(glodaColumns);
 
   invoke_column_picker_option([{anonid: "reset"}]);
   assert_visible_columns(GLODA_DEFAULTS);
--- a/mail/test/mozmill/folder-display/test-right-click-middle-click-messages.js
+++ b/mail/test/mozmill/folder-display/test-right-click-middle-click-messages.js
@@ -63,27 +63,26 @@ function test_right_click_with_nothing_s
 
   close_popup(mc, mc.eid("mailContext"));
   assert_nothing_selected();
 }
 
 /**
  * Test that clicking on the column header shows the column picker.
  */
-test_right_click_column_header_shows_col_picker.__force_skip__ = true;
 function test_right_click_column_header_shows_col_picker() {
   be_in_folder(folder);
 
   // The treecolpicker element itself doesn't have an id, so we have to walk
   // down from the parent to find it.
   //  treadCols
   //   |- hbox                item 0
   //   |- treecolpicker   <-- item 1 this is the one we want
   let threadCols = mc.window.document.getElementById("threadCols");
-  let treeColPicker = mc.window.document.getAnonymousNodes(threadCols).item(1);
+  let treeColPicker = threadCols.querySelector("treecolpicker");
   let popup = mc.window.document.getAnonymousElementByAttribute(
                 treeColPicker, "anonid", "popup");
 
   // Right click the subject column header
   // This should show the column picker popup.
   mc.rightClick(mc.eid("subjectCol"));
 
   // Check that the popup opens.
--- a/mail/test/mozmill/shared-modules/test-window-helpers.js
+++ b/mail/test/mozmill/shared-modules/test-window-helpers.js
@@ -1762,17 +1762,17 @@ function augment_controller(aController,
     let treecolses = doc.documentElement.getElementsByTagName("treecols");
     for (let i = 0; i < treecolses.length; i++) {
       let treecols = treecolses[i];
       // The treecolpicker element itself doesn't have an id, so we have to walk
       // down from the parent to find it.
       //  treadCols
       //   |- hbox                item 0
       //   |- treecolpicker   <-- item 1 this is the one we want
-      let treeColPicker = doc.getAnonymousNodes(treecols).item(1);
+      let treeColPicker = treecols.querySelector("treecolpicker");
       let popup = doc.getAnonymousElementByAttribute(treeColPicker,
                                                      "anonid", "popup");
       popup.addEventListener("popupshowing", __popup_showing, true);
       popup.addEventListener("popupshown", __popup_shown, true);
       popup.addEventListener("popuphiding", __popup_hiding, true);
       popup.addEventListener("popuphidden", __popup_hidden, true);
     }