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
93
94
95
96
97
98
99
|
/* 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/. */
const { GlodaIndexer } = ChromeUtils.import(
"resource:///modules/gloda/GlodaIndexer.jsm"
);
const { MessageGenerator } = ChromeUtils.import(
"resource://testing-common/mailnews/MessageGenerator.jsm"
);
const { PromiseTestUtils } = ChromeUtils.import(
"resource://testing-common/mailnews/PromiseTestUtils.jsm"
);
const TEST_DOCUMENT_URL =
"http://mochi.test:8888/browser/comm/mail/base/test/browser/files/sampleContent.html";
const TEST_IMAGE_URL =
"http://mochi.test:8888/browser/comm/mail/base/test/browser/files/tb-logo.png";
let tabmail = document.getElementById("tabmail");
let rootFolder, testFolder, testMessages;
add_setup(async function () {
MailServices.accounts.createLocalMailAccount();
let account = MailServices.accounts.accounts[0];
account.addIdentity(MailServices.accounts.createIdentity());
rootFolder = account.incomingServer.rootFolder;
rootFolder.createSubfolder("tabIcon", null);
testFolder = rootFolder
.getChildNamed("tabIcon")
.QueryInterface(Ci.nsIMsgLocalMailFolder);
let messageFile = new FileUtils.File(
getTestFilePath("files/sampleContent.eml")
);
Assert.ok(messageFile.exists(), "test data file should exist");
let promiseCopyListener = new PromiseTestUtils.PromiseCopyListener();
// Copy gIncomingMailFile into the Inbox.
MailServices.copy.copyFileMessage(
messageFile,
testFolder,
null,
false,
0,
"",
promiseCopyListener,
null
);
await promiseCopyListener.promise;
testMessages = [...testFolder.messages];
tabmail.currentAbout3Pane.displayFolder(testFolder);
registerCleanupFunction(() => {
tabmail.closeOtherTabs(0);
MailServices.accounts.removeAccount(account, false);
});
});
add_task(async function testMsgInFolder() {
tabmail.currentAbout3Pane.threadTree.selectedIndex = 0;
await BrowserTestUtils.browserLoaded(
tabmail.currentAboutMessage.getMessagePaneBrowser()
);
let icon = tabmail.tabInfo[0].tabNode.querySelector(".tab-icon-image");
await TestUtils.waitForCondition(() => icon.complete, "Icon loaded");
Assert.equal(
icon.src,
"chrome://messenger/skin/icons/new/compact/folder.svg"
);
});
add_task(async function testMsgInTab() {
window.OpenMessageInNewTab(testMessages[0], { background: false });
await BrowserTestUtils.waitForEvent(
tabmail.tabInfo[1].chromeBrowser,
"MsgLoaded"
);
let tab = tabmail.tabInfo[1];
let icon = tab.tabNode.querySelector(".tab-icon-image");
await TestUtils.waitForCondition(() => icon.complete, "Icon loaded");
Assert.equal(icon.src, "chrome://messenger/skin/icons/new/compact/draft.svg");
});
add_task(async function testContentTab() {
let tab = window.openTab("contentTab", {
url: TEST_DOCUMENT_URL,
background: false,
});
await BrowserTestUtils.browserLoaded(tab.browser);
let icon = tab.tabNode.querySelector(".tab-icon-image");
// Start of TEST_IMAGE_URL as data url.
await TestUtils.waitForCondition(
() => icon.src.startsWith("data:image/png;base64,iVBORw0KGgoAAAANSUhEU"),
"Waited for icon to be correct"
);
});
|