39 Components.utils.import(
"resource://gre/modules/utils.js");
41 const bmsvc = PlacesUtils.bookmarks;
46 var testURI =
uri(
"http://foo.com");
54 bmsvc.setKeywordForBookmark(bm1,
"foo");
55 PlacesUtils.setPostDataForBookmark(bm1,
"pdata1");
57 bmsvc.setKeywordForBookmark(bm2,
"bar");
58 PlacesUtils.setPostDataForBookmark(bm2,
"pdata2");
62 [
url,
postdata] = PlacesUtils.getURLAndPostDataForKeyword(
"foo");
67 [
url,
postdata] = PlacesUtils.getURLAndPostDataForKeyword(
"bar");
72 bmsvc.removeItem(bm1);
73 bmsvc.removeItem(bm2);
80 bmsvc.setKeywordForBookmark(bm1,
"foo");
81 PlacesUtils.setPostDataForBookmark(bm1,
"pdata1");
83 bmsvc.setKeywordForBookmark(bm2,
"foo");
84 PlacesUtils.setPostDataForBookmark(bm2,
"pdata2");
86 var bm1da =
bmsvc.getItemDateAdded(bm1);
87 var bm1lm =
bmsvc.getItemLastModified(bm1);
88 LOG(
"bm1 dateAdded: " + bm1da +
", lastModified: " + bm1lm);
89 var bm2da =
bmsvc.getItemDateAdded(bm2);
90 var bm2lm =
bmsvc.getItemLastModified(bm2);
91 LOG(
"bm2 dateAdded: " + bm2da +
", lastModified: " + bm2lm);
92 do_check_true(bm1da <= bm2da);
93 do_check_true(bm1lm <= bm2lm);
95 [
url,
postdata] = PlacesUtils.getURLAndPostDataForKeyword(
"foo");
100 bmsvc.removeItem(bm1);
101 bmsvc.removeItem(bm2);
109 bmsvc.setKeywordForBookmark(bm1,
"foo");
110 PlacesUtils.setPostDataForBookmark(bm1,
"pdata1");
112 bmsvc.setKeywordForBookmark(bm2,
"foo");
113 PlacesUtils.setPostDataForBookmark(bm2,
"pdata2");
116 bmsvc.setItemTitle(bm1,
"change");
118 var bm1da =
bmsvc.getItemDateAdded(bm1);
119 var bm1lm =
bmsvc.getItemLastModified(bm1);
120 LOG(
"bm1 dateAdded: " + bm1da +
", lastModified: " + bm1lm);
121 var bm2da =
bmsvc.getItemDateAdded(bm2);
122 var bm2lm =
bmsvc.getItemLastModified(bm2);
123 LOG(
"bm2 dateAdded: " + bm2da +
", lastModified: " + bm2lm);
124 do_check_true(bm1da <= bm2da);
128 do_check_true(bm1lm >= bm2lm);
134 bmsvc.setItemLastModified(bm1, bm2lm + 1);
136 [
url,
postdata] = PlacesUtils.getURLAndPostDataForKeyword(
"foo");
141 bmsvc.removeItem(bm1);
142 bmsvc.removeItem(bm2);
149 var testDate = Date.now() * 1000;
151 bmsvc.setKeywordForBookmark(bm1,
"foo");
152 PlacesUtils.setPostDataForBookmark(bm1,
"pdata1");
153 bmsvc.setItemDateAdded(bm1, testDate);
154 bmsvc.setItemLastModified(bm1, testDate);
157 bmsvc.setKeywordForBookmark(bm2,
"foo");
158 PlacesUtils.setPostDataForBookmark(bm2,
"pdata2");
159 bmsvc.setItemDateAdded(bm2, testDate);
160 bmsvc.setItemLastModified(bm2, testDate);
162 var bm1da =
bmsvc.getItemDateAdded(bm1, testDate);
163 var bm1lm =
bmsvc.getItemLastModified(bm1);
164 LOG(
"bm1 dateAdded: " + bm1da +
", lastModified: " + bm1lm);
165 var bm2da =
bmsvc.getItemDateAdded(bm2);
166 var bm2lm =
bmsvc.getItemLastModified(bm2);
167 LOG(
"bm2 dateAdded: " + bm2da +
", lastModified: " + bm2lm);
173 var ids =
bmsvc.getBookmarkIdsForURI(testURI, {});
177 [
url,
postdata] = PlacesUtils.getURLAndPostDataForKeyword(
"foo");
182 bmsvc.removeItem(bm1);
183 bmsvc.removeItem(bm2);
do_check_eq(typeof PlacesUtils,"object")