Bug 833909 - show the attachment notifier if reopening a draft with keywords. r=jorgk
authoraceman <acelists@atlas.sk>
Wed, 30 Mar 2016 15:51:00 +0200
changeset 19145 bfd81bd6163ba7469b7b4744c8656ff847620796
parent 19144 ddcbed3a77c0a510faca283156d781e2126763cc
child 19146 e2b4f60836623eabf99b560def6e3c0ed0a9e444
push id11752
push usermozilla@jorgk.com
push dateThu, 31 Mar 2016 21:26:34 +0000
treeherdercomm-central@e2b4f6083662 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorgk
bugs833909
Bug 833909 - show the attachment notifier if reopening a draft with keywords. r=jorgk
mail/components/compose/content/MsgComposeCommands.js
mail/test/mozmill/composition/test-attachment-reminder.js
--- a/mail/components/compose/content/MsgComposeCommands.js
+++ b/mail/components/compose/content/MsgComposeCommands.js
@@ -4709,16 +4709,20 @@ var gAttachmentNotifier =
       characterData: true,
       subtree: true,
     });
 
     // Add an input event listener for the subject field since there
     // are ways of changing its value without key presses.
     GetMsgSubjectElement().addEventListener("input",
       this.subjectObserver, true);
+
+    // We could have been opened with a draft message already containing
+    // some keywords, so run the checker once to pick them up.
+    this.event.notify();
   },
 
   // Timer based function triggered by the inputEventListener
   // for the subject field.
   subjectObserver: function handleEvent() {
     gAttachmentNotifier.timer.cancel();
     gAttachmentNotifier.timer.initWithCallback(gAttachmentNotifier.event, 500,
                                                Components.interfaces.nsITimer.TYPE_ONE_SHOT);
--- a/mail/test/mozmill/composition/test-attachment-reminder.js
+++ b/mail/test/mozmill/composition/test-attachment-reminder.js
@@ -550,16 +550,67 @@ function test_disabled_attachment_remind
   click_send_and_handle_send_error(cwc);
 
   close_compose_window(cwc);
 
   Services.prefs.setBoolPref(kReminderPref, true);
 }
 
 /**
+ * Bug 833909
+ * Test reminder comes up when a draft with keywords is opened.
+ */
+function test_reminder_in_draft() {
+  // Open a sample message with no attachment keywords.
+  let cwc = open_compose_new_mail();
+  setupComposeWin(cwc, "test@example.invalid", "Testing draft reminder!",
+                  "Some body...");
+
+  // This one should have the manual reminder disabled.
+  assert_manual_reminder_state(cwc, false);
+  // There should be no attachment notification.
+  assert_automatic_reminder_state(cwc, false);
+
+  // Add some keyword so the automatic notification
+  // could potentially show up.
+  setupComposeWin(cwc, "", "", " and look for your attachment!");
+
+  // Give the notification time to appear.
+  wait_for_reminder_state(cwc, true);
+
+  // Now close the message with saving it as draft.
+  plan_for_modal_dialog("commonDialog", click_save_message);
+  cwc.window.goDoCommand("cmd_close");
+  wait_for_modal_dialog("commonDialog");
+
+  // The draft message was saved into Local Folders/Drafts.
+  let drafts = MailServices.accounts.localFoldersServer.rootFolder
+                           .getFolderWithFlags(Ci.nsMsgFolderFlags.Drafts);
+  be_in_folder(drafts);
+
+  select_click_row(0);
+  // Wait for the notification with the Edit button.
+  wait_for_notification_to_show(mc, "msgNotificationBar", "draftMsgContent");
+  // Edit the draft again...
+  plan_for_new_window("msgcompose");
+  // ... by clicking Edit in the draft message notification bar.
+  mc.click(mc.eid("msgNotificationBar", {tagName: "button", label: "Edit"}));
+  cwc = wait_for_compose_window();
+
+  // Give the notification time to appear.
+  wait_for_reminder_state(cwc, true);
+
+  close_compose_window(cwc);
+
+  // Delete the leftover draft message.
+  press_delete();
+}
+
+
+/**
  * Click the send button and handle the send error dialog popping up.
  * It will return us back to the compose window.
  *
  * @param aController
  * @param aAlreadySending  Set this to true if sending was already triggered
  *                         by other means.
  */
 function click_send_and_handle_send_error(aController, aAlreadySending) {