40 ok(PlacesUtils,
"checking PlacesUtils, running in chrome context?");
41 ok(
PlacesUIUtils,
"checking PlacesUIUtils, running in chrome context?");
53 var toolbarId = PlacesUtils.toolbarFolderId;
54 var toolbarNode = PlacesUtils.getFolderContents(toolbarId).root;
56 var oldCount = toolbarNode.childCount;
57 var testRootId = PlacesUtils.bookmarks.createFolder(toolbarId,
"test root", -1);
58 is(toolbarNode.childCount, oldCount+1,
"confirm test root node is a container, and is empty");
59 var testRootNode = toolbarNode.getChild(toolbarNode.childCount-1);
61 testRootNode.containerOpen =
true;
62 is(testRootNode.childCount, 0,
"confirm test root node is a container, and is empty");
65 var folderAId = PlacesUtils.bookmarks.createFolder(testRootId,
"A", -1);
66 PlacesUtils.bookmarks.insertBookmark(folderAId, PlacesUtils._uri(
"http://foo"),
68 PlacesUtils.bookmarks.insertSeparator(folderAId, -1);
69 PlacesUtils.livemarks.createLivemarkFolderOnly(folderAId,
"test livemark",
70 PlacesUtils._uri(
"http://test"),
71 PlacesUtils._uri(
"http://test"), -1);
73 var folderANode = testRootNode.getChild(0);
74 var folderAGUIDs =
getGUIDs(folderANode);
77 ok(
checkGUIDs(folderANode, folderAGUIDs,
true),
"confirm guid test works");
80 var serializedNode = PlacesUtils.wrapNode(folderANode, PlacesUtils.TYPE_X_MOZ_PLACE_CONTAINER);
81 var rawNode = PlacesUtils.unwrapNodes(serializedNode, PlacesUtils.TYPE_X_MOZ_PLACE_CONTAINER).shift();
82 ok(rawNode.type,
"confirm json node was made");
87 PlacesUtils.TYPE_X_MOZ_PLACE_CONTAINER,
88 testRootId, -1,
true);
89 ok(transaction,
"create transaction");
93 is(testRootNode.childCount, 2,
"create test folder via copy");
96 var folderBNode = testRootNode.getChild(1);
97 ok(
checkGUIDs(folderBNode, folderAGUIDs,
false),
"confirm folder A GUIDs don't match folder B GUIDs");
98 var folderBGUIDs =
getGUIDs(folderBNode);
99 ok(
checkGUIDs(folderBNode, folderBGUIDs,
true),
"confirm test of new GUIDs");
103 is(testRootNode.childCount, 1,
"confirm undo removed the copied folder");
108 is(testRootNode.childCount, 2,
"confirm redo re-copied the folder");
109 folderBNode = testRootNode.getChild(1);
110 ok(
checkGUIDs(folderBNode, folderAGUIDs,
false),
"folder B GUIDs after undo/redo don't match folder A GUIDs");
111 ok(
checkGUIDs(folderBNode, folderBGUIDs,
true),
"folder B GUIDs after under/redo should match pre-undo/redo folder B GUIDs");
114 testRootNode.containerOpen =
false;
115 toolbarNode.containerOpen =
false;
119 PlacesUtils.bookmarks.removeItem(testRootId);
124 aNode.containerOpen =
true;
126 folder: PlacesUtils.bookmarks.getItemGUID(aNode.itemId),
127 bookmark: PlacesUtils.bookmarks.getItemGUID(aNode.getChild(0).itemId),
128 separator: PlacesUtils.bookmarks.getItemGUID(aNode.getChild(1).itemId),
129 livemark: PlacesUtils.bookmarks.getItemGUID(aNode.getChild(2).itemId)
131 aNode.containerOpen =
false;
137 function check(aNode, aGUID, aEquals) {
138 var nodeGUID = PlacesUtils.bookmarks.getItemGUID(aNode.itemId);
139 return aEquals ? (nodeGUID == aGUID) : (nodeGUID != aGUID);
143 aFolderNode.containerOpen =
true;
145 var allMatch =
check(aFolderNode, aGUIDs.folder, aShouldMatch) &&
146 check(aFolderNode.getChild(0), aGUIDs.bookmark, aShouldMatch) &&
147 check(aFolderNode.getChild(1), aGUIDs.separator, aShouldMatch) &&
148 check(aFolderNode.getChild(2), aGUIDs.livemark, aShouldMatch);
150 aFolderNode.containerOpen =
false;
function checkGUIDs(aFolderNode, aGUIDs, aShouldMatch)
function asContainer(aNode)