summaryrefslogtreecommitdiffstats
path: root/comm/mailnews/mime/test/unit/test_EncodeMimePartIIStr_UTF8.js
blob: 71d31da9ac8043994f88ff469b5f86340dc43979 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/* 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 tests minimal mime encoding fixed in bug 458685

var { MailServices } = ChromeUtils.import(
  "resource:///modules/MailServices.jsm"
);

function run_test() {
  var i;

  var checks = [
    ["", false, ""],
    ["\u0436", false, "=?UTF-8?B?0LY=?="], // CYRILLIC SMALL LETTER ZHE
    ["IamASCII", false, "IamASCII"],
    // Although an invalid email, we shouldn't crash on it (bug 479206)
    ["crash test@foo.invalid>", true, '"crash test"@foo.invalid'],
    [
      "MXR now displays links to Github log & Blame for\r\n Gaia/Rust/Servo",
      false,
      "MXR now displays links to Github log & Blame for\r\n Gaia/Rust/Servo",
    ],
    ["-----------------------:", false, "-----------------------:"],
  ];

  for (i = 0; i < checks.length; ++i) {
    Assert.equal(
      MailServices.mimeConverter.encodeMimePartIIStr_UTF8(
        checks[i][0],
        checks[i][1],
        "Subject".length,
        72
      ),
      checks[i][2]
    );
  }
}