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
|
/**
* Tests the LoginHelper object.
*/
"use strict";
Cu.import("resource://gre/modules/Task.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "LoginHelper",
"resource://gre/modules/LoginHelper.jsm");
function* createSignonFile(singon) {
let {file, pref} = singon;
if (pref) {
Services.prefs.setCharPref(pref, file);
}
yield OS.File.writeAtomic(
OS.Path.join(OS.Constants.Path.profileDir, file), new Uint8Array(1));
}
function* isSignonClear(singon) {
const {file, pref} = singon;
const fileExists = yield OS.File.exists(
OS.Path.join(OS.Constants.Path.profileDir, file));
if (pref) {
try {
Services.prefs.getCharPref(pref);
return false;
} catch (e) {}
}
return !fileExists;
}
add_task(function* test_remove_lagecy_signonfile() {
// In the last test case, signons3.txt being deleted even when
// it doesn't exist.
const signonsSettings = [[
{ file: "signons.txt" },
{ file: "signons2.txt" },
{ file: "signons3.txt" }
], [
{ file: "signons.txt", pref: "signon.SignonFileName" },
{ file: "signons2.txt", pref: "signon.SignonFileName2" },
{ file: "signons3.txt", pref: "signon.SignonFileName3" }
], [
{ file: "signons2.txt" },
{ file: "singons.txt", pref: "signon.SignonFileName" },
{ file: "customized2.txt", pref: "signon.SignonFileName2" },
{ file: "customized3.txt", pref: "signon.SignonFileName3" }
]];
for (let setting of signonsSettings) {
for (let singon of setting) {
yield createSignonFile(singon);
}
LoginHelper.removeLegacySignonFiles();
for (let singon of setting) {
equal(yield isSignonClear(singon), true);
}
}
});
|