Bug 1159346 - Existing livemarks are broken. r=ttaubert
authorMarco Bonardo <mbonardo@mozilla.com>
Wed, 29 Apr 2015 10:57:20 +0200
changeset 273006 d8590ff0898ff607e0274f3ad725f8f8a53ce3cd
parent 273005 a32292906940c4c9827e45d6e57e8196b81358d8
child 273007 46f29b35aefe78ad4ff01cf6086a34f8eb1e71f9
push id863
push userraliiev@mozilla.com
push dateMon, 03 Aug 2015 13:22:43 +0000
treeherdermozilla-release@f6321b14228d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersttaubert
bugs1159346
milestone40.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1159346 - Existing livemarks are broken. r=ttaubert
toolkit/components/places/nsLivemarkService.js
toolkit/components/places/tests/unit/test_mozIAsyncLivemarks.js
--- a/toolkit/components/places/nsLivemarkService.js
+++ b/toolkit/components/places/nsLivemarkService.js
@@ -67,19 +67,19 @@ XPCOMUtils.defineLazyGetter(this, "gLive
         feedURI_anno: PlacesUtils.LMANNO_FEEDURI,
         siteURI_anno: PlacesUtils.LMANNO_SITEURI });
     for (let row of rows) {
       let siteURI = row.getResultByName("siteURI");
       let livemark = new Livemark({
         id: row.getResultByName("id"),
         guid: row.getResultByName("guid"),
         title: row.getResultByName("title"),
-        parentId: row.getResultByName("parent"),
+        parentId: row.getResultByName("parentId"),
         parentGuid: row.getResultByName("parentGuid"),
-        index: row.getResultByName("position"),
+        index: row.getResultByName("index"),
         dateAdded: row.getResultByName("dateAdded"),
         lastModified: row.getResultByName("lastModified"),
         feedURI: NetUtil.newURI(row.getResultByName("feedURI")),
         siteURI: siteURI ? NetUtil.newURI(siteURI) : null
       });
       livemarksMap.set(livemark.guid, livemark);
     }
     return livemarksMap;
--- a/toolkit/components/places/tests/unit/test_mozIAsyncLivemarks.js
+++ b/toolkit/components/places/tests/unit/test_mozIAsyncLivemarks.js
@@ -1,16 +1,48 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Tests functionality of the mozIAsyncLivemarks interface.
 
 const FEED_URI = NetUtil.newURI("http://feed.rss/");
 const SITE_URI = NetUtil.newURI("http://site.org/");
 
+// This test must be the first one, since it's testing the cache.
+add_task(function* test_livemark_cache() {
+  // Add a livemark through other APIs.
+  let folder = yield PlacesUtils.bookmarks.insert({
+    type: PlacesUtils.bookmarks.TYPE_FOLDER,
+    title: "test",
+    parentGuid: PlacesUtils.bookmarks.unfiledGuid
+  });
+  let id = yield PlacesUtils.promiseItemId(folder.guid);
+  PlacesUtils.annotations
+             .setItemAnnotation(id, PlacesUtils.LMANNO_FEEDURI,
+                                "http://example.com/feed",
+                                0, PlacesUtils.annotations.EXPIRE_NEVER);
+  PlacesUtils.annotations
+             .setItemAnnotation(id, PlacesUtils.LMANNO_SITEURI,
+                                "http://example.com/site",
+                                0, PlacesUtils.annotations.EXPIRE_NEVER);
+
+  let livemark = yield PlacesUtils.livemarks.getLivemark({ guid: folder.guid });
+  Assert.equal(folder.guid, livemark.guid);
+  Assert.equal(folder.dateAdded * 1000, livemark.dateAdded);
+  Assert.equal(folder.parentGuid, livemark.parentGuid);
+  Assert.equal(folder.index, livemark.index);
+  Assert.equal(folder.title, livemark.title);
+  Assert.equal(id, livemark.id);
+  Assert.equal(PlacesUtils.unfiledBookmarksFolderId, livemark.parentId);
+  Assert.equal("http://example.com/feed", livemark.feedURI.spec);
+  Assert.equal("http://example.com/site", livemark.siteURI.spec);
+
+  yield PlacesUtils.livemarks.removeLivemark(livemark);
+});
+
 add_task(function* test_addLivemark_noArguments_throws() {
   try {
     yield PlacesUtils.livemarks.addLivemark();
     do_throw("Invoking addLivemark with no arguments should throw");
   } catch (ex) {
     do_check_eq(ex.result, Cr.NS_ERROR_XPC_NOT_ENOUGH_ARGS);
   }
 });