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
|
/**
* The intent of this file is to test that pop3 download code message storage
* works correctly.
*/
/* import-globals-from ../../../test/resources/POP3pump.js */
load("../../../resources/POP3pump.js");
var testSubjects = [
"[Bug 397009] A filter will let me tag, but not untag",
"Hello, did you receive my bugmail?",
"[Bug 655578] list-id filter broken",
];
var gMsgHdrs = [];
var gHdrIndex = 0;
var gFiles = [
"../../../data/bugmail1",
"../../../data/draft1",
"../../../data/bugmail19",
];
// This combination of prefs is required to reproduce bug 713611, which
// is what this test is about.
Services.prefs.setBoolPref("mailnews.downloadToTempFile", false);
Services.prefs.setBoolPref("mail.server.default.leave_on_server", true);
function run_test() {
// add 3 messages
gPOP3Pump.files = gFiles;
gPOP3Pump.onDone = continueTest;
do_test_pending();
gPOP3Pump.run();
}
function continueTest() {
// get message headers for the inbox folder
var msgCount = 0;
for (let hdr of localAccountUtils.inboxFolder.msgDatabase.enumerateMessages()) {
gMsgHdrs.push(hdr);
Assert.equal(hdr.subject, testSubjects[msgCount++]);
}
Assert.equal(msgCount, 3);
gPOP3Pump = null;
streamNextMessage();
}
function streamNextMessage() {
let msghdr = gMsgHdrs[gHdrIndex];
let msgURI = msghdr.folder.getUriForMsg(msghdr);
let msgServ = MailServices.messageServiceFromURI(msgURI);
msgServ.streamMessage(msgURI, gStreamListener, null, null, false, "", true);
}
var gStreamListener = {
QueryInterface: ChromeUtils.generateQI(["nsIStreamListener"]),
_stream: null,
_data: null,
onStartRequest(aRequest) {
this._stream = null;
this._data = "";
},
onStopRequest(aRequest, aStatusCode) {
// check that the streamed message starts with "From "
Assert.ok(this._data.startsWith("From "));
if (++gHdrIndex == gFiles.length) {
do_test_finished();
} else {
streamNextMessage();
}
},
onDataAvailable(aRequest, aInputStream, aOff, aCount) {
if (this._stream == null) {
this._stream = Cc["@mozilla.org/scriptableinputstream;1"].createInstance(
Ci.nsIScriptableInputStream
);
this._stream.init(aInputStream);
}
this._data += this._stream.read(aCount);
},
};
|