toolkit/components/places/tests/unit/test_mozIAsyncLivemarks.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/components/places/tests/unit/test_mozIAsyncLivemarks.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,499 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 +   http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +// Tests functionality of the mozIAsyncLivemarks interface.
     1.8 +
     1.9 +const FEED_URI = NetUtil.newURI("http://feed.rss/");
    1.10 +const SITE_URI = NetUtil.newURI("http://site.org/");
    1.11 +
    1.12 +
    1.13 +add_task(function test_addLivemark_noArguments_throws()
    1.14 +{
    1.15 +  try {
    1.16 +    yield PlacesUtils.livemarks.addLivemark();
    1.17 +    do_throw("Invoking addLivemark with no arguments should throw");
    1.18 +  } catch (ex) {
    1.19 +    // The error is actually generated by XPConnect.
    1.20 +    do_check_eq(ex.result, Cr.NS_ERROR_XPC_NOT_ENOUGH_ARGS);
    1.21 +  }
    1.22 +});
    1.23 +
    1.24 +add_task(function test_addLivemark_emptyObject_throws()
    1.25 +{
    1.26 +  try {
    1.27 +    yield PlacesUtils.livemarks.addLivemark({});
    1.28 +    do_throw("Invoking addLivemark with empty object should throw");
    1.29 +  } catch (ex) {
    1.30 +    do_check_eq(ex.result, Cr.NS_ERROR_INVALID_ARG);
    1.31 +  }
    1.32 +});
    1.33 +
    1.34 +add_task(function test_addLivemark_badParentId_throws()
    1.35 +{
    1.36 +  try {
    1.37 +    yield PlacesUtils.livemarks.addLivemark({ parentId: "test" });
    1.38 +    do_throw("Invoking addLivemark with a bad parent id should throw");
    1.39 +  } catch (ex) {
    1.40 +    do_check_eq(ex.result, Cr.NS_ERROR_INVALID_ARG);
    1.41 +  }
    1.42 +});
    1.43 +
    1.44 +add_task(function test_addLivemark_invalidParentId_throws()
    1.45 +{
    1.46 +  try {
    1.47 +    yield PlacesUtils.livemarks.addLivemark({ parentId: -2 });
    1.48 +    do_throw("Invoking addLivemark with an invalid parent id should throw");
    1.49 +  } catch (ex) {
    1.50 +    do_check_eq(ex.result, Cr.NS_ERROR_INVALID_ARG);
    1.51 +  }
    1.52 +});
    1.53 +
    1.54 +add_task(function test_addLivemark_noIndex_throws()
    1.55 +{
    1.56 +  try {
    1.57 +    yield PlacesUtils.livemarks.addLivemark({
    1.58 +      parentId: PlacesUtils.unfiledBookmarksFolderId });
    1.59 +    do_throw("Invoking addLivemark with no index should throw");
    1.60 +  } catch (ex) {
    1.61 +    do_check_eq(ex.result, Cr.NS_ERROR_INVALID_ARG);
    1.62 +  }
    1.63 +});
    1.64 +
    1.65 +add_task(function test_addLivemark_badIndex_throws()
    1.66 +{
    1.67 +  try {
    1.68 +    yield PlacesUtils.livemarks.addLivemark(
    1.69 +      { parentId: PlacesUtils.unfiledBookmarksFolderId
    1.70 +      , index: "test" });
    1.71 +    do_throw("Invoking addLivemark with a bad index should throw");
    1.72 +  } catch (ex) {
    1.73 +    do_check_eq(ex.result, Cr.NS_ERROR_INVALID_ARG);
    1.74 +  }
    1.75 +});
    1.76 +
    1.77 +add_task(function test_addLivemark_invalidIndex_throws()
    1.78 +{
    1.79 +  try {
    1.80 +    yield PlacesUtils.livemarks.addLivemark(
    1.81 +      { parentId: PlacesUtils.unfiledBookmarksFolderId
    1.82 +      , index: -2
    1.83 +      });
    1.84 +    do_throw("Invoking addLivemark with an invalid index should throw");
    1.85 +  } catch (ex) {
    1.86 +    do_check_eq(ex.result, Cr.NS_ERROR_INVALID_ARG);
    1.87 +  }
    1.88 +});
    1.89 +
    1.90 +add_task(function test_addLivemark_noFeedURI_throws()
    1.91 +{
    1.92 +  try {
    1.93 +    yield PlacesUtils.livemarks.addLivemark(
    1.94 +      { parentId: PlacesUtils.unfiledBookmarksFolderId
    1.95 +      , index: PlacesUtils.bookmarks.DEFAULT_INDEX });
    1.96 +    do_throw("Invoking addLivemark with no feedURI should throw");
    1.97 +  } catch (ex) {
    1.98 +    do_check_eq(ex.result, Cr.NS_ERROR_INVALID_ARG);
    1.99 +  }
   1.100 +});
   1.101 +
   1.102 +add_task(function test_addLivemark_badFeedURI_throws()
   1.103 +{
   1.104 +  try {
   1.105 +    yield PlacesUtils.livemarks.addLivemark(
   1.106 +      { parentId: PlacesUtils.unfiledBookmarksFolderId
   1.107 +      , index: PlacesUtils.bookmarks.DEFAULT_INDEX
   1.108 +      , feedURI: "test" });
   1.109 +    do_throw("Invoking addLivemark with a bad feedURI should throw");
   1.110 +  } catch (ex) {
   1.111 +    do_check_eq(ex.result, Cr.NS_ERROR_INVALID_ARG);
   1.112 +  }
   1.113 +});
   1.114 +
   1.115 +add_task(function test_addLivemark_badSiteURI_throws()
   1.116 +{
   1.117 +  try {
   1.118 +    yield PlacesUtils.livemarks.addLivemark(
   1.119 +      { parentId: PlacesUtils.unfiledBookmarksFolderId
   1.120 +      , index: PlacesUtils.bookmarks.DEFAULT_INDEX
   1.121 +      , feedURI: FEED_URI
   1.122 +      , siteURI: "test" });
   1.123 +    do_throw("Invoking addLivemark with a bad siteURI should throw");
   1.124 +  } catch (ex) {
   1.125 +    do_check_eq(ex.result, Cr.NS_ERROR_INVALID_ARG);
   1.126 +  }
   1.127 +});
   1.128 +
   1.129 +add_task(function test_addLivemark_badGuid_throws()
   1.130 +{
   1.131 +  try {
   1.132 +    yield PlacesUtils.livemarks.addLivemark(
   1.133 +      { parentId: PlacesUtils.unfiledBookmarksFolderId
   1.134 +      , index: PlacesUtils.bookmarks.DEFAULT_INDEX
   1.135 +      , feedURI: FEED_URI
   1.136 +      , guid: "123456" });
   1.137 +    do_throw("Invoking addLivemark with a bad guid should throw");
   1.138 +  } catch (ex) {
   1.139 +    do_check_eq(ex.result, Cr.NS_ERROR_INVALID_ARG);
   1.140 +  }
   1.141 +});
   1.142 +
   1.143 +add_task(function test_addLivemark_badCallback_throws()
   1.144 +{
   1.145 +  try {
   1.146 +    yield PlacesUtils.livemarks.addLivemark(
   1.147 +      { parentId: PlacesUtils.unfiledBookmarksFolderId
   1.148 +      , index: PlacesUtils.bookmarks.DEFAULT_INDEX
   1.149 +      , feedURI: FEED_URI
   1.150 +      }, "test");
   1.151 +    do_throw("Invoking addLivemark with a bad callback should throw");
   1.152 +  } catch (ex) {
   1.153 +    // The error is actually generated by XPConnect.
   1.154 +    do_check_eq(ex.result, Cr.NS_ERROR_XPC_BAD_CONVERT_JS);
   1.155 +  }
   1.156 +});
   1.157 +
   1.158 +add_task(function test_addLivemark_noCallback_succeeds()
   1.159 +{
   1.160 +  let onItemAddedCalled = false;
   1.161 +  PlacesUtils.bookmarks.addObserver({
   1.162 +    __proto__: NavBookmarkObserver.prototype,
   1.163 +    onItemAdded: function onItemAdded(aItemId, aParentId, aIndex, aItemType,
   1.164 +                                      aURI, aTitle)
   1.165 +    {
   1.166 +      onItemAddedCalled = true;
   1.167 +      PlacesUtils.bookmarks.removeObserver(this);
   1.168 +      do_check_eq(aParentId, PlacesUtils.unfiledBookmarksFolderId);
   1.169 +      do_check_eq(aIndex, 0);
   1.170 +      do_check_eq(aItemType, Ci.nsINavBookmarksService.TYPE_FOLDER);
   1.171 +      do_check_eq(aTitle, "test");
   1.172 +    }
   1.173 +  }, false);
   1.174 +
   1.175 +  yield PlacesUtils.livemarks.addLivemark(
   1.176 +    { title: "test"
   1.177 +    , parentId: PlacesUtils.unfiledBookmarksFolderId
   1.178 +    , index: PlacesUtils.bookmarks.DEFAULT_INDEX
   1.179 +    , feedURI: FEED_URI });
   1.180 +  do_check_true(onItemAddedCalled);
   1.181 +});
   1.182 +
   1.183 +
   1.184 +add_task(function test_addLivemark_noSiteURI_succeeds()
   1.185 +{
   1.186 +  let livemark = yield PlacesUtils.livemarks.addLivemark(
   1.187 +    { title: "test"
   1.188 +    , parentId: PlacesUtils.unfiledBookmarksFolderId
   1.189 +    , index: PlacesUtils.bookmarks.DEFAULT_INDEX
   1.190 +    , feedURI: FEED_URI
   1.191 +    });
   1.192 +  do_check_true(livemark.id > 0);
   1.193 +  do_check_valid_places_guid(livemark.guid);
   1.194 +  do_check_eq(livemark.title, "test");
   1.195 +  do_check_eq(livemark.parentId, PlacesUtils.unfiledBookmarksFolderId);
   1.196 +  do_check_eq(livemark.index, PlacesUtils.bookmarks.getItemIndex(livemark.id));
   1.197 +  do_check_eq(livemark.lastModified, PlacesUtils.bookmarks.getItemLastModified(livemark.id));
   1.198 +  do_check_true(livemark.feedURI.equals(FEED_URI));
   1.199 +  do_check_eq(livemark.siteURI, null);
   1.200 +});
   1.201 +
   1.202 +add_task(function test_addLivemark_succeeds()
   1.203 +{
   1.204 +  let livemark = yield PlacesUtils.livemarks.addLivemark(
   1.205 +    { title: "test"
   1.206 +    , parentId: PlacesUtils.unfiledBookmarksFolderId
   1.207 +    , index: PlacesUtils.bookmarks.DEFAULT_INDEX
   1.208 +    , feedURI: FEED_URI
   1.209 +    , siteURI: SITE_URI
   1.210 +    });
   1.211 +
   1.212 +  do_check_true(livemark.id > 0);
   1.213 +  do_check_valid_places_guid(livemark.guid);
   1.214 +  do_check_eq(livemark.title, "test");
   1.215 +  do_check_eq(livemark.parentId, PlacesUtils.unfiledBookmarksFolderId);
   1.216 +  do_check_eq(livemark.index, PlacesUtils.bookmarks.getItemIndex(livemark.id));
   1.217 +  do_check_eq(livemark.lastModified, PlacesUtils.bookmarks.getItemLastModified(livemark.id));
   1.218 +  do_check_true(livemark.feedURI.equals(FEED_URI));
   1.219 +  do_check_true(livemark.siteURI.equals(SITE_URI));
   1.220 +  do_check_true(PlacesUtils.annotations
   1.221 +                           .itemHasAnnotation(livemark.id,
   1.222 +                                              PlacesUtils.LMANNO_FEEDURI));
   1.223 +  do_check_true(PlacesUtils.annotations
   1.224 +                           .itemHasAnnotation(livemark.id,
   1.225 +                                              PlacesUtils.LMANNO_SITEURI));
   1.226 +});
   1.227 +
   1.228 +add_task(function test_addLivemark_bogusid_succeeds()
   1.229 +{
   1.230 +  let livemark = yield PlacesUtils.livemarks.addLivemark(
   1.231 +    { id: 100 // Should be ignored.
   1.232 +    , title: "test"
   1.233 +    , parentId: PlacesUtils.unfiledBookmarksFolderId
   1.234 +    , index: PlacesUtils.bookmarks.DEFAULT_INDEX
   1.235 +    , feedURI: FEED_URI
   1.236 +    , siteURI: SITE_URI
   1.237 +    });
   1.238 +  do_check_true(livemark.id > 0);
   1.239 +  do_check_neq(livemark.id, 100);
   1.240 +});
   1.241 +
   1.242 +add_task(function test_addLivemark_bogusParent_fails()
   1.243 +{
   1.244 +  try {
   1.245 +    yield PlacesUtils.livemarks.addLivemark(
   1.246 +      { title: "test"
   1.247 +      , parentId: 187
   1.248 +      , index: PlacesUtils.bookmarks.DEFAULT_INDEX
   1.249 +      , feedURI: FEED_URI
   1.250 +      });
   1.251 +    do_throw("Adding a livemark with a bogus parent should fail");
   1.252 +  } catch(ex) {}
   1.253 +});
   1.254 +
   1.255 +add_task(function test_addLivemark_intoLivemark_fails()
   1.256 +{
   1.257 +  let livemark = yield PlacesUtils.livemarks.addLivemark(
   1.258 +    { title: "test"
   1.259 +    , parentId: PlacesUtils.unfiledBookmarksFolderId
   1.260 +    , index: PlacesUtils.bookmarks.DEFAULT_INDEX
   1.261 +    , feedURI: FEED_URI
   1.262 +    });
   1.263 +  do_check_true(Boolean(livemark));
   1.264 +
   1.265 +  try {
   1.266 +    yield PlacesUtils.livemarks.addLivemark(
   1.267 +      { title: "test"
   1.268 +      , parentId: livemark.id
   1.269 +      , index: PlacesUtils.bookmarks.DEFAULT_INDEX
   1.270 +      , feedURI: FEED_URI
   1.271 +      });
   1.272 +    do_throw("Adding a livemark into a livemark should fail");
   1.273 +  } catch(ex) {}
   1.274 +});
   1.275 +
   1.276 +add_task(function test_addLivemark_forceGuid_succeeds()
   1.277 +{
   1.278 +  let checkLivemark = aLivemark => {
   1.279 +    do_check_eq(aLivemark.guid, "1234567890AB");
   1.280 +    do_check_guid_for_bookmark(aLivemark.id, "1234567890AB");
   1.281 +  };
   1.282 +
   1.283 +  let livemark = yield PlacesUtils.livemarks.addLivemark(
   1.284 +    { title: "test"
   1.285 +    , parentId: PlacesUtils.unfiledBookmarksFolderId
   1.286 +    , index: PlacesUtils.bookmarks.DEFAULT_INDEX
   1.287 +    , feedURI: FEED_URI
   1.288 +    , guid: "1234567890AB"
   1.289 +    });
   1.290 +  checkLivemark(livemark);
   1.291 +});
   1.292 +
   1.293 +add_task(function test_addLivemark_lastModified_succeeds()
   1.294 +{
   1.295 +  let now = Date.now() * 1000;
   1.296 +  let livemark = yield PlacesUtils.livemarks.addLivemark(
   1.297 +    { title: "test"
   1.298 +    , parentId: PlacesUtils.unfiledBookmarksFolderId
   1.299 +    , index: PlacesUtils.bookmarks.DEFAULT_INDEX
   1.300 +    , feedURI: FEED_URI
   1.301 +    , lastModified: now
   1.302 +    });
   1.303 +  do_check_eq(livemark.lastModified, now);
   1.304 +});
   1.305 +
   1.306 +add_task(function test_removeLivemark_emptyObject_throws()
   1.307 +{
   1.308 +  try {
   1.309 +    yield PlacesUtils.livemarks.removeLivemark({});
   1.310 +    do_throw("Invoking removeLivemark with empty object should throw");
   1.311 +  } catch (ex) {
   1.312 +    do_check_eq(ex.result, Cr.NS_ERROR_INVALID_ARG);
   1.313 +  }
   1.314 +});
   1.315 +
   1.316 +add_task(function test_removeLivemark_noValidId_throws()
   1.317 +{
   1.318 +  try {
   1.319 +    yield PlacesUtils.livemarks.removeLivemark({ id: -10, guid: "test"});
   1.320 +    do_throw("Invoking removeLivemark with no valid id should throw");
   1.321 +  } catch (ex) {
   1.322 +    do_check_eq(ex.result, Cr.NS_ERROR_INVALID_ARG);
   1.323 +  }
   1.324 +});
   1.325 +
   1.326 +add_task(function test_removeLivemark_nonExistent_fails()
   1.327 +{
   1.328 +  try {
   1.329 +    yield PlacesUtils.livemarks.removeLivemark({ id: 1337 });
   1.330 +    do_throw("Removing a non-existent livemark should fail");
   1.331 +  }
   1.332 +  catch(ex) {
   1.333 +  }
   1.334 +});
   1.335 +
   1.336 +add_task(function test_removeLivemark_guid_succeeds()
   1.337 +{
   1.338 +  let livemark = yield PlacesUtils.livemarks.addLivemark(
   1.339 +    { title: "test"
   1.340 +    , parentId: PlacesUtils.unfiledBookmarksFolderId
   1.341 +    , index: PlacesUtils.bookmarks.DEFAULT_INDEX
   1.342 +    , feedURI: FEED_URI
   1.343 +    , guid: "234567890ABC"
   1.344 +  });
   1.345 +
   1.346 +
   1.347 +  do_check_eq(livemark.guid, "234567890ABC");
   1.348 +
   1.349 +  yield PlacesUtils.livemarks.removeLivemark({
   1.350 +    id: 789, guid: "234567890ABC"
   1.351 +  });
   1.352 +
   1.353 +  do_check_eq(PlacesUtils.bookmarks.getItemIndex(livemark.id), -1);
   1.354 +});
   1.355 +
   1.356 +add_task(function test_removeLivemark_id_succeeds()
   1.357 +{
   1.358 +  let livemark = yield PlacesUtils.livemarks.addLivemark(
   1.359 +    { title: "test"
   1.360 +    , parentId: PlacesUtils.unfiledBookmarksFolderId
   1.361 +    , index: PlacesUtils.bookmarks.DEFAULT_INDEX
   1.362 +    , feedURI: FEED_URI
   1.363 +  });
   1.364 +
   1.365 +  yield PlacesUtils.livemarks.removeLivemark({ id: livemark.id });
   1.366 +  do_check_eq(PlacesUtils.bookmarks.getItemIndex(livemark.id), -1);
   1.367 +});
   1.368 +
   1.369 +add_task(function test_getLivemark_emptyObject_throws()
   1.370 +{
   1.371 +  try {
   1.372 +    yield PlacesUtils.livemarks.getLivemark({});
   1.373 +    do_throw("Invoking getLivemark with empty object should throw");
   1.374 +  } catch (ex) {
   1.375 +    do_check_eq(ex.result, Cr.NS_ERROR_INVALID_ARG);
   1.376 +  }
   1.377 +});
   1.378 +
   1.379 +add_task(function test_getLivemark_noValidId_throws()
   1.380 +{
   1.381 +  try {
   1.382 +    yield PlacesUtils.livemarks.getLivemark({ id: -10, guid: "test"});
   1.383 +    do_throw("Invoking getLivemark with no valid id should throw");
   1.384 +  } catch (ex) {
   1.385 +    do_check_eq(ex.result, Cr.NS_ERROR_INVALID_ARG);
   1.386 +  }
   1.387 +});
   1.388 +
   1.389 +add_task(function test_getLivemark_nonExistentId_fails()
   1.390 +{
   1.391 +  try {
   1.392 +    yield PlacesUtils.livemarks.getLivemark({ id: 1234 });
   1.393 +    do_throw("getLivemark for a non existent id should fail");
   1.394 +  }
   1.395 +  catch(ex) {}
   1.396 +});
   1.397 +
   1.398 +add_task(function test_getLivemark_nonExistentGUID_fails()
   1.399 +{
   1.400 +  try {
   1.401 +    yield PlacesUtils.livemarks.getLivemark({ guid: "34567890ABCD" });
   1.402 +    do_throw("getLivemark for a non-existent guid should fail");
   1.403 +  }
   1.404 +  catch(ex) {}
   1.405 +});
   1.406 +
   1.407 +add_task(function test_getLivemark_guid_succeeds()
   1.408 +{
   1.409 +  yield PlacesUtils.livemarks.addLivemark(
   1.410 +    { title: "test"
   1.411 +    , parentId: PlacesUtils.unfiledBookmarksFolderId
   1.412 +    , index: PlacesUtils.bookmarks.DEFAULT_INDEX
   1.413 +    , feedURI: FEED_URI
   1.414 +    , guid: "34567890ABCD" });
   1.415 +
   1.416 +  // invalid id to check the guid wins.
   1.417 +  let livemark =
   1.418 +    yield PlacesUtils.livemarks.getLivemark({ id: 789, guid: "34567890ABCD" });
   1.419 +
   1.420 +  do_check_eq(livemark.title, "test");
   1.421 +  do_check_eq(livemark.parentId, PlacesUtils.unfiledBookmarksFolderId);
   1.422 +  do_check_eq(livemark.index, PlacesUtils.bookmarks.getItemIndex(livemark.id));
   1.423 +  do_check_true(livemark.feedURI.equals(FEED_URI));
   1.424 +  do_check_eq(livemark.siteURI, null);
   1.425 +  do_check_eq(livemark.guid, "34567890ABCD");
   1.426 +});
   1.427 +
   1.428 +add_task(function test_getLivemark_id_succeeds()
   1.429 +{
   1.430 +  let livemark = yield PlacesUtils.livemarks.addLivemark(
   1.431 +    { title: "test"
   1.432 +    , parentId: PlacesUtils.unfiledBookmarksFolderId
   1.433 +    , index: PlacesUtils.bookmarks.DEFAULT_INDEX
   1.434 +    , feedURI: FEED_URI
   1.435 +    });
   1.436 +
   1.437 +  livemark = yield PlacesUtils.livemarks.getLivemark({ id: livemark.id });
   1.438 +
   1.439 +  do_check_eq(livemark.title, "test");
   1.440 +  do_check_eq(livemark.parentId, PlacesUtils.unfiledBookmarksFolderId);
   1.441 +  do_check_eq(livemark.index, PlacesUtils.bookmarks.getItemIndex(livemark.id));
   1.442 +  do_check_true(livemark.feedURI.equals(FEED_URI));
   1.443 +  do_check_eq(livemark.siteURI, null);
   1.444 +  do_check_guid_for_bookmark(livemark.id, livemark.guid);
   1.445 +});
   1.446 +
   1.447 +add_task(function test_getLivemark_removeItem_contention()
   1.448 +{
   1.449 +  PlacesUtils.livemarks.addLivemark({ title: "test"
   1.450 +                                    , parentId: PlacesUtils.unfiledBookmarksFolderId
   1.451 +                                    , index: PlacesUtils.bookmarks.DEFAULT_INDEX
   1.452 +                                    , feedURI: FEED_URI
   1.453 +                                    });
   1.454 +  PlacesUtils.bookmarks.removeFolderChildren(PlacesUtils.unfiledBookmarksFolderId);
   1.455 +  PlacesUtils.livemarks.addLivemark({ title: "test"
   1.456 +                                    , parentId: PlacesUtils.unfiledBookmarksFolderId
   1.457 +                                    , index: PlacesUtils.bookmarks.DEFAULT_INDEX
   1.458 +                                    , feedURI: FEED_URI
   1.459 +                                    });
   1.460 +  let id = PlacesUtils.bookmarks.getIdForItemAt(PlacesUtils.unfiledBookmarksFolderId,
   1.461 +                                                PlacesUtils.bookmarks.DEFAULT_INDEX);
   1.462 +
   1.463 +  let livemark = yield PlacesUtils.livemarks.getLivemark({ id: id });
   1.464 +
   1.465 +  do_check_eq(livemark.title, "test");
   1.466 +  do_check_eq(livemark.parentId, PlacesUtils.unfiledBookmarksFolderId);
   1.467 +  do_check_eq(livemark.index, PlacesUtils.bookmarks.getItemIndex(livemark.id));
   1.468 +  do_check_true(livemark.feedURI.equals(FEED_URI));
   1.469 +  do_check_eq(livemark.siteURI, null);
   1.470 +  do_check_guid_for_bookmark(livemark.id, livemark.guid);
   1.471 +});
   1.472 +
   1.473 +add_task(function test_title_change()
   1.474 +{
   1.475 +  let livemark = yield PlacesUtils.livemarks.addLivemark(
   1.476 +    { title: "test"
   1.477 +    , parentId: PlacesUtils.unfiledBookmarksFolderId
   1.478 +    , index: PlacesUtils.bookmarks.DEFAULT_INDEX
   1.479 +    , feedURI: FEED_URI });
   1.480 +
   1.481 +  PlacesUtils.bookmarks.setItemTitle(livemark.id, "test2");
   1.482 +  do_check_eq(livemark.title, "test2");
   1.483 +});
   1.484 +
   1.485 +add_task(function test_livemark_move()
   1.486 +{
   1.487 +  let livemark = yield PlacesUtils.livemarks.addLivemark(
   1.488 +    { title: "test"
   1.489 +    , parentId: PlacesUtils.unfiledBookmarksFolderId
   1.490 +    , index: PlacesUtils.bookmarks.DEFAULT_INDEX
   1.491 +    , feedURI: FEED_URI } );
   1.492 +
   1.493 +  PlacesUtils.bookmarks.moveItem(livemark.id,
   1.494 +                                 PlacesUtils.toolbarFolderId,
   1.495 +                                 PlacesUtils.bookmarks.DEFAULT_INDEX);
   1.496 +  do_check_eq(livemark.parentId, PlacesUtils.toolbarFolderId);
   1.497 +  do_check_eq(livemark.index, PlacesUtils.bookmarks.getItemIndex(livemark.id));
   1.498 +});
   1.499 +
   1.500 +function run_test() {
   1.501 +  run_next_test();
   1.502 +}

mercurial