45 var
hs =
Cc[
"@mozilla.org/browser/nav-history-service;1"].
47 var
dbConn =
hs.QueryInterface(
Ci.nsPIPlacesDatabase).DBConnection;
48 var
bs =
Cc[
"@mozilla.org/browser/nav-bookmarks-service;1"].
50 var
as =
Cc[
"@mozilla.org/browser/annotation-service;1"].
52 var
lms =
Cc[
"@mozilla.org/browser/livemark-service;2"].
54 var
icos =
Cc[
"@mozilla.org/browser/favicon-service;1"].
56 var
ps =
Cc[
"@mozilla.org/preferences-service;1"].
58 var
ies =
Cc[
"@mozilla.org/browser/places/import-export-service;1"].
66 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==";
71 ps.setIntPref(
"browser.places.smartBookmarksVersion", -1);
74 var corruptBookmarksFile = do_get_file(
"bookmarks.corrupt.html");
76 ies.importHTMLFromFile(corruptBookmarksFile,
true);
77 }
catch(ex) { do_throw(
"couldn't import corrupt bookmarks file: " + ex); }
84 var corruptItemId = bs.insertBookmark(bs.toolbarFolder,
85 uri(
"http://test.mozilla.org"),
86 bs.DEFAULT_INDEX,
"We love belugas");
87 var stmt =
dbConn.createStatement(
"UPDATE moz_bookmarks SET fk = NULL WHERE id = :itemId");
88 stmt.params.itemId = corruptItemId;
93 var bookmarksFile =
dirSvc.get(
"ProfD",
Ci.nsILocalFile);
94 bookmarksFile.append(
"bookmarks.exported.html");
95 if (bookmarksFile.exists())
96 bookmarksFile.remove(
false);
97 bookmarksFile.create(
Ci.nsILocalFile.NORMAL_FILE_TYPE, 0600);
98 if (!bookmarksFile.exists())
99 do_throw(
"couldn't create file: bookmarks.exported.html");
101 ies.exportHTMLToFile(bookmarksFile);
102 }
catch(ex) { do_throw(
"couldn't export to bookmarks.exported.html: " + ex); }
109 ies.importHTMLFromFile(bookmarksFile,
true);
110 }
catch(ex) { do_throw(
"couldn't import the exported file: " + ex); }
121 var query =
hs.getNewQuery();
122 query.setFolders([bs.bookmarksMenuFolder], 1);
124 options.queryType =
Ci.nsINavHistoryQueryOptions.QUERY_TYPE_BOOKMARKS;
125 var result =
hs.executeQuery(query, options);
126 var rootNode = result.root;
127 rootNode.containerOpen =
true;
132 do_check_eq(testFolder.type, testFolder.RESULT_TYPE_FOLDER);
135 do_check_eq(bs.getItemDateAdded(testFolder.itemId)/1000000, 1177541020);
137 do_check_eq(bs.getItemLastModified(testFolder.itemId)/1000000, 1177541050);
138 testFolder = testFolder.QueryInterface(
Ci.nsINavHistoryQueryResultNode);
141 do_check_true(as.itemHasAnnotation(testFolder.itemId,
146 testFolder.containerOpen =
true;
147 var cc = testFolder.childCount;
151 var testBookmark1 = testFolder.getChild(0);
153 do_check_eq(
"http://test/post", testBookmark1.uri);
155 do_check_eq(
"test post keyword", testBookmark1.title);
157 do_check_eq(
"test", bs.getKeywordForBookmark(testBookmark1.itemId));
159 do_check_true(as.itemHasAnnotation(testBookmark1.itemId,
162 do_check_eq(testBookmark1.dateAdded/1000000, 1177375336);
164 do_check_eq(testBookmark1.lastModified/1000000, 1177375423);
166 do_check_true(as.itemHasAnnotation(testBookmark1.itemId,
171 var testURI =
uri(testBookmark1.uri);
174 do_check_true(as.itemHasAnnotation(testBookmark1.itemId,
177 as.getItemAnnotation(testBookmark1.itemId,
181 testFolder.containerOpen =
false;
182 rootNode.containerOpen =
false;
185 query.setFolders([bs.toolbarFolder], 1);
186 result =
hs.executeQuery(query,
hs.getNewQueryOptions());
187 var toolbar = result.root;
188 toolbar.containerOpen =
true;
192 var livemark = toolbar.getChild(1);
196 do_check_true(lms.isLivemark(livemark.itemId));
198 do_check_eq(
"http://en-us.fxfeeds.mozilla.com/en-US/firefox/livebookmarks/",
199 lms.getSiteURI(livemark.itemId).spec);
201 do_check_eq(
"http://en-us.fxfeeds.mozilla.com/en-US/firefox/headlines.xml",
202 lms.getFeedURI(livemark.itemId).spec);
205 toolbar.containerOpen =
false;
208 query.setFolders([bs.unfiledBookmarksFolder], 1);
209 result =
hs.executeQuery(query,
hs.getNewQueryOptions());
210 var unfiledBookmarks = result.root;
211 unfiledBookmarks.containerOpen =
true;
213 unfiledBookmarks.containerOpen =
false;
217 var dataURL = icos.getFaviconDataAsDataURL(faviconURI);
do_check_eq(typeof PlacesUtils,"object")
function database_check()
const TEST_FAVICON_DATA_URL
function remove_all_bookmarks()
const TEST_FAVICON_PAGE_URL
getService(Ci.sbIFaceplateManager)
const LOAD_IN_SIDEBAR_ANNO