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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
/* 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/. */
/**
* Test mail.compose.other.header is rendered and handled correctly.
*/
var {
close_compose_window,
get_msg_source,
open_compose_new_mail,
save_compose_message,
open_compose_from_draft,
} = ChromeUtils.import("resource://testing-common/mozmill/ComposeHelpers.jsm");
var { be_in_folder, select_click_row, get_special_folder } = ChromeUtils.import(
"resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
);
var { wait_for_window_focused } = ChromeUtils.import(
"resource://testing-common/mozmill/WindowHelpers.jsm"
);
/**
* Test custom headers are set and encoded correctly.
*/
add_task(async function test_customHeaders() {
let draftsFolder = await get_special_folder(Ci.nsMsgFolderFlags.Drafts, true);
// Set other.header so that they will be rendered in compose window.
let otherHeaders = Services.prefs.getCharPref("mail.compose.other.header");
Services.prefs.setCharPref(
"mail.compose.other.header",
"X-Header1, X-Header2, Approved ,Supersedes"
);
// Set values to custom headers.
let cwc = open_compose_new_mail();
let inputs = cwc.window.document.querySelectorAll(".address-row-raw input");
inputs[0].value = "Test äöü";
inputs[1].value = "Test 😃";
inputs[2].value = "moderator@tinderbox.com";
inputs[3].value = "<message-id-1234@tinderbox.com>";
await save_compose_message(cwc.window);
close_compose_window(cwc);
await TestUtils.waitForCondition(
() => draftsFolder.getTotalMessages(false) == 1,
"message saved to drafts folder"
);
await be_in_folder(draftsFolder);
let draftMsg = select_click_row(0);
let draftMsgLines = (await get_msg_source(draftMsg)).split("\n");
// Check header values are set and encoded correctly.
Assert.ok(
draftMsgLines.some(
line => line.trim() == "X-Header1: =?UTF-8?B?VGVzdCDDpMO2w7w=?="
),
"Correct X-Header1 found"
);
Assert.ok(
draftMsgLines.some(
line => line.trim() == "X-Header2: =?UTF-8?B?VGVzdCDwn5iD?="
),
"Correct X-Header2 found"
);
Assert.ok(
draftMsgLines.some(
line => line.trim() == "Approved: moderator@tinderbox.com"
),
"Correct Approved found"
);
Assert.ok(
draftMsgLines.some(
line => line.trim() == "Supersedes: <message-id-1234@tinderbox.com>"
),
"Correct Supersedes found"
);
cwc = open_compose_from_draft();
let inputs2 = cwc.window.document.querySelectorAll(".address-row-raw input");
Assert.equal(inputs2[0].value, "Test äöü");
Assert.equal(inputs2[1].value, "Test 😃");
Assert.equal(inputs2[2].value, "moderator@tinderbox.com");
Assert.equal(inputs2[3].value, "<message-id-1234@tinderbox.com>");
close_compose_window(cwc);
// Reset other.header.
Services.prefs.setCharPref("mail.compose.other.header", otherHeaders);
});
|