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
|
/* 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 an address book, once renamed, is not deleted when a sibling address book is deleted.
*/
function addDirectory(dirName) {
let dirPrefId = MailServices.ab.newAddressBook(dirName, "", kPABData.dirType);
return MailServices.ab.getDirectoryFromId(dirPrefId);
}
function renameDirectory(directory, newName) {
directory.dirName = newName;
}
/**
* Create 4 addressbooks (directories). Rename the second one and delete
* the third one. Check if their names are still correct. (bug 745664)
*/
async function run_test() {
let dirNames = ["testAb0", "testAb1", "testAb2", "testAb3"];
let directories = [];
for (let dirName of dirNames) {
directories.push(addDirectory(dirName));
}
dirNames[1] = "newTestAb1";
renameDirectory(directories[1], dirNames[1]);
for (let dir in dirNames) {
Assert.equal(dirNames[dir], directories[dir].dirName);
}
await promiseDirectoryRemoved(directories[2].URI);
dirNames.splice(2, 1);
directories.splice(2, 1);
for (let dir in dirNames) {
Assert.equal(dirNames[dir], directories[dir].dirName);
}
}
|