Bug 682803 - can't set address book in filters. r+a=Standard8
authorMike Conley <mconley@mozilla.com>
Wed, 31 Aug 2011 21:03:08 +0100
changeset 8520 121d0daa0447619141a1474b64632663f1f31952
parent 8519 8c41f2a2a78f4168e302e530d98a0a5ad33e6cee
child 8521 06cd5532ae6179a83489addc3690c66a15eadda7
push id122
push userbugzilla@standard8.plus.com
push dateWed, 31 Aug 2011 20:06:01 +0000
treeherdercomm-aurora@121d0daa0447 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs682803
Bug 682803 - can't set address book in filters. r+a=Standard8
mail/base/content/mailWidgets.xml
mail/test/mozmill/folder-widget/test-message-filters.js
--- a/mail/base/content/mailWidgets.xml
+++ b/mail/base/content/mailWidgets.xml
@@ -1615,30 +1615,17 @@
           <xul:menuitem value="1" stringTag="read" class="search-value-menuitem"/>
           <xul:menuitem value="65536" stringTag="new" class="search-value-menuitem"/>
           <xul:menuitem value="4096" stringTag="forwarded" class="search-value-menuitem"/>
           <xul:menuitem value="4" stringTag="flagged" class="search-value-menuitem"/>
         </xul:menupopup>
       </xul:menulist>
       <xul:textbox flex="1" class="search-value-textbox" xbl:inherits="disabled"/>
       <xul:menulist flex="1" class="search-value-menulist" xbl:inherits="disabled">
-        <xul:menupopup class="search-value-popup" ref="moz-abdirectory://"
-                 datasources="rdf:addressdirectory"
-                 sortActive="true"
-                 sortDirection="ascending"
-                 sortResource="http://home.netscape.com/NC-rdf#DirTreeNameSort">
-          <xul:template>
-            <xul:rule nc:IsRemote="true"/>
-            <xul:rule nc:IsMailList="false">
-              <xul:menuitem uri="..."
-                    label="rdf:http://home.netscape.com/NC-rdf#DirName"
-                    value="rdf:http://home.netscape.com/NC-rdf#DirUri"/>
-            </xul:rule>
-          </xul:template>
-        </xul:menupopup>
+        <xul:menupopup class="addrbooksPopup" localonly="true"/>
       </xul:menulist>
       <xul:menulist flex="1" class="search-value-menulist" xbl:inherits="disabled">
         <xul:menupopup class="search-value-popup">
         </xul:menupopup>
       </xul:menulist>
       <xul:menulist flex="1" class="search-value-menulist" xbl:inherits="disabled">
         <xul:menupopup class="search-value-popup">
           <xul:menuitem value="2" stringTag="junk" class="search-value-menuitem"/>
--- a/mail/test/mozmill/folder-widget/test-message-filters.js
+++ b/mail/test/mozmill/folder-widget/test-message-filters.js
@@ -15,16 +15,17 @@
  *
  * The Initial Developer of the Original Code is
  * the Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2009
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Blake Winton <bwinton@latte.ca>
+ *   Mike Conley <mconley@mozilla.com>
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  * in which case the provisions of the GPL or the LGPL are applicable instead
  * of those above. If you wish to allow use of your version of this file only
  * under the terms of either the GPL or the LGPL, and not to allow others to
  * use your version of this file under the terms of the MPL, indicate your
@@ -37,30 +38,32 @@
 
 /*
  * Test various properties of the message filters.
  */
 var MODULE_NAME = "test-message-filters";
 
 var RELATIVE_ROOT = "../shared-modules";
 var MODULE_REQUIRES = ["folder-display-helpers", "window-helpers",
-                       "test-nntp-helpers"];
+                       "test-nntp-helpers", "address-book-helpers"];
 
 var elib = {};
 Cu.import('resource://mozmill/modules/elementslib.js', elib);
 var folderA;
 
 function setupModule(module)
 {
   let fdh = collector.getModule("folder-display-helpers");
   fdh.installInto(module);
   let wh = collector.getModule("window-helpers");
   wh.installInto(module);
   let nh = collector.getModule("test-nntp-helpers");
   nh.installInto(module);
+  let abh = collector.getModule("address-book-helpers");
+  abh.installInto(module);
 
   setupNNTPDaemon();
 
   folderA = create_folder("FolderToolbarA");
   // we need one message to select and open
   make_new_sets_in_folder(folderA, [{count: 1}]);
 
   server = setupLocalServer(NNTP_PORT);
@@ -138,8 +141,56 @@ function test_customize_toolbar_doesnt_d
   mc.rightClick(mc.eid("mail-bar3"));
   mc.click(mc.eid("CustomizeMailToolbar"));
 
   let toolbox = mc.eid("mail-toolbox");
   toolbox.node.customizeDone();
   assert_equals(menu.node.itemCount, 5,
                 "Incorrect number of items for GetNewMessages after customization");
 }
+
+/*
+ * Test that the address books can appear in the message filter dropdown
+ */
+function test_address_books_appear_in_message_filter_dropdown()
+{
+  // Create a remote address book - we don't want this to appear in the
+  // dropdown.
+  let ldapAb = create_ldap_address_book("Some LDAP Address Book");
+
+  // Sanity check - this LDAP book should be remote.
+  assert_true(ldapAb.isRemote);
+
+  // Open the "Tools » Message Filters…" window,
+  // a.k.a. "tasksMenu » filtersCmd".
+  mc.menus.Tools.filtersCmd.click();
+
+  // We'll assume that the filters dialog is already open from
+  // the previous tests.
+  let filterc = wait_for_existing_window("mailnews:filterlist");
+
+  // Prepare a function to deal with the filter editor once it
+  // has opened
+  function filterEditorOpened(fec) {
+    let searchAttr = fec.e("searchAttr0");
+    let attrList = fec.window.document.getAnonymousNodes(searchAttr)[0];
+    attrList.value = Components.interfaces.nsMsgSearchAttrib.To;
+    let searchOp = fec.e("searchOp0");
+    let opList = fec.window.document.getAnonymousNodes(searchOp)[0];
+    opList.value = Components.interfaces.nsMsgSearchOp.IsInAB;
+    let searchValue = fec.e("searchVal0");
+
+    // The magic number "4" is because the address book list is the
+    // 4th child node of the searchvalue widget.
+    let abList = fec.window.document.getAnonymousNodes(searchValue)[4];
+
+    // We should have 2 address books here - one for the Personal Address
+    // Book, and one for Collected Addresses.  The LDAP address book should
+    // not be shown, since it isn't a local address book.
+    assert_equals(2, abList.itemCount, "Did not display the correct number "
+                  + "of address books in the filter menu list.");
+  }
+
+  // Let's open the filter editor.
+  plan_for_modal_dialog("mailnews:filtereditor", filterEditorOpened);
+  filterc.click(filterc.eid("newButton"));
+  wait_for_modal_dialog("mailnews:filtereditor");
+}