Bug 1325967 - Enhance tests for reply/forward/etc. when using override or default charset. r=aceman a=jorgk
authorJorg K <jorgk@jorgk.com>
Thu, 29 Dec 2016 13:51:20 +0100
changeset 27697 26265ec715cf1ffa58436256667ebc108c90eebd
parent 27696 bdc870f9fe257618f91319559c7eb3d5b77b1b8c
child 27698 94c29c2b3a6ff6ac8dffae2d5fa915673f8c476a
push id1850
push userclokep@gmail.com
push dateWed, 08 Mar 2017 19:29:12 +0000
treeherdercomm-esr52@028df196b2d9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaceman, jorgk
bugs1325967
Bug 1325967 - Enhance tests for reply/forward/etc. when using override or default charset. r=aceman a=jorgk
mail/test/mozmill/composition/body-greek.eml
mail/test/mozmill/composition/test-reply-multipart-charset.js
new file mode 100644
--- /dev/null
+++ b/mail/test/mozmill/composition/body-greek.eml
@@ -0,0 +1,9 @@
+From: test <test@example.com>
+Subject: test reply to ISO-8859-7 encoded message
+To: test2 <test2@example.com>
+Date: Sat, 27 Feb 2016 17:11:45 +0100
+MIME-Version: 1.0
+Content-Type: text/plain; charset=ISO-8859-7
+Content-Transfer-Encoding: quoted-printable
+
+Here comes some Greek text: =CA=E1=EB=E7=F3=F0=DD=F1=E1
--- a/mail/test/mozmill/composition/test-reply-multipart-charset.js
+++ b/mail/test/mozmill/composition/test-reply-multipart-charset.js
@@ -1,16 +1,28 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /**
+ * This has become a "mixed bag" of tests for various bugs.
+ *
+ * Bug 1026989:
  * Tests that the reply to a message picks up the charset from the body
  * and not from an attachment. Also test "Edit as new", forward inline and
  * forward as attachment.
+ *
+ * Bug 961983:
+ * Tests that UTF-16 is not used in a composition.
+ *
+ * Bug 1323377:
+ * Tests that the correct charset is used, even if the message
+ * wasn't viewed before answering/forwarding.
+ * For good measure some tests are included for charset overriding
+ * and enforcing the charset default.
  */
 
 // make SOLO_TEST=composition/test-reply-multipart-charset.js mozmill-one
 
 var MODULE_NAME = "test-reply-multipart-charset";
 
 var RELATIVE_ROOT = "../shared-modules";
 var MODULE_REQUIRES = ["folder-display-helpers", "compose-helpers", "window-helpers"];
@@ -25,17 +37,19 @@ var folderToStoreMessages;
 function setupModule(module) {
   for (let lib of MODULE_REQUIRES) {
     collector.getModule(lib).installInto(module);
   }
 
   folderToStoreMessages = create_folder("FolderWithMessages");
 }
 
-function subtest_replyEditAsNewForward_charset(aAction, aFile, aCharset) {
+function subtest_replyEditAsNewForward_charset(aAction, aFile, aCharset,
+                                               aOverride = null,
+                                               aViewed = true) {
   be_in_folder(folderToStoreMessages);
 
   let file = os.getFileForPath(os.abspath(aFile,
                                os.getFileForPath(__file__)));
   let msgc = open_message_from_file(file);
 
   // Copy the message to a folder. We run the message through a folder
   // since replying/editing as new/forwarding directly to the message
@@ -46,17 +60,31 @@ function subtest_replyEditAsNewForward_c
   msgc.click_menus_in_sequence(msgc.e("mailContext"), [
     {id: "mailContext-copyMenu"},
     {label: "Local Folders"},
     {label: "FolderWithMessages"},
   ]);
   close_window(msgc);
 
   let msg = select_click_row(0);
-  assert_selected_and_displayed(mc, msg);
+  if (aViewed) {
+    // Only if the preview pane is on, we can check the following.
+    assert_selected_and_displayed(mc, msg);
+  }
+
+  if (aOverride) {
+    // Display the message using the override charset.
+    // Use the app menu which is also available on Mac.
+    mc.click(mc.eid("button-appmenu"));
+    mc.click_menus_in_sequence(mc.e("appmenu-popup"), [
+      {label: "View"},
+      {label: "Text Encoding"},
+      {label: aOverride},
+    ]);
+  }
 
   let fwdWin;
   switch (aAction) {
   case 1: // Reply.
     fwdWin = open_compose_with_reply();
     break;
   case 2: // Edit as new.
     fwdWin = open_compose_with_edit_as_new();
@@ -74,19 +102,50 @@ function subtest_replyEditAsNewForward_c
   let charset = fwdWin.e("content-frame").contentDocument.charset;
   assert_equals(charset, aCharset.toLowerCase(),
                 "Compose window has the wrong charset");
   close_compose_window(fwdWin);
 
   press_delete(mc);
 }
 
-function test_replyEditAsNewForward_charset() {
-  // Check that the charset is taken from the message body.
+function test_replyEditAsNewForward_charsetFromBody() {
+  // Check that the charset is taken from the message body (bug 1026989).
   subtest_replyEditAsNewForward_charset(1, "./multipart-charset.eml", "EUC-KR");
   subtest_replyEditAsNewForward_charset(2, "./multipart-charset.eml", "EUC-KR");
   subtest_replyEditAsNewForward_charset(3, "./multipart-charset.eml", "EUC-KR");
   // For "forward as attachment" we use the default charset (which is UTF-8).
   subtest_replyEditAsNewForward_charset(4, "./multipart-charset.eml", "UTF-8");
+}
 
-  // Check that a UTF-16 encoded e-mail is forced to UTF-8 when replying.
+function test_reply_noUTF16() {
+  // Check that a UTF-16 encoded e-mail is forced to UTF-8 when replying (bug 961983).
   subtest_replyEditAsNewForward_charset(1, "./body-utf16.eml", "UTF-8");
 }
+
+function test_replyEditAsNewForward_override() {
+  // Check that the override is honoured (inspired by bug 1323377).
+  subtest_replyEditAsNewForward_charset(1, "./multipart-charset.eml", "UTF-8", "Unicode");
+  subtest_replyEditAsNewForward_charset(2, "./multipart-charset.eml", "windows-1252", "Western");
+  subtest_replyEditAsNewForward_charset(3, "./multipart-charset.eml", "ISO-8859-7", "Greek (ISO)");
+}
+
+function test_replyEditAsNewForward_enforceDefault() {
+  // Check that the default is honoured (inspired by bug 1323377).
+  Services.prefs.setBoolPref("mailnews.reply_in_default_charset", true);
+  Services.prefs.setCharPref("mailnews.send_default_charset", "ISO-8859-7");
+  subtest_replyEditAsNewForward_charset(1, "./multipart-charset.eml", "ISO-8859-7");
+  subtest_replyEditAsNewForward_charset(2, "./multipart-charset.eml", "ISO-8859-7");
+  subtest_replyEditAsNewForward_charset(3, "./multipart-charset.eml", "ISO-8859-7");
+  Services.prefs.clearUserPref("mailnews.reply_in_default_charset");
+  Services.prefs.clearUserPref("mailnews.send_default_charset");
+}
+
+function test_replyEditAsNewForward_noPreview() {
+  // Check that it works even if the message wasn't viewed before, so
+  // switch off the preview pane (bug 1323377).
+  be_in_folder(folderToStoreMessages);
+  mc.window.goDoCommand("cmd_toggleMessagePane");
+
+  subtest_replyEditAsNewForward_charset(1, "./format-flowed.eml", "windows-1252", null, false);
+  subtest_replyEditAsNewForward_charset(2, "./body-greek.eml", "ISO-8859-7", null, false);
+  subtest_replyEditAsNewForward_charset(3, "./multipart-charset.eml", "EUC-KR", null, false);
+}