40 ok(PlacesUtils,
"checking PlacesUtils, running in chrome context?");
41 ok(
PlacesUIUtils,
"checking PlacesUIUtils, running in chrome context?");
44 const IDX = PlacesUtils.bookmarks.DEFAULT_INDEX;
47 var rootId = PlacesUtils.bookmarks.createFolder(PlacesUtils.toolbarFolderId,
"", IDX);
48 var rootNode = PlacesUtils.getFolderContents(rootId,
false,
true).root;
49 is(rootNode.childCount, 0,
"confirm test root is empty");
57 PlacesUtils.bookmarks.createFolder(rootId,
"", IDX);
60 is(rootNode.childCount, 1,
61 "populate added data to the test root");
63 true,
"can move regular folder id");
65 true,
"can move regular folder node");
73 PlacesUtils.bookmarks.createFolder(rootId,
"foo", IDX);
75 PlacesUtils.bookmarks.insertBookmark(rootId,
makeURI(
"place:folder="+this.folderId), IDX,
"bar");
78 is(rootNode.childCount, 2,
79 "populated data to the test root");
81 var folderNode = rootNode.getChild(0);
82 is(folderNode.type, 6,
"node is folder");
83 is(this.folderId, folderNode.itemId,
"folder id and folder node item id match");
85 var shortcutNode = rootNode.getChild(1);
86 is(shortcutNode.type, 9,
"node is folder shortcut");
87 is(this.shortcutId, shortcutNode.itemId,
"shortcut id and shortcut node item id match");
89 var concreteId = PlacesUtils.getConcreteItemId(shortcutNode);
90 is(concreteId, folderNode.itemId,
"shortcut node id and concrete id match");
93 true,
"can move folder shortcut id");
96 true,
"can move folder shortcut node");
104 PlacesUtils.bookmarks.insertBookmark(rootId,
makeURI(
"http://foo.com"), IDX,
"foo");
106 PlacesUtils.bookmarks.insertBookmark(rootId,
makeURI(
"place:terms=foo"), IDX,
"bar");
109 is(rootNode.childCount, 2,
110 "populated data to the test root");
112 var bmNode = rootNode.getChild(0);
113 is(bmNode.itemId,
this.bookmarkId,
"bookmark id and bookmark node item id match");
115 var queryNode = rootNode.getChild(1);
116 is(queryNode.itemId,
this.queryId,
"query id and query node item id match");
119 true,
"can move query id");
122 true,
"can move query node");
129 folders: [PlacesUtils.bookmarksMenuFolderId,
130 PlacesUtils.tagsFolderId, PlacesUtils.unfiledBookmarksFolderId,
131 PlacesUtils.toolbarFolderId],
134 for (var
i = 0;
i < this.folders.length;
i++) {
135 var
id = this.folders[
i];
137 PlacesUtils.bookmarks.insertBookmark(rootId,
makeURI(
"place:folder=" +
id), IDX,
"");
142 is(rootNode.childCount,
this.folders.length,
143 "populated data to the test root");
145 function getRootChildNode(aId) {
146 var
node = PlacesUtils.getFolderContents(PlacesUtils.placesRootId,
false,
true).root;
147 for (var
i = 0;
i < node.childCount;
i++) {
148 var child = node.getChild(
i);
149 if (child.itemId == aId) {
150 node.containerOpen =
false;
154 node.containerOpen =
false;
155 throw(
"Unable to find child node");
159 for (var
i = 0;
i < this.folders.length;
i++) {
160 var
id = this.folders[
i];
163 false,
"shouldn't be able to move special folder id");
165 var
node = getRootChildNode(
id);
166 isnot(node,
null,
"Node found");
168 false,
"shouldn't be able to move special folder node");
170 var shortcutId = this.shortcuts[
id];
171 var shortcutNode = rootNode.getChild(
i);
173 is(shortcutNode.itemId, shortcutId,
"shortcut id and shortcut node item id match");
175 LOG(
"can move shortcut id?");
177 true,
"should be able to move special folder shortcut id");
179 LOG(
"can move shortcut node?");
181 true,
"should be able to move special folder shortcut node");
191 PlacesUtils.tagging.tagURI(this.
uri, [
"bar"]);
195 var query = PlacesUtils.history.getNewQuery();
196 var
options = PlacesUtils.history.getNewQueryOptions();
197 options.resultType =
Ci.nsINavHistoryQueryOptions.RESULTS_AS_TAG_QUERY;
198 var tagsNode = PlacesUtils.history.executeQuery(query, options).root;
200 tagsNode.containerOpen =
true;
201 is(tagsNode.childCount, 1,
"has new tag");
203 var tagNode = tagsNode.getChild(0);
206 false,
"should not be able to move tag container node");
208 tagsNode.containerOpen =
false;
216 PlacesUtils.bookmarks.createFolder(rootId,
"foo", IDX);
217 PlacesUtils.bookmarks.createFolder(this.
id,
"bar", IDX);
218 PlacesUtils.bookmarks.setFolderReadonly(this.
id,
true);
221 is(rootNode.childCount, 1,
222 "populate added data to the test root");
223 var readOnlyFolder = rootNode.getChild(0);
227 true,
"can move read-only folder id");
229 true,
"can move read-only folder node");
232 readOnlyFolder.QueryInterface(
Ci.nsINavHistoryContainerResultNode);
233 readOnlyFolder.containerOpen =
true;
234 var childFolder = readOnlyFolder.getChild(0);
237 false,
"cannot move a child of a read-only folder");
239 false,
"cannot move a child node of a read-only folder node");
243 tests.forEach(
function(aTest) {
244 PlacesUtils.bookmarks.removeFolderChildren(rootId);
249 PlacesUtils.bookmarks.removeItem(rootId);
function populate(aFolderId)
function makeURI(aURLSpec, aCharset)
var PlacesControllerDragHelper
_getSelectedPageStyle s i