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
|
/* 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 test checks proper operation of the account ordering functionality in the Account manager.
*/
"use strict";
var { click_account_tree_row, get_account_tree_row, open_advanced_settings } =
ChromeUtils.import(
"resource://testing-common/mozmill/AccountManagerHelpers.jsm"
);
var { MailServices } = ChromeUtils.import(
"resource:///modules/MailServices.jsm"
);
var { mc } = ChromeUtils.import(
"resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
);
var gPopAccount, gOriginalAccountCount;
add_setup(function () {
// There may be pre-existing accounts from other tests.
gOriginalAccountCount = MailServices.accounts.allServers.length;
// Create a POP server
let popServer = MailServices.accounts
.createIncomingServer("nobody", "foo.invalid", "pop3")
.QueryInterface(Ci.nsIPop3IncomingServer);
let identity = MailServices.accounts.createIdentity();
identity.email = "tinderbox@foo.invalid";
gPopAccount = MailServices.accounts.createAccount();
gPopAccount.incomingServer = popServer;
gPopAccount.addIdentity(identity);
// Now there should be one more account.
Assert.equal(
MailServices.accounts.allServers.length,
gOriginalAccountCount + 1
);
});
registerCleanupFunction(function () {
if (gPopAccount) {
// Remove our test account to leave the profile clean.
MailServices.accounts.removeAccount(gPopAccount);
gPopAccount = null;
}
// There should be only the original accounts left.
Assert.equal(MailServices.accounts.allServers.length, gOriginalAccountCount);
});
add_task(async function test_account_open_state() {
await open_advanced_settings(async function (tab) {
await subtest_check_account_order(tab);
});
});
/**
* Check the order of the accounts.
*
* @param {object} tab - The account manager tab.
*/
async function subtest_check_account_order(tab) {
let accountRow = get_account_tree_row(gPopAccount.key, null, tab);
click_account_tree_row(tab, accountRow);
let prevAccountList = MailServices.accounts.accounts.map(
account => account.key
);
// Moving the account up to reorder.
EventUtils.synthesizeKey("VK_UP", { altKey: true });
await new Promise(resolve => setTimeout(resolve));
let curAccountList = MailServices.accounts.accounts.map(
account => account.key
);
Assert.notEqual(curAccountList.join(), prevAccountList.join());
// Moving the account down, back to the starting position.
EventUtils.synthesizeKey("VK_DOWN", { altKey: true });
await new Promise(resolve => setTimeout(resolve));
curAccountList = MailServices.accounts.accounts.map(account => account.key);
Assert.equal(curAccountList.join(), prevAccountList.join());
}
|