41 var
histsvc =
Cc[
"@mozilla.org/browser/nav-history-service;1"].getService(
Ci.nsINavHistoryService);
43 do_throw(
"Could not get nav-history-service\n");
48 var
bmsvc =
Cc[
"@mozilla.org/browser/nav-bookmarks-service;1"].getService(
Ci.nsINavBookmarksService);
50 do_throw(
"Could not get nav-bookmarks-service\n");
55 var annosvc =
Cc[
"@mozilla.org/browser/annotation-service;1"].getService(
Ci.nsIAnnotationService);
57 do_throw(
"Could not get annotation service\n");
62 var livemarksvc =
Cc[
"@mozilla.org/browser/livemark-service;2"].getService(
Ci.nsILivemarkService);
64 do_throw(
"Could not get livemark service\n");
69 var iconsvc =
Cc[
"@mozilla.org/browser/favicon-service;1"].getService(
Ci.nsIFaviconService);
71 do_throw(
"Could not get favicon service\n");
76 var mssvc =
Cc[
"@mozilla.org/microsummary/service;1"].getService(
Ci.nsIMicrosummaryService);
78 do_throw(
"Could not get microsummary service\n");
83 var
iosvc =
Cc[
"@mozilla.org/network/io-service;1"].getService(
Ci.nsIIOService);
85 do_throw(
"Could not get io service\n");
93 const TEST_FAVICON_DATA_URL =
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAHWSURBVHjaYvz//z8DJQAggJiQOe/fv2fv7Oz8rays/N+VkfG/iYnJfyD/1+rVq7ffu3dPFpsBAAHEAHIBCJ85c8bN2Nj4vwsDw/8zQLwKiO8CcRoQu0DxqlWrdsHUwzBAAIGJmTNnPgYa9j8UqhFElwPxf2MIDeIrKSn9FwSJoRkAEEAM0DD4DzMAyPi/G+QKY4hh5WAXGf8PDQ0FGwJ22d27CjADAAIIrLmjo+MXA9R2kAHvGBA2wwx6B8W7od6CeQcggKCmCEL8bgwxYCbUIGTDVkHDBia+CuotgACCueD3TDQN75D4xmAvCoK9ARMHBzAw0AECiBHkAlC0Mdy7x9ABNA3obAZXIAa6iKEcGlMVQHwWyjYuL2d4v2cPg8vZswx7gHyAAAK7AOif7SAbOqCmn4Ha3AHFsIDtgPq/vLz8P4MSkJ2W9h8ggBjevXvHDo4FQUQg/kdypqCg4H8lUIACnQ/SOBMYI8bAsAJFPcj1AAEEjwVQqLpAbXmH5BJjqI0gi9DTAAgDBBCcAVLkgmQ7yKCZxpCQxqUZhAECCJ4XgMl493ug21ZD+aDAXH0WLM4A9MZPXJkJIIAwTAR5pQMalaCABQUULttBGCCAGCnNzgABBgAMJ5THwGvJLAAAAABJRU5ErkJggg==";
98 var
importer =
Cc[
"@mozilla.org/browser/places/import-export-service;1"].getService(
Ci.nsIPlacesImportExportService);
101 Cc[
"@mozilla.org/preferences-service;1"].getService(
Ci.nsIPrefBranch).
102 setIntPref(
"browser.places.smartBookmarksVersion", -1);
105 var bookmarksFileOld = do_get_file(
"bookmarks.preplaces.html");
107 var bookmarksFileNew =
dirSvc.get(
"ProfD",
Ci.nsILocalFile);
108 bookmarksFileNew.append(
"bookmarks.exported.html");
111 if (bookmarksFileNew.exists())
112 bookmarksFileNew.remove(
false);
113 bookmarksFileNew.create(
Ci.nsILocalFile.NORMAL_FILE_TYPE, 0600);
114 if (!bookmarksFileNew.exists())
115 do_throw(
"couldn't create file: bookmarks.exported.html");
122 importer.importHTMLFromFile(bookmarksFileOld,
true);
123 }
catch(ex) { do_throw(
"couldn't import legacy bookmarks file: " + ex); }
132 importer.exportHTMLToFile(bookmarksFileNew);
133 }
catch(ex) { do_throw(
"couldn't export to file: " + ex); }
134 bmsvc.removeFolderChildren(bmsvc.bookmarksMenuFolder);
135 bmsvc.removeFolderChildren(bmsvc.toolbarFolder);
137 importer.importHTMLFromFile(bookmarksFileNew,
true);
138 }
catch(ex) { do_throw(
"couldn't import the exported file: " + ex); }
201 var query =
histsvc.getNewQuery();
202 query.setFolders([aFolder], 1);
203 var result =
histsvc.executeQuery(query,
histsvc.getNewQueryOptions());
204 var rootNode = result.root;
205 rootNode.containerOpen =
true;
213 do_check_eq(testFolder.type, testFolder.RESULT_TYPE_FOLDER);
217 do_check_eq(bmsvc.getItemDateAdded(testFolder.itemId)/1000000, 1177541020);
219 do_check_eq(bmsvc.getItemLastModified(testFolder.itemId)/1000000, 1177541050);
221 testFolder = testFolder.QueryInterface(
Ci.nsINavHistoryQueryResultNode);
224 do_check_true(annosvc.itemHasAnnotation(testFolder.itemId,
229 testFolder.containerOpen =
true;
230 var cc = testFolder.childCount;
236 var testBookmark1 = testFolder.getChild(0);
238 do_check_eq(
"http://test/post", testBookmark1.uri);
240 do_check_eq(
"test post keyword", testBookmark1.title);
242 do_check_eq(
"test", bmsvc.getKeywordForBookmark(testBookmark1.itemId));
244 do_check_true(annosvc.itemHasAnnotation(testBookmark1.itemId,
247 do_check_eq(testBookmark1.dateAdded/1000000, 1177375336);
250 do_check_eq(testBookmark1.lastModified/1000000, 1177375423);
253 do_check_true(annosvc.itemHasAnnotation(testBookmark1.itemId,
259 var testURI =
uri(testBookmark1.uri);
263 do_check_true(annosvc.itemHasAnnotation(testBookmark1.itemId,
266 annosvc.getItemAnnotation(testBookmark1.itemId,
287 testFolder.containerOpen =
false;
288 rootNode.containerOpen =
false;
290 query.setFolders([bmsvc.toolbarFolder], 1);
291 result =
histsvc.executeQuery(query,
histsvc.getNewQueryOptions());
293 var toolbar = result.root;
294 toolbar.containerOpen =
true;
298 var livemark = toolbar.getChild(1);
302 do_check_true(livemarksvc.isLivemark(livemark.itemId));
304 do_check_eq(
"http://en-us.fxfeeds.mozilla.com/en-US/firefox/livebookmarks/",
305 livemarksvc.getSiteURI(livemark.itemId).spec);
307 do_check_eq(
"http://en-us.fxfeeds.mozilla.com/en-US/firefox/headlines.xml",
308 livemarksvc.getFeedURI(livemark.itemId).spec);
310 toolbar.containerOpen =
false;
313 query.setFolders([bmsvc.unfiledBookmarksFolder], 1);
314 result =
histsvc.executeQuery(query,
histsvc.getNewQueryOptions());
315 var unfiledBookmarks = result.root;
316 unfiledBookmarks.containerOpen =
true;
318 unfiledBookmarks.containerOpen =
false;
322 var dataURL = iconsvc.getFaviconDataAsDataURL(faviconURI);
do_check_eq(typeof PlacesUtils,"object")
const TEST_FAVICON_PAGE_URL
const TEST_FAVICON_DATA_URL
const LOAD_IN_SIDEBAR_ANNO
function testCanonicalBookmarks(aFolder)