2010-05-10 18:08:52 -07:00
|
|
|
_("Make sure various combinations of anno arguments do the right get/set for pages/items");
|
2010-06-16 14:30:08 -07:00
|
|
|
Cu.import("resource://services-sync/util.js");
|
2010-05-10 18:08:52 -07:00
|
|
|
|
|
|
|
function run_test() {
|
2010-06-21 23:56:56 -07:00
|
|
|
_("create a bookmark to a url so it exists");
|
|
|
|
let url = "about:";
|
|
|
|
let bmkid = Svc.Bookmark.insertBookmark(Svc.Bookmark.unfiledBookmarksFolder,
|
|
|
|
Utils.makeURI(url), -1, "");
|
|
|
|
|
2010-06-22 18:28:37 -07:00
|
|
|
_("set an anno on the bookmark ");
|
|
|
|
Utils.anno(bmkid, "anno", "hi");
|
|
|
|
do_check_eq(Utils.anno(bmkid, "anno"), "hi");
|
|
|
|
|
2010-05-10 18:08:52 -07:00
|
|
|
_("set an anno on a url");
|
2010-06-21 23:56:56 -07:00
|
|
|
Utils.anno(url, "tation", "hello");
|
|
|
|
do_check_eq(Utils.anno(url, "tation"), "hello");
|
2010-05-10 18:08:52 -07:00
|
|
|
|
|
|
|
_("make sure getting it also works with a nsIURI");
|
2010-06-21 23:56:56 -07:00
|
|
|
let uri = Utils.makeURI(url);
|
2010-05-10 18:08:52 -07:00
|
|
|
do_check_eq(Utils.anno(uri, "tation"), "hello");
|
|
|
|
|
|
|
|
_("make sure annotations get updated");
|
|
|
|
Utils.anno(uri, "tation", "bye!");
|
2010-06-21 23:56:56 -07:00
|
|
|
do_check_eq(Utils.anno(url, "tation"), "bye!");
|
2010-05-10 18:08:52 -07:00
|
|
|
|
|
|
|
_("sanity check that the item anno is still there");
|
2010-06-22 18:28:37 -07:00
|
|
|
do_check_eq(Utils.anno(bmkid, "anno"), "hi");
|
2010-06-01 11:30:11 -07:00
|
|
|
|
|
|
|
_("invalid uris don't get annos");
|
|
|
|
let didThrow = false;
|
|
|
|
try {
|
|
|
|
Utils.anno("foo/bar/baz", "bad");
|
|
|
|
}
|
|
|
|
catch(ex) {
|
|
|
|
didThrow = true;
|
|
|
|
}
|
|
|
|
do_check_true(didThrow);
|
2010-06-21 23:56:56 -07:00
|
|
|
|
|
|
|
_("cleaning up the bookmark we created");
|
|
|
|
Svc.Bookmark.removeItem(bmkid);
|
2010-05-10 18:08:52 -07:00
|
|
|
}
|