42 const Cc = Components.classes;
43 const Ci = Components.interfaces;
51 ok(PlacesUtils,
"PlacesUtils in context");
55 var
ww =
Cc[
"@mozilla.org/embedcomp/window-watcher;1"].
59 if (aTopic ===
"domwindowopened") {
60 ww.unregisterNotification(
this);
61 gLibrary = aSubject.QueryInterface(
Ci.nsIDOMWindow);
69 ww.registerNotification(windowObserver);
71 "chrome://browser/content/places/places.xul",
73 "chrome,toolbar=yes,dialog=no,resizable",
81 var
bs = PlacesUtils.bookmarks;
84 var addedBookmarks = [];
87 ok(
true,
"*** Acting on menu bookmarks");
88 var
id = bs.insertBookmark(bs.bookmarksMenuFolder,
89 PlacesUtils._uri(
"http://bm1.mozilla.org/"),
92 addedBookmarks.push(
id);
93 id = bs.insertBookmark(bs.bookmarksMenuFolder,
94 PlacesUtils._uri(
"place:"),
97 addedBookmarks.push(
id);
98 id = bs.insertSeparator(bs.bookmarksMenuFolder, bs.DEFAULT_INDEX);
99 addedBookmarks.push(
id);
100 id = bs.createFolder(bs.bookmarksMenuFolder,
103 addedBookmarks.push(
id);
104 id = bs.insertBookmark(
id,
105 PlacesUtils._uri(
"http://bmf1.mozilla.org/"),
108 addedBookmarks.push(
id);
109 bs.moveItem(
id, bs.bookmarksMenuFolder, 0);
112 ok(
true,
"*** Acting on toolbar bookmarks");
113 bs.insertBookmark(bs.toolbarFolder,
114 PlacesUtils._uri(
"http://tb1.mozilla.org/"),
117 addedBookmarks.push(
id);
118 id = bs.insertBookmark(bs.toolbarFolder,
119 PlacesUtils._uri(
"place:"),
122 addedBookmarks.push(
id);
123 id = bs.insertSeparator(bs.toolbarFolder, bs.DEFAULT_INDEX);
124 addedBookmarks.push(
id);
125 id = bs.createFolder(bs.toolbarFolder,
128 addedBookmarks.push(
id);
129 id = bs.insertBookmark(
id,
130 PlacesUtils._uri(
"http://tbf1.mozilla.org/"),
133 addedBookmarks.push(
id);
134 bs.moveItem(
id, bs.toolbarFolder, 0);
137 ok(
true,
"*** Acting on unsorted bookmarks");
138 id = bs.insertBookmark(bs.unfiledBookmarksFolder,
139 PlacesUtils._uri(
"http://ub1.mozilla.org/"),
142 addedBookmarks.push(
id);
143 id = bs.insertBookmark(bs.unfiledBookmarksFolder,
144 PlacesUtils._uri(
"place:"),
147 addedBookmarks.push(
id);
148 id = bs.insertSeparator(bs.unfiledBookmarksFolder, bs.DEFAULT_INDEX);
149 addedBookmarks.push(
id);
150 id = bs.createFolder(bs.unfiledBookmarksFolder,
153 addedBookmarks.push(
id);
154 id = bs.insertBookmark(
id,
155 PlacesUtils._uri(
"http://ubf1.mozilla.org/"),
158 addedBookmarks.push(
id);
159 bs.moveItem(
id, bs.unfiledBookmarksFolder, 0);
162 addedBookmarks.forEach(
function (aItem) {
166 bs.removeItem(aItem);
190 if (aIID.equals(
Ci.nsINavBookmarkObserver) ||
191 aIID.equals(
Ci.nsISupports))
193 throw Cr.NS_NOINTERFACE;
197 onItemAdded:
function PSB_onItemAdded(aItemId, aFolderId, aIndex) {
202 var type = PlacesUtils.bookmarks.getItemType(aItemId);
204 case PlacesUtils.bookmarks.TYPE_BOOKMARK:
205 var uriString = PlacesUtils.bookmarks.getBookmarkURI(aItemId).spec;
206 var isQuery = uriString.substr(0, 6) ==
"place:";
208 isnot(node,
null,
"Found new Places node in left pane");
209 ok(index >= 0,
"Node is at index " + index);
213 case PlacesUtils.bookmarks.TYPE_SEPARATOR:
214 is(node,
null,
"New Places node not added in left pane");
217 isnot(node,
null,
"Found new Places node in left pane");
218 ok(index >= 0,
"Node is at index " + index);
222 onItemRemoved:
function PSB_onItemRemoved(aItemId, aFolder, aIndex) {
226 is(node,
null,
"Places node not found in left pane");
229 onItemMoved:
function(aItemId,
230 aOldFolderId, aOldIndex,
231 aNewFolderId, aNewIndex) {
236 var type = PlacesUtils.bookmarks.getItemType(aItemId);
238 case PlacesUtils.bookmarks.TYPE_BOOKMARK:
239 var uriString = PlacesUtils.bookmarks.getBookmarkURI(aItemId).spec;
240 var isQuery = uriString.substr(0, 6) ==
"place:";
242 isnot(node,
null,
"Found new Places node in left pane");
243 ok(index >= 0,
"Node is at index " + index);
247 case type == PlacesUtils.bookmarks.TYPE_SEPARATOR:
248 is(node,
null,
"New Places node not added in left pane");
251 isnot(node,
null,
"Found new Places node in left pane");
252 ok(index >= 0,
"Node is at index " + index);
258 onBeforeItemRemoved:
function PSB_onBeforeItemRemoved(aItemId) {},
259 onItemVisited:
function() {},
260 onItemChanged:
function PSB_onItemChanged(aItemId, aProperty,
261 aIsAnnotationProperty,
aValue) {}
274 function findNode(aContainerIndex) {
275 if (aTree.view.isContainerEmpty(aContainerIndex))
280 for (var
i = aContainerIndex + 1;
i < aTree.view.rowCount;
i++) {
281 var
node = aTree.view.nodeForTreeIndex(
i);
283 if (node.itemId == aItemId) {
285 return [
node,
i - aTree.view.getParentIndex(
i) - 1];
288 if (PlacesUtils.nodeIsFolder(node)) {
290 aTree.view.toggleOpenState(
i);
292 var foundNode = findNode(
i);
294 aTree.view.toggleOpenState(
i);
296 if (foundNode[0] != null)
301 if (!aTree.view.hasNextSibling(aContainerIndex + 1,
i))
308 for (var
i = 0;
i < aTree.view.rowCount;
i++) {
310 aTree.view.toggleOpenState(
i);
312 var foundNode = findNode(
i);
314 aTree.view.toggleOpenState(
i);
316 if (foundNode[0] !=
null)
onPageChanged onEndUpdateBatch
sbOSDControlService prototype QueryInterface
getService(Ci.sbIFaceplateManager)
onPageChanged onBeginUpdateBatch
function getNodeForTreeItem(aItemId, aTree)
_getSelectedPageStyle s i
_updateTextAndScrollDataForFrame aData
sbDeviceFirmwareAutoCheckForUpdate prototype observe