1 const Ci = Components.interfaces;
2 const Cc = Components.classes;
8 var
ios =
Cc[
"@mozilla.org/network/io-service;1"].getService(
Ci.nsIIOService);
15 ok(tags,
"Check access to bookmark tags root");
16 ok(!tags.parent,
"Check tags parent (should be null)");
22 ok(unfiled,
"Check access to bookmark unfiled root");
23 ok(!unfiled.parent,
"Check unfiled parent (should be null)");
29 ok(toolbar,
"Check access to bookmark toolbar root");
30 ok(!toolbar.parent,
"Check toolbar parent (should be null)");
32 var toolbarKidCount = toolbar.children.length;
35 var testFolderToolbar = toolbar.addFolder(
"FUEL in Toolbar");
36 ok(testFolderToolbar,
"Check folder creation");
37 is(testFolderToolbar.type,
"folder",
"Check 'folder.type' after creation");
38 ok(testFolderToolbar.parent,
"Check parent after folder creation");
41 is(toolbar.children.length, toolbarKidCount,
"Check toolbar folder child count after adding a child folder");
47 ok(root,
"Check access to bookmark root");
48 ok(!root.parent,
"Check root parent (should be null)");
50 var rootKidCount = root.children.length;
54 ok(testFolder,
"Check folder creation");
55 is(testFolder.type,
"folder",
"Check 'folder.type' after creation");
56 ok(testFolder.parent,
"Check parent after folder creation");
59 is(root.children.length, rootKidCount,
"Check root folder child count after adding a child folder");
63 testFolder.description =
"FUEL folder";
64 is(testFolder.description,
"FUEL folder",
"Check setting 'folder.description'");
65 is(
gLastFolderAction,
"bookmarkProperties/description",
"Check event handler for setting 'folder.description'");
67 testFolder.title =
"fuel-is-cool";
68 is(testFolder.title,
"fuel-is-cool",
"Check setting 'folder.title'");
71 testFolder.annotations.set(
"testing/folder",
"annotate-this", 0);
72 ok(testFolder.annotations.has(
"testing/folder"),
"Checking existence of added annotation");
73 is(
gLastFolderAction,
"testing/folder",
"Check event handler for setting annotation");
75 is(testFolder.annotations.get(
"testing/folder"),
"annotate-this",
"Checking existence of added annotation");
76 testFolder.annotations.remove(
"testing/folder");
77 ok(!testFolder.annotations.has(
"testing/folder"),
"Checking existence of removed annotation");
78 is(
gLastFolderAction,
"testing/folder",
"Check event handler for removing annotation");
84 var testBookmark = testFolder.addBookmark(
"Mozilla",
url(
"http://www.mozilla.com/"));
85 ok(testBookmark,
"Check bookmark creation");
86 ok(testBookmark.parent,
"Check parent after bookmark creation");
87 is(
gLastFolderAction,
"addchild",
"Check event handler for adding a child to a folder");
88 is(testBookmark.type,
"bookmark",
"Check 'bookmark.type' after creation");
89 is(testBookmark.title,
"Mozilla",
"Check 'bookmark.title' after creation");
90 is(testBookmark.uri.spec,
"http://www.mozilla.com/",
"Check 'bookmark.uri' after creation");
92 is(testFolder.children.length, 1,
"Check test folder child count after adding a child bookmark");
96 testBookmark.description =
"mozcorp";
97 is(testBookmark.description,
"mozcorp",
"Check setting 'bookmark.description'");
98 is(
gLastBookmarkAction,
"bookmarkProperties/description",
"Check event handler for setting 'bookmark.description'");
100 testBookmark.keyword =
"moz"
101 is(testBookmark.keyword,
"moz",
"Check setting 'bookmark.keyword'");
104 testBookmark.title =
"MozCorp"
105 is(testBookmark.title,
"MozCorp",
"Check setting 'bookmark.title'");
108 testBookmark.uri =
url(
"http://www.mozilla.org/");
109 is(testBookmark.uri.spec,
"http://www.mozilla.org/",
"Check setting 'bookmark.uri'");
113 testBookmark.annotations.set(
"testing/bookmark",
"annotate-this", 0);
114 ok(testBookmark.annotations.has(
"testing/bookmark"),
"Checking existence of added annotation");
117 is(testBookmark.annotations.get(
"testing/bookmark"),
"annotate-this",
"Checking existence of added annotation");
118 testBookmark.annotations.remove(
"testing/bookmark");
119 ok(!testBookmark.annotations.has(
"testing/bookmark"),
"Checking existence of removed annotation");
120 is(
gLastBookmarkAction,
"testing/bookmark",
"Check event handler for removing annotation");
121 is(testBookmark.annotations.get(
"testing/bookmark"),
null,
"Check existence of a missing annotation");
124 testBookmark.annotations.set(
"testing/bookmark/string",
"annotate-this", 0);
125 ok(testBookmark.annotations.has(
"testing/bookmark/string"),
"Checking existence of added string annotation");
126 is(testBookmark.annotations.get(
"testing/bookmark/string"),
"annotate-this",
"Checking value of added string annotation");
127 is(
gLastBookmarkAction,
"testing/bookmark/string",
"Check event handler for setting annotation");
129 testBookmark.annotations.set(
"testing/bookmark/int", 100, 0);
130 ok(testBookmark.annotations.has(
"testing/bookmark/int"),
"Checking existence of added integer annotation");
131 is(testBookmark.annotations.get(
"testing/bookmark/int"), 100,
"Checking value of added integer annotation");
132 is(
gLastBookmarkAction,
"testing/bookmark/int",
"Check event handler for setting annotation");
134 testBookmark.annotations.set(
"testing/bookmark/double", 3.333, 0);
135 ok(testBookmark.annotations.has(
"testing/bookmark/double"),
"Checking existence of added double annotation");
136 is(testBookmark.annotations.get(
"testing/bookmark/double"), 3.333,
"Checking value of added double annotation");
137 is(
gLastBookmarkAction,
"testing/bookmark/double",
"Check event handler for setting annotation");
141 var names = testBookmark.annotations.names;
142 is(names[1],
"testing/bookmark/string",
"Checking contents of annotation names array");
143 is(names.length, 4,
"Checking the annotation names array after adding 3 annotations");
146 var testSeparator = testFolder.addSeparator();
147 ok(testSeparator,
"Check bookmark creation");
148 ok(testSeparator.parent,
"Check parent after separator creation");
149 is(
gLastFolderAction,
"addchild",
"Check event handler for adding a child separator to a folder");
150 is(testSeparator.type,
"separator",
"Check 'bookmark.type' after separator creation");
152 is(testFolder.children.length, 2,
"Check test folder child count after adding a child separator");
156 testSeparator.remove();
158 is(
gLastFolderAction,
"removechild",
"Check event handler for removing a child separator from a folder");
159 is(testFolder.children.length, 1,
"Check test folder child count after removing a child separator");
163 testBookmark.remove();
165 is(
gLastFolderAction,
"removechild",
"Check event handler for removing a child from a folder");
166 is(testFolder.children.length, 0,
"Check test folder child count after removing a child bookmark");
171 is(
gLastFolderAction,
"remove",
"Check event handler for removing child folder");
173 is(root.children.length, rootKidCount,
"Check root folder child count after removing a child folder");
176 var testFolderA = root.addFolder(
"folder-a");
177 var testFolderB = root.addFolder(
"folder-b");
179 var testMove = testFolderA.addBookmark(
"Mozilla",
url(
"http://www.mozilla.com/"));
181 is(testMove.parent.title,
"folder-a",
"Checking for new parent before moving bookmark");
183 testMove.parent = testFolderB;
184 is(testMove.parent.title,
"folder-b",
"Checking for new parent after moving bookmark");
189 testFolderA.parent = testFolderB;
190 is(testFolderA.parent.title,
"folder-b",
"Checking for new parent after moving folder");
function onFolderChange(evt)
function onFolderMove(evt)
function onBookmarkRemove(evt)
function onBookmarkMove(evt)
function onFolderRemove(evt)
function onFolderRemoveChild(evt)
function onBookmarkChange(evt)
function onFolderAddChild(evt)