Bug 585753 - Changeset 7e8b1f7852a9 breaks bookmark sync [r=mconnor]
authorPhilipp von Weitershausen <philipp@weitershausen.de>
Tue, 10 Aug 2010 01:59:26 +0200
changeset 49609 95630d242dad3cc118175f4674d2c87489941875
parent 49608 e001d2a2e7fab655a1b892f21a7cfe284aef69c3
child 49610 edc4b8a08357b225301a7af258309730bde137f5
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconnor
bugs585753
Bug 585753 - Changeset 7e8b1f7852a9 breaks bookmark sync [r=mconnor]
services/sync/modules/engines/bookmarks.js
services/sync/tests/unit/test_bookmark_store.js
--- a/services/sync/modules/engines/bookmarks.js
+++ b/services/sync/modules/engines/bookmarks.js
@@ -868,17 +868,17 @@ BookmarksStore.prototype = {
     if (record.parentid == "toolbar")
       index += 150;
 
     // Add in the bookmark's frecency if we have something
     if (record.bmkUri != null) {
       this._frecencyStm.params.url = record.bmkUri;
       let result = Utils.queryAsync(this._frecencyStm, ["frecency"]);
       if (result.length)
-        index += result.frecency;
+        index += result[0].frecency;
     }
 
     return index;
   },
 
   _getParentGUIDForId: function BStore__getParentGUIDForId(itemId) {
     // Give the parent annotation if it exists
     try {
new file mode 100644
--- /dev/null
+++ b/services/sync/tests/unit/test_bookmark_store.js
@@ -0,0 +1,49 @@
+Cu.import("resource://services-sync/engines/bookmarks.js");
+Cu.import("resource://services-sync/util.js");
+
+function run_test() {
+  let store = new BookmarksEngine()._store;
+  store.wipe();
+
+  try {
+    _("Ensure the record isn't present yet.");
+    let fxuri = Utils.makeURI("http://getfirefox.com/");
+    let ids = Svc.Bookmark.getBookmarkIdsForURI(fxuri, {});
+    do_check_eq(ids.length, 0);
+
+    _("Let's create a new record.");
+    let fxrecord = {id: "{5d81b87c-d5fc-42d9-a114-d69b7342f10e}0",
+                    type: "bookmark",
+                    bmkUri: fxuri.spec,
+                    title: "Get Firefox!",
+                    tags: [],
+                    keyword: "awesome",
+                    loadInSidebar: false,
+                    parentName: "Bookmarks Toolbar",
+                    parentid: "toolbar"};
+    store.applyIncoming(fxrecord);
+
+    _("Verify it has been created correctly.");
+    ids = Svc.Bookmark.getBookmarkIdsForURI(fxuri, {});
+    do_check_eq(ids.length, 1);
+    let id = ids[0];
+    do_check_eq(Svc.Bookmark.getItemGUID(id), fxrecord.id);
+    do_check_eq(Svc.Bookmark.getItemType(id), Svc.Bookmark.TYPE_BOOKMARK);
+    do_check_eq(Svc.Bookmark.getItemTitle(id), fxrecord.title);
+    do_check_eq(Svc.Bookmark.getFolderIdForItem(id),
+                Svc.Bookmark.toolbarFolder);
+    do_check_eq(Svc.Bookmark.getKeywordForBookmark(id), fxrecord.keyword);
+
+    _("Have the store create a new record object. Verify that it has the same data.");
+    let newrecord = store.createRecord(fxrecord.id);
+    for each (let property in ["type", "bmkUri", "title", "keyword",
+                               "parentName", "parentid"])
+      do_check_eq(newrecord[property], fxrecord[property]);      
+
+    _("The calculated sort index is based on frecency data.");
+    do_check_true(newrecord.sortindex >= 150);
+  } finally {
+    _("Clean up.");
+    store.wipe();
+  }
+}