summaryrefslogtreecommitdiffstats
path: root/comm/mail/test/browser/composition/browser_base64Display.js
blob: 8b2dc1edafbc1e62e35356bb10b9795c86eedd96 (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
40
41
42
43
44
45
46
47
48
/* 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/. */

/**
 * Tests that messages with "broken" base64 are correctly displayed.
 */

"use strict";

var { get_about_message, open_message_from_file } = ChromeUtils.import(
  "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
);
var { close_window } = ChromeUtils.import(
  "resource://testing-common/mozmill/WindowHelpers.jsm"
);

add_task(async function test_base64_display() {
  let file = new FileUtils.File(
    getTestFilePath("data/base64-with-whitespace.eml")
  );
  let msgc = await open_message_from_file(file);
  let aboutMessage = get_about_message(msgc.window);
  let bodyText = aboutMessage.document
    .getElementById("messagepane")
    .contentDocument.querySelector("body").textContent;
  close_window(msgc);

  Assert.ok(
    bodyText.includes("abcdefghijklmnopqrstuvwxyz"),
    "Decode base64 body from message."
  );
});

add_task(async function test_base64_display2() {
  let file = new FileUtils.File(getTestFilePath("data/base64-bug1586890.eml"));
  let msgc = await open_message_from_file(file);
  let aboutMessage = get_about_message(msgc.window);
  let bodyText = aboutMessage.document
    .getElementById("messagepane")
    .contentDocument.querySelector("body").textContent;
  close_window(msgc);

  Assert.ok(
    bodyText.includes("abcdefghijklm"),
    "Decode base64 body from UTF-16 message with broken charset."
  );
});