Bug 628768 - mark as read toggle broken; r=bwinton ui-r=clarkbw a=3.3 blocker
authorJim Porter <squibblyflabbetydoo@gmail.com>
Mon, 14 Mar 2011 11:43:53 +0000
changeset 7345 6fbe19ade0d5fc5e7af5c521fe948378d0426b66
parent 7344 5294592f5499efbff63609a6b5b37dba05be229d
child 7346 eb416af716c504041114237dc749729b8e6120ff
child 7349 d77f19be2ec0e0b95fb61616e69a6b65fcbd51ef
push idunknown
push userunknown
push dateunknown
reviewersbwinton, clarkbw, 3
bugs628768
Bug 628768 - mark as read toggle broken; r=bwinton ui-r=clarkbw a=3.3 blocker
mail/base/content/mail3PaneWindowCommands.js
mail/base/content/mailWindowOverlay.xul
mail/locales/en-US/chrome/messenger/messenger.dtd
mail/test/mozmill/folder-display/test-message-commands.js
--- a/mail/base/content/mail3PaneWindowCommands.js
+++ b/mail/base/content/mail3PaneWindowCommands.js
@@ -206,16 +206,17 @@ var DefaultController =
       case "cmd_getMsgsForAuthAccounts":
       case "cmd_getNextNMessages":
       case "cmd_find":
       case "cmd_findAgain":
       case "cmd_findPrevious":
       case "cmd_search":
       case "button_mark":
       case "cmd_tag":
+      case "cmd_toggleRead":
       case "cmd_markAsRead":
       case "cmd_markAsUnread":
       case "cmd_markAllRead":
       case "cmd_markThreadAsRead":
       case "cmd_markReadByDate":
       case "cmd_markAsFlagged":
       case "cmd_markAsJunk":
       case "cmd_markAsNotJunk":
@@ -396,16 +397,17 @@ var DefaultController =
       case "cmd_applyFilters":
         return gFolderDisplay.getCommandStatus(nsMsgViewCommandType.applyFilters);
       case "cmd_runJunkControls":
         return gFolderDisplay.getCommandStatus(nsMsgViewCommandType.runJunkControls);
       case "cmd_deleteJunk":
         return gFolderDisplay.getCommandStatus(nsMsgViewCommandType.deleteJunk);
       case "button_mark":
       case "cmd_tag":
+      case "cmd_toggleRead":
       case "cmd_markThreadAsRead":
         return GetNumSelectedMessages() > 0;
       case "cmd_markAsRead":
         return CanMarkMsgAsRead(true);
       case "cmd_markAsUnread":
         return CanMarkMsgAsRead(false);
       case "button_previous":
       case "button_next":
@@ -775,16 +777,17 @@ var DefaultController =
         return;
       case "cmd_properties":
         gFolderTreeController.editFolder();
         return;
       case "cmd_search":
         MsgSearchMessages();
         return;
       case "button_mark":
+      case "cmd_toggleRead":
         MsgMarkMsgAsRead();
         return;
       case "cmd_markAsRead":
         MsgMarkMsgAsRead(true);
         return;
       case "cmd_markAsUnread":
         MsgMarkMsgAsRead(false);
         return;
--- a/mail/base/content/mailWindowOverlay.xul
+++ b/mail/base/content/mailWindowOverlay.xul
@@ -301,16 +301,17 @@
              disabled="true"/>
 </commandset>
 
 <commandset id="mailMarkMenuItems"
               commandupdater="true"
               events="create-menu-mark"
               oncommandupdate="goUpdateMailMenuItems(this)">
 
+    <command id="cmd_toggleRead" oncommand="goDoCommand('cmd_toggleRead'); event.stopPropagation()" disabled="true"/>
     <command id="cmd_markAsRead" oncommand="goDoCommand('cmd_markAsRead'); event.stopPropagation()" disabled="true"/>
     <command id="cmd_markAsUnread" oncommand="goDoCommand('cmd_markAsUnread'); event.stopPropagation()" disabled="true"/>
     <command id="cmd_markAllRead" oncommand="goDoCommand('cmd_markAllRead'); event.stopPropagation()" disabled="true"/>
     <command id="cmd_markThreadAsRead" oncommand="goDoCommand('cmd_markThreadAsRead'); event.stopPropagation()" disabled="true"/>
     <command id="cmd_markReadByDate" oncommand="goDoCommand('cmd_markReadByDate');" disabled="true"/>
     <command id="cmd_markAsFlagged" oncommand="goDoCommand('cmd_markAsFlagged'); event.stopPropagation()" disabled="true"/>
     <command id="cmd_markAsJunk" oncommand="goDoCommand('cmd_markAsJunk'); event.stopPropagation()" disabled="true"/>
     <command id="cmd_markAsNotJunk" oncommand="goDoCommand('cmd_markAsNotJunk'); event.stopPropagation()" disabled="true"/>
@@ -379,18 +380,17 @@
   <key id="key_delete" keycode="VK_DELETE"
        oncommand="goDoCommand('cmd_delete');"/>
   <key id="cmd_shiftDelete" keycode="VK_DELETE"
        oncommand="goDoCommand('cmd_shiftDelete');" modifiers="shift"/>
 #endif
   <key id="key_selectAll"/>
   <key id="key_selectThread" key="&selectThreadCmd.key;"             oncommand="goDoCommand('cmd_selectThread');" modifiers="accel, shift"/>
 
-  <key id="key_markAsRead" key="&markAsReadCmd.key;"                 oncommand="goDoCommand('cmd_markAsRead');"/>
-  <key id="key_markAsUnread" key="&markAsUnreadCmd.key;"             oncommand="goDoCommand('cmd_markAsUnread');" modifiers="shift"/>
+  <key id="key_toggleRead" key="&toggleReadCmd.key;"                 oncommand="goDoCommand('cmd_toggleRead');"/>
   <key id="key_toggleFlagged" key="&markStarredCmd.key;"             oncommand="goDoCommand('cmd_markAsFlagged');"/>
   <key id="key_markJunk" key="&markAsJunkCmd.key;"                   oncommand="goDoCommand('cmd_markAsJunk');"/>
   <key id="key_markNotJunk" key="&markAsNotJunkCmd.key;"             oncommand="goDoCommand('cmd_markAsNotJunk');"
        modifiers="shift"/>
 
   <key id="key_markAllRead" key="&markAllReadCmd.key;"
        oncommand="goDoCommand('cmd_markAllRead');" modifiers="shift"/>
 
@@ -1492,20 +1492,20 @@
                 <menuitem id="tagMenu-tagRemoveAll" oncommand="RemoveAllMessageTags();"/>
                 <menuseparator id="tagMenuAfterRemoveSeparator"/>
               </menupopup>
             </menu>
             <menu id="markMenu" label="&markMenu.label;" accesskey="&markMenu.accesskey;">
               <menupopup id="menu_MarkPopup" onpopupshowing="InitMessageMark()">
                 <menuitem id="markReadMenuItem" label="&markAsReadCmd.label;"
                           accesskey="&markAsReadCmd.accesskey;"
-                          command="cmd_markAsRead" key="key_markAsRead"/>
+                          command="cmd_markAsRead"/>
                 <menuitem id="markUnreadMenuItem" label="&markAsUnreadCmd.label;"
                           accesskey="&markAsUnreadCmd.accesskey;"
-                          command="cmd_markAsUnread" key="key_markAsUnread"/>
+                          command="cmd_markAsUnread"/>
                 <menuitem id="menu_markThreadAsRead" label="&markThreadAsReadCmd.label;" accesskey="&markThreadAsReadCmd.accesskey;" command="cmd_markThreadAsRead"
                           key="key_markThreadAsRead"/>
                 <menuitem id="menu_markReadByDate" label="&markReadByDateCmd.label;" accesskey="&markReadByDateCmd.accesskey;" command="cmd_markReadByDate"
                           key="key_markReadByDate"/>
                 <menuitem id="menu_markAllRead" label="&markAllReadCmd.label;" key="key_markAllRead" accesskey="&markAllReadCmd.accesskey;" command="cmd_markAllRead"/>
                 <menuseparator id="markMenuAfterAllReadSeparator"/>
                 <menuitem id="markFlaggedMenuItem"
                           type="checkbox"
@@ -1833,22 +1833,20 @@
                    type="menu-button"
                    class="toolbarbutton-1"
                    label="&markButton.label;"
                    oncommand="goDoCommand('button_mark')"
                    observes="button_mark"
                    tooltiptext="&markButton.tooltip;">
       <menupopup id="button-markPopup" onpopupshowing="InitMessageMark()">
         <menuitem id="markReadToolbarItem"
-                  key="key_markAsRead"
                   label="&markAsReadCmd.label;"
                   accesskey="&markAsReadCmd.accesskey;"
                   command="cmd_markAsRead" />
         <menuitem id="markUnreadToolbarItem"
-                  key="key_markAsUnread"
                   label="&markAsUnreadCmd.label;"
                   accesskey="&markAsUnreadCmd.accesskey;"
                   command="cmd_markAsUnread" />
         <menuitem id="button-markThreadAsRead"
                   label="&markThreadAsReadCmd.label;"
                   key="key_markThreadAsRead"
                   accesskey="&markThreadAsReadCmd.accesskey;"
                   command="cmd_markThreadAsRead"/>
--- a/mail/locales/en-US/chrome/messenger/messenger.dtd
+++ b/mail/locales/en-US/chrome/messenger/messenger.dtd
@@ -399,22 +399,21 @@ you can use these alternative items. Oth
 <!ENTITY tagCmd4.key "4">
 <!ENTITY tagCmd5.key "5">
 <!ENTITY tagCmd6.key "6">
 <!ENTITY tagCmd7.key "7">
 <!ENTITY tagCmd8.key "8">
 <!ENTITY tagCmd9.key "9">
 <!ENTITY markMenu.label "Mark">
 <!ENTITY markMenu.accesskey "k">
+<!ENTITY toggleReadCmd.key "m">
 <!ENTITY markAsReadCmd.label "As Read">
 <!ENTITY markAsReadCmd.accesskey "R">
-<!ENTITY markAsReadCmd.key "m">
 <!ENTITY markAsUnreadCmd.label "As Unread">
 <!ENTITY markAsUnreadCmd.accesskey "U">
-<!ENTITY markAsUnreadCmd.key "m">
 <!ENTITY markThreadAsReadCmd.label "Thread As Read">
 <!ENTITY markThreadAsReadCmd.accesskey "T">
 <!ENTITY markThreadAsReadCmd.key "r">
 <!ENTITY markReadByDateCmd.label "As Read by Dateā€¦">
 <!ENTITY markReadByDateCmd.accesskey "D">
 <!ENTITY markReadByDateCmd.key "c">
 <!ENTITY markAllReadCmd.label "All Read">
 <!ENTITY markAllReadCmd.accesskey "A">
--- a/mail/test/mozmill/folder-display/test-message-commands.js
+++ b/mail/test/mozmill/folder-display/test-message-commands.js
@@ -81,16 +81,17 @@ function check_read_status(messages, rea
   for (let i = 0; i < messages.length; i++)
     assert_true(messages[i].isRead == read,
                 "Message marked as " + read_str(messages[i].isRead) +
                 ", expected " + read_str(read));
 }
 
 /**
  * Ensures that the mark read/unread menu items are enabled/disabled properly
+ * @param index the row in the thread pane of the message to query
  * @param canMarkRead true if the mark read item should be enabled
  * @param canMarkUnread true if the mark unread item should be enabled
  */
 function check_read_menuitems(index, canMarkRead, canMarkUnread) {
   right_click_on_row(index);
   wait_for_popup_to_open(mc.e("mailContext"));
   mc.click_menus_in_sequence(mc.e("mailContext"), [{id: "mailContext-mark"}]);
 
@@ -107,91 +108,130 @@ function check_read_menuitems(index, can
 }
 
 function enable_archiving(enabled) {
   Cc["@mozilla.org/preferences-service;1"]
    .getService(Ci.nsIPrefService).getBranch(null)
    .setBoolPref("mail.identity.default.archive_enabled", enabled);
 }
 
-// XXX Disabled due to issues with running these tests on tinderbox
-/*
+function mark_read_via_menu(index, read) {
+  let menuItem = read ? "mailContext-markRead" : "mailContext-markUnread";
+  right_click_on_row(index);
+  mc.click_menus_in_sequence(mc.e("mailContext"), [{id: "mailContext-mark"},
+                                                   {id: menuItem}]);
+  close_popup(mc, mc.eid("mailContext"));
+}
+
 function test_mark_one_read() {
   be_in_folder(unreadFolder);
   let curMessage = select_click_row(0);
 
   curMessage.markRead(false);
-  mc.keypress(null, "m", {});
+  mark_read_via_menu(0, true);
   check_read_status([curMessage], true);
 }
 
 function test_mark_one_unread() {
   be_in_folder(unreadFolder);
   let curMessage = select_click_row(0);
 
   curMessage.markRead(true);
-  mc.keypress(null, "m", {shiftKey: true});
+  mark_read_via_menu(0, false);
   check_read_status([curMessage], false);
 }
 
 function test_mark_n_read() {
   be_in_folder(unreadFolder);
   select_click_row(0);
   let curMessages = select_shift_click_row(1);
 
   for (let i = 0; i < curMessages.length; i++)
     curMessages[i].markRead(false);
-  mc.keypress(null, "m", {});
+  mark_read_via_menu(0, true);
   check_read_status(curMessages, true);
 }
 
 function test_mark_n_unread() {
   be_in_folder(unreadFolder);
   select_click_row(0);
   let curMessages = select_shift_click_row(1);
 
   for (let i = 0; i < curMessages.length; i++)
     curMessages[i].markRead(true);
-  mc.keypress(null, "m", {shiftKey: true});
+  mark_read_via_menu(0, false);
   check_read_status(curMessages, false);
 }
 
 function test_mark_n_read_mixed() {
   be_in_folder(unreadFolder);
   select_click_row(0);
   let curMessages = select_shift_click_row(1);
 
   curMessages[0].markRead(true);
   curMessages[1].markRead(false);
-  mc.keypress(null, "m", {});
+  mark_read_via_menu(0, true);
   check_read_status(curMessages, true);
 
   curMessages[0].markRead(false);
   curMessages[1].markRead(true);
-  mc.keypress(null, "m", {});
+  mark_read_via_menu(0, true);
   check_read_status(curMessages, true);
 
 }
 
 function test_mark_n_unread_mixed() {
   be_in_folder(unreadFolder);
   select_click_row(0);
   let curMessages = select_shift_click_row(1);
 
   curMessages[0].markRead(false);
   curMessages[1].markRead(true);
-  mc.keypress(null, "m", {shiftKey: true});
+  mark_read_via_menu(0, false);
   check_read_status(curMessages, false);
 
   curMessages[0].markRead(true);
   curMessages[1].markRead(false);
-  mc.keypress(null, "m", {shiftKey: true});
+  mark_read_via_menu(0, false);
   check_read_status(curMessages, false);
 }
-*/
+
+function test_toggle_read() {
+  be_in_folder(unreadFolder);
+  let curMessage = select_click_row(0);
+
+  curMessage.markRead(false);
+  mc.keypress(null, "m", {});
+  check_read_status([curMessage], true);
+}
+
+function test_toggle_unread() {
+  be_in_folder(unreadFolder);
+  let curMessage = select_click_row(0);
+
+  curMessage.markRead(true);
+  mc.keypress(null, "m", {});
+  check_read_status([curMessage], false);
+}
+
+function test_toggle_mixed() {
+  be_in_folder(unreadFolder);
+  select_click_row(0);
+  let curMessages = select_shift_click_row(1);
+
+  curMessages[0].markRead(false);
+  curMessages[1].markRead(true);
+  mc.keypress(null, "m", {});
+  check_read_status(curMessages, true);
+
+  curMessages[0].markRead(true);
+  curMessages[1].markRead(false);
+  mc.keypress(null, "m", {});
+  check_read_status(curMessages, false);
+}
 
 function test_mark_menu_read() {
   be_in_folder(unreadFolder);
   let curMessage = select_click_row(0);
 
   curMessage.markRead(false);
   check_read_menuitems(0, true, false);
 }