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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
add_task(async function test_untitled_visited_bookmark() {
let fxURI = uri("http://getfirefox.com");
await PlacesUtils.history.insert({
url: fxURI,
title: "Get Firefox!",
visits: [
{
date: new Date(),
transition: PlacesUtils.history.TRANSITIONS.TYPED,
},
],
});
let { root: node } = PlacesUtils.getFolderContents(
PlacesUtils.bookmarks.toolbarGuid
);
try {
let fxBmk = await PlacesUtils.bookmarks.insert({
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
url: fxURI,
});
strictEqual(fxBmk.title, "", "Visited bookmark should not have title");
await PlacesTestUtils.promiseAsyncUpdates();
let fxBmkId = await PlacesTestUtils.promiseItemId(fxBmk.guid);
strictEqual(
PlacesUtils.bookmarks.getItemTitle(fxBmkId),
"",
"Should return empty string for untitled visited bookmark"
);
let fxBmkNode = node.getChild(0);
equal(fxBmkNode.itemId, fxBmkId, "Visited bookmark ID should match");
strictEqual(
fxBmkNode.title,
"",
"Visited bookmark node should not have title"
);
} finally {
node.containerOpen = false;
}
await PlacesUtils.bookmarks.eraseEverything();
});
add_task(async function test_untitled_unvisited_bookmark() {
let tbURI = uri("http://getthunderbird.com");
let { root: node } = PlacesUtils.getFolderContents(
PlacesUtils.bookmarks.toolbarGuid
);
try {
let tbBmk = await PlacesUtils.bookmarks.insert({
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
url: tbURI,
});
strictEqual(tbBmk.title, "", "Unvisited bookmark should not have title");
await PlacesTestUtils.promiseAsyncUpdates();
let tbBmkId = await PlacesTestUtils.promiseItemId(tbBmk.guid);
strictEqual(
PlacesUtils.bookmarks.getItemTitle(tbBmkId),
"",
"Should return empty string for untitled unvisited bookmark"
);
let tbBmkNode = node.getChild(0);
equal(tbBmkNode.itemId, tbBmkId, "Unvisited bookmark ID should match");
strictEqual(
tbBmkNode.title,
"",
"Unvisited bookmark node should not have title"
);
} finally {
node.containerOpen = false;
}
await PlacesUtils.bookmarks.eraseEverything();
});
add_task(async function test_untitled_folder() {
let { root: node } = PlacesUtils.getFolderContents(
PlacesUtils.bookmarks.toolbarGuid
);
try {
let folder = await PlacesUtils.bookmarks.insert({
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
type: PlacesUtils.bookmarks.TYPE_FOLDER,
});
await PlacesTestUtils.promiseAsyncUpdates();
let folderId = await PlacesTestUtils.promiseItemId(folder.guid);
strictEqual(
PlacesUtils.bookmarks.getItemTitle(folderId),
"",
"Should return empty string for untitled folder"
);
let folderNode = node.getChild(0);
equal(folderNode.itemId, folderId, "Folder ID should match");
strictEqual(folderNode.title, "", "Folder node should not have title");
} finally {
node.containerOpen = false;
}
await PlacesUtils.bookmarks.eraseEverything();
});
|