41 Cc[
"@mozilla.org/browser/livemark-service;2"].getService(
Ci.nsILivemarkService);
42 Cc[
"@mozilla.org/feed-processor;1"].createInstance(
Ci.nsIFeedProcessor);
48 Components.utils.import(
"resource://gre/modules/utils.js");
66 var
importer =
Cc[
"@mozilla.org/browser/places/import-export-service;1"].getService(
Ci.nsIPlacesImportExportService);
69 Cc[
"@mozilla.org/preferences-service;1"].getService(
Ci.nsIPrefBranch).
70 setIntPref(
"browser.places.smartBookmarksVersion", -1);
74 var bookmarksFileOld = do_get_file(
"bookmarks.preplaces.html");
76 var jsonFile =
dirSvc.get(
"ProfD",
Ci.nsILocalFile);
77 jsonFile.append(
"bookmarks.exported.json");
80 if (jsonFile.exists())
81 jsonFile.remove(
false);
82 jsonFile.create(
Ci.nsILocalFile.NORMAL_FILE_TYPE, 0600);
83 if (!jsonFile.exists())
84 do_throw(
"couldn't create file: bookmarks.exported.json");
91 importer.importHTMLFromFile(bookmarksFileOld,
true);
92 }
catch(ex) { do_throw(
"couldn't import legacy bookmarks file: " + ex); }
102 PlacesUtils.backupBookmarksToFile(jsonFile);
103 }
catch(ex) { do_throw(
"couldn't export to file: " + ex); }
104 LOG(
"exported json");
106 PlacesUtils.restoreBookmarksFromJSONFile(jsonFile);
107 }
catch(ex) { do_throw(
"couldn't import the exported file: " + ex); }
108 LOG(
"imported json");
110 LOG(
"validated import");
114 {
uri:
uri(
"http://slint.us"), tags: [
"indie",
"kentucky",
"music"] },
115 {
uri:
uri(
"http://en.wikipedia.org/wiki/Diplodocus"), tags: [
"dinosaur",
"dj",
"rad word"] }
119 {
uri:
uri(
"http://slint.us"), title:
"indie, kentucky, music" },
120 {
uri:
uri(
"http://en.wikipedia.org/wiki/Diplodocus"), title:
"dinosaur, dj, rad word" }
130 PlacesUtils.tagging.tagURI(u,
t);
134 PlacesUtils.bookmarks.insertBookmark(PlacesUtils.bookmarks.unfiledBookmarksFolder,
135 u, PlacesUtils.bookmarks.DEFAULT_INDEX,
t);
140 PlacesUtils.bookmarks.insertBookmark(PlacesUtils.bookmarks.toolbarFolder,
141 u, PlacesUtils.bookmarks.DEFAULT_INDEX,
t);
156 var query = PlacesUtils.history.getNewQuery();
157 query.setFolders([PlacesUtils.bookmarks.bookmarksMenuFolder], 1);
158 var result = PlacesUtils.history.executeQuery(query, PlacesUtils.history.getNewQueryOptions());
159 var rootNode = result.root;
160 rootNode.containerOpen =
true;
168 do_check_eq(testFolder.type, testFolder.RESULT_TYPE_FOLDER);
178 testFolder = testFolder.QueryInterface(
Ci.nsINavHistoryQueryResultNode);
181 do_check_true(PlacesUtils.annotations.itemHasAnnotation(testFolder.itemId,
184 PlacesUtils.annotations.getItemAnnotation(testFolder.itemId,
DESCRIPTION_ANNO));
186 testFolder.containerOpen =
true;
187 var cc = testFolder.childCount;
193 var testBookmark1 = testFolder.getChild(0);
195 do_check_eq(
"http://test/post", testBookmark1.uri);
197 do_check_eq(
"test post keyword", testBookmark1.title);
199 do_check_eq(
"test", PlacesUtils.bookmarks.getKeywordForBookmark(testBookmark1.itemId));
201 do_check_true(PlacesUtils.annotations.itemHasAnnotation(testBookmark1.itemId,
212 do_check_true(PlacesUtils.annotations.itemHasAnnotation(testBookmark1.itemId,
POST_DATA_ANNO));
214 PlacesUtils.annotations.getItemAnnotation(testBookmark1.itemId,
POST_DATA_ANNO));
217 var testURI = PlacesUtils._uri(testBookmark1.uri);
218 do_check_eq(
"ISO-8859-1", PlacesUtils.history.getCharsetForURI(testURI));
221 do_check_true(PlacesUtils.annotations.itemHasAnnotation(testBookmark1.itemId,
224 PlacesUtils.annotations.getItemAnnotation(testBookmark1.itemId,
246 testFolder.containerOpen =
false;
247 rootNode.containerOpen =
false;
251 var query = PlacesUtils.history.getNewQuery();
252 query.setFolders([PlacesUtils.bookmarks.toolbarFolder], 1);
253 var result = PlacesUtils.history.executeQuery(query, PlacesUtils.history.getNewQueryOptions());
255 var toolbar = result.root;
256 toolbar.containerOpen =
true;
259 do_check_eq(toolbar.childCount, bookmarkData.length + 2);
262 var livemark = toolbar.getChild(1);
266 do_check_true(PlacesUtils.livemarks.isLivemark(livemark.itemId));
268 do_check_eq(
"http://en-us.fxfeeds.mozilla.com/en-US/firefox/livebookmarks/",
269 PlacesUtils.livemarks.getSiteURI(livemark.itemId).spec);
271 do_check_eq(
"http://en-us.fxfeeds.mozilla.com/en-US/firefox/headlines.xml",
272 PlacesUtils.livemarks.getFeedURI(livemark.itemId).spec);
275 var child = toolbar.getChild(2);
278 child = toolbar.getChild(3);
282 toolbar.containerOpen =
false;
286 var query = PlacesUtils.history.getNewQuery();
287 query.setFolders([PlacesUtils.bookmarks.unfiledBookmarksFolder], 1);
288 var result = PlacesUtils.history.executeQuery(query, PlacesUtils.history.getNewQueryOptions());
289 var rootNode = result.root;
290 rootNode.containerOpen =
true;
292 do_check_eq(rootNode.childCount, bookmarkData.length + 1);
293 for (var
i = 1;
i < rootNode.childCount;
i++) {
294 var child = rootNode.getChild(
i);
295 dump(bookmarkData[
i - 1].
uri.spec +
" == " + child.uri +
"?\n");
296 do_check_true(bookmarkData[
i - 1].
uri.equals(
uri(child.uri)));
303 rootNode.containerOpen =
false;
309 dump(
"test tags for " + u.spec +
": " +
t +
"\n");
310 var tt = PlacesUtils.tagging.getTagsForURI(u, {});
311 dump(
"true tags for " + u.spec +
": " + tt +
"\n");
312 do_check_true(
t.every(
function(el) {
314 return tt.indexOf(el) > -1;
do_check_eq(typeof PlacesUtils,"object")
function testToolbarFolder()
function testCanonicalBookmarks()
function testUnfiledBookmarks()
const LOAD_IN_SIDEBAR_ANNO
_getSelectedPageStyle s i