Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* vim:set ts=2 sw=2 sts=2 et: */ |
michael@0 | 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | let bs = PlacesUtils.bookmarks; |
michael@0 | 8 | let hs = PlacesUtils.history; |
michael@0 | 9 | let anno = PlacesUtils.annotations; |
michael@0 | 10 | |
michael@0 | 11 | |
michael@0 | 12 | let bookmarksObserver = { |
michael@0 | 13 | onBeginUpdateBatch: function() { |
michael@0 | 14 | this._beginUpdateBatch = true; |
michael@0 | 15 | }, |
michael@0 | 16 | onEndUpdateBatch: function() { |
michael@0 | 17 | this._endUpdateBatch = true; |
michael@0 | 18 | }, |
michael@0 | 19 | onItemAdded: function(id, folder, index, itemType, uri, title, dateAdded, |
michael@0 | 20 | guid) { |
michael@0 | 21 | this._itemAddedId = id; |
michael@0 | 22 | this._itemAddedParent = folder; |
michael@0 | 23 | this._itemAddedIndex = index; |
michael@0 | 24 | this._itemAddedURI = uri; |
michael@0 | 25 | this._itemAddedTitle = title; |
michael@0 | 26 | |
michael@0 | 27 | // Ensure that we've created a guid for this item. |
michael@0 | 28 | let stmt = DBConn().createStatement( |
michael@0 | 29 | "SELECT guid " |
michael@0 | 30 | + "FROM moz_bookmarks " |
michael@0 | 31 | + "WHERE id = :item_id " |
michael@0 | 32 | ); |
michael@0 | 33 | stmt.params.item_id = id; |
michael@0 | 34 | do_check_true(stmt.executeStep()); |
michael@0 | 35 | do_check_false(stmt.getIsNull(0)); |
michael@0 | 36 | do_check_valid_places_guid(stmt.row.guid); |
michael@0 | 37 | do_check_eq(stmt.row.guid, guid); |
michael@0 | 38 | stmt.finalize(); |
michael@0 | 39 | }, |
michael@0 | 40 | onItemRemoved: function(id, folder, index, itemType) { |
michael@0 | 41 | this._itemRemovedId = id; |
michael@0 | 42 | this._itemRemovedFolder = folder; |
michael@0 | 43 | this._itemRemovedIndex = index; |
michael@0 | 44 | }, |
michael@0 | 45 | onItemChanged: function(id, property, isAnnotationProperty, value, |
michael@0 | 46 | lastModified, itemType) { |
michael@0 | 47 | this._itemChangedId = id; |
michael@0 | 48 | this._itemChangedProperty = property; |
michael@0 | 49 | this._itemChanged_isAnnotationProperty = isAnnotationProperty; |
michael@0 | 50 | this._itemChangedValue = value; |
michael@0 | 51 | }, |
michael@0 | 52 | onItemVisited: function(id, visitID, time) { |
michael@0 | 53 | this._itemVisitedId = id; |
michael@0 | 54 | this._itemVisitedVistId = visitID; |
michael@0 | 55 | this._itemVisitedTime = time; |
michael@0 | 56 | }, |
michael@0 | 57 | onItemMoved: function(id, oldParent, oldIndex, newParent, newIndex, |
michael@0 | 58 | itemType) { |
michael@0 | 59 | this._itemMovedId = id |
michael@0 | 60 | this._itemMovedOldParent = oldParent; |
michael@0 | 61 | this._itemMovedOldIndex = oldIndex; |
michael@0 | 62 | this._itemMovedNewParent = newParent; |
michael@0 | 63 | this._itemMovedNewIndex = newIndex; |
michael@0 | 64 | }, |
michael@0 | 65 | QueryInterface: XPCOMUtils.generateQI([ |
michael@0 | 66 | Ci.nsINavBookmarkObserver, |
michael@0 | 67 | ]) |
michael@0 | 68 | }; |
michael@0 | 69 | |
michael@0 | 70 | |
michael@0 | 71 | // Get bookmarks menu folder id. |
michael@0 | 72 | let root = bs.bookmarksMenuFolder; |
michael@0 | 73 | // Index at which items should begin. |
michael@0 | 74 | let bmStartIndex = 0; |
michael@0 | 75 | |
michael@0 | 76 | |
michael@0 | 77 | function run_test() { |
michael@0 | 78 | run_next_test(); |
michael@0 | 79 | } |
michael@0 | 80 | |
michael@0 | 81 | add_task(function test_bookmarks() { |
michael@0 | 82 | bs.addObserver(bookmarksObserver, false); |
michael@0 | 83 | |
michael@0 | 84 | // test special folders |
michael@0 | 85 | do_check_true(bs.placesRoot > 0); |
michael@0 | 86 | do_check_true(bs.bookmarksMenuFolder > 0); |
michael@0 | 87 | do_check_true(bs.tagsFolder > 0); |
michael@0 | 88 | do_check_true(bs.toolbarFolder > 0); |
michael@0 | 89 | do_check_true(bs.unfiledBookmarksFolder > 0); |
michael@0 | 90 | |
michael@0 | 91 | // test getFolderIdForItem() with bogus item id will throw |
michael@0 | 92 | try { |
michael@0 | 93 | let id = bs.getFolderIdForItem(0); |
michael@0 | 94 | do_throw("getFolderIdForItem accepted bad input"); |
michael@0 | 95 | } catch(ex) {} |
michael@0 | 96 | |
michael@0 | 97 | // test getFolderIdForItem() with bogus item id will throw |
michael@0 | 98 | try { |
michael@0 | 99 | let id = bs.getFolderIdForItem(-1); |
michael@0 | 100 | do_throw("getFolderIdForItem accepted bad input"); |
michael@0 | 101 | } catch(ex) {} |
michael@0 | 102 | |
michael@0 | 103 | // test root parentage |
michael@0 | 104 | do_check_eq(bs.getFolderIdForItem(bs.bookmarksMenuFolder), bs.placesRoot); |
michael@0 | 105 | do_check_eq(bs.getFolderIdForItem(bs.tagsFolder), bs.placesRoot); |
michael@0 | 106 | do_check_eq(bs.getFolderIdForItem(bs.toolbarFolder), bs.placesRoot); |
michael@0 | 107 | do_check_eq(bs.getFolderIdForItem(bs.unfiledBookmarksFolder), bs.placesRoot); |
michael@0 | 108 | |
michael@0 | 109 | // create a folder to hold all the tests |
michael@0 | 110 | // this makes the tests more tolerant of changes to default_places.html |
michael@0 | 111 | let testRoot = bs.createFolder(root, "places bookmarks xpcshell tests", |
michael@0 | 112 | bs.DEFAULT_INDEX); |
michael@0 | 113 | do_check_eq(bookmarksObserver._itemAddedId, testRoot); |
michael@0 | 114 | do_check_eq(bookmarksObserver._itemAddedParent, root); |
michael@0 | 115 | do_check_eq(bookmarksObserver._itemAddedIndex, bmStartIndex); |
michael@0 | 116 | do_check_eq(bookmarksObserver._itemAddedURI, null); |
michael@0 | 117 | let testStartIndex = 0; |
michael@0 | 118 | |
michael@0 | 119 | // test getItemIndex for folders |
michael@0 | 120 | do_check_eq(bs.getItemIndex(testRoot), bmStartIndex); |
michael@0 | 121 | |
michael@0 | 122 | // test getItemType for folders |
michael@0 | 123 | do_check_eq(bs.getItemType(testRoot), bs.TYPE_FOLDER); |
michael@0 | 124 | |
michael@0 | 125 | // insert a bookmark. |
michael@0 | 126 | // the time before we insert, in microseconds |
michael@0 | 127 | let beforeInsert = Date.now() * 1000; |
michael@0 | 128 | do_check_true(beforeInsert > 0); |
michael@0 | 129 | |
michael@0 | 130 | let newId = bs.insertBookmark(testRoot, uri("http://google.com/"), |
michael@0 | 131 | bs.DEFAULT_INDEX, ""); |
michael@0 | 132 | do_check_eq(bookmarksObserver._itemAddedId, newId); |
michael@0 | 133 | do_check_eq(bookmarksObserver._itemAddedParent, testRoot); |
michael@0 | 134 | do_check_eq(bookmarksObserver._itemAddedIndex, testStartIndex); |
michael@0 | 135 | do_check_true(bookmarksObserver._itemAddedURI.equals(uri("http://google.com/"))); |
michael@0 | 136 | do_check_eq(bs.getBookmarkURI(newId).spec, "http://google.com/"); |
michael@0 | 137 | |
michael@0 | 138 | let dateAdded = bs.getItemDateAdded(newId); |
michael@0 | 139 | // dateAdded can equal beforeInsert |
michael@0 | 140 | do_check_true(is_time_ordered(beforeInsert, dateAdded)); |
michael@0 | 141 | |
michael@0 | 142 | // after just inserting, modified should not be set |
michael@0 | 143 | let lastModified = bs.getItemLastModified(newId); |
michael@0 | 144 | do_check_eq(lastModified, dateAdded); |
michael@0 | 145 | |
michael@0 | 146 | // The time before we set the title, in microseconds. |
michael@0 | 147 | let beforeSetTitle = Date.now() * 1000; |
michael@0 | 148 | do_check_true(beforeSetTitle >= beforeInsert); |
michael@0 | 149 | |
michael@0 | 150 | // Workaround possible VM timers issues moving lastModified and dateAdded |
michael@0 | 151 | // to the past. |
michael@0 | 152 | bs.setItemLastModified(newId, --lastModified); |
michael@0 | 153 | bs.setItemDateAdded(newId, --dateAdded); |
michael@0 | 154 | |
michael@0 | 155 | // set bookmark title |
michael@0 | 156 | bs.setItemTitle(newId, "Google"); |
michael@0 | 157 | do_check_eq(bookmarksObserver._itemChangedId, newId); |
michael@0 | 158 | do_check_eq(bookmarksObserver._itemChangedProperty, "title"); |
michael@0 | 159 | do_check_eq(bookmarksObserver._itemChangedValue, "Google"); |
michael@0 | 160 | |
michael@0 | 161 | // check that dateAdded hasn't changed |
michael@0 | 162 | let dateAdded2 = bs.getItemDateAdded(newId); |
michael@0 | 163 | do_check_eq(dateAdded2, dateAdded); |
michael@0 | 164 | |
michael@0 | 165 | // check lastModified after we set the title |
michael@0 | 166 | let lastModified2 = bs.getItemLastModified(newId); |
michael@0 | 167 | LOG("test setItemTitle"); |
michael@0 | 168 | LOG("dateAdded = " + dateAdded); |
michael@0 | 169 | LOG("beforeSetTitle = " + beforeSetTitle); |
michael@0 | 170 | LOG("lastModified = " + lastModified); |
michael@0 | 171 | LOG("lastModified2 = " + lastModified2); |
michael@0 | 172 | do_check_true(is_time_ordered(lastModified, lastModified2)); |
michael@0 | 173 | do_check_true(is_time_ordered(dateAdded, lastModified2)); |
michael@0 | 174 | |
michael@0 | 175 | // get item title |
michael@0 | 176 | let title = bs.getItemTitle(newId); |
michael@0 | 177 | do_check_eq(title, "Google"); |
michael@0 | 178 | |
michael@0 | 179 | // test getItemType for bookmarks |
michael@0 | 180 | do_check_eq(bs.getItemType(newId), bs.TYPE_BOOKMARK); |
michael@0 | 181 | |
michael@0 | 182 | // get item title bad input |
michael@0 | 183 | try { |
michael@0 | 184 | let title = bs.getItemTitle(-3); |
michael@0 | 185 | do_throw("getItemTitle accepted bad input"); |
michael@0 | 186 | } catch(ex) {} |
michael@0 | 187 | |
michael@0 | 188 | // get the folder that the bookmark is in |
michael@0 | 189 | let folderId = bs.getFolderIdForItem(newId); |
michael@0 | 190 | do_check_eq(folderId, testRoot); |
michael@0 | 191 | |
michael@0 | 192 | // test getItemIndex for bookmarks |
michael@0 | 193 | do_check_eq(bs.getItemIndex(newId), testStartIndex); |
michael@0 | 194 | |
michael@0 | 195 | // create a folder at a specific index |
michael@0 | 196 | let workFolder = bs.createFolder(testRoot, "Work", 0); |
michael@0 | 197 | do_check_eq(bookmarksObserver._itemAddedId, workFolder); |
michael@0 | 198 | do_check_eq(bookmarksObserver._itemAddedParent, testRoot); |
michael@0 | 199 | do_check_eq(bookmarksObserver._itemAddedIndex, 0); |
michael@0 | 200 | do_check_eq(bookmarksObserver._itemAddedURI, null); |
michael@0 | 201 | |
michael@0 | 202 | do_check_eq(bs.getItemTitle(workFolder), "Work"); |
michael@0 | 203 | bs.setItemTitle(workFolder, "Work #"); |
michael@0 | 204 | do_check_eq(bs.getItemTitle(workFolder), "Work #"); |
michael@0 | 205 | |
michael@0 | 206 | // add item into subfolder, specifying index |
michael@0 | 207 | let newId2 = bs.insertBookmark(workFolder, |
michael@0 | 208 | uri("http://developer.mozilla.org/"), |
michael@0 | 209 | 0, ""); |
michael@0 | 210 | do_check_eq(bookmarksObserver._itemAddedId, newId2); |
michael@0 | 211 | do_check_eq(bookmarksObserver._itemAddedParent, workFolder); |
michael@0 | 212 | do_check_eq(bookmarksObserver._itemAddedIndex, 0); |
michael@0 | 213 | |
michael@0 | 214 | // change item |
michael@0 | 215 | bs.setItemTitle(newId2, "DevMo"); |
michael@0 | 216 | do_check_eq(bookmarksObserver._itemChangedProperty, "title"); |
michael@0 | 217 | |
michael@0 | 218 | // insert item into subfolder |
michael@0 | 219 | let newId3 = bs.insertBookmark(workFolder, |
michael@0 | 220 | uri("http://msdn.microsoft.com/"), |
michael@0 | 221 | bs.DEFAULT_INDEX, ""); |
michael@0 | 222 | do_check_eq(bookmarksObserver._itemAddedId, newId3); |
michael@0 | 223 | do_check_eq(bookmarksObserver._itemAddedParent, workFolder); |
michael@0 | 224 | do_check_eq(bookmarksObserver._itemAddedIndex, 1); |
michael@0 | 225 | |
michael@0 | 226 | // change item |
michael@0 | 227 | bs.setItemTitle(newId3, "MSDN"); |
michael@0 | 228 | do_check_eq(bookmarksObserver._itemChangedProperty, "title"); |
michael@0 | 229 | |
michael@0 | 230 | // remove item |
michael@0 | 231 | bs.removeItem(newId2); |
michael@0 | 232 | do_check_eq(bookmarksObserver._itemRemovedId, newId2); |
michael@0 | 233 | do_check_eq(bookmarksObserver._itemRemovedFolder, workFolder); |
michael@0 | 234 | do_check_eq(bookmarksObserver._itemRemovedIndex, 0); |
michael@0 | 235 | |
michael@0 | 236 | // insert item into subfolder |
michael@0 | 237 | let newId4 = bs.insertBookmark(workFolder, |
michael@0 | 238 | uri("http://developer.mozilla.org/"), |
michael@0 | 239 | bs.DEFAULT_INDEX, ""); |
michael@0 | 240 | do_check_eq(bookmarksObserver._itemAddedId, newId4); |
michael@0 | 241 | do_check_eq(bookmarksObserver._itemAddedParent, workFolder); |
michael@0 | 242 | do_check_eq(bookmarksObserver._itemAddedIndex, 1); |
michael@0 | 243 | |
michael@0 | 244 | // create folder |
michael@0 | 245 | let homeFolder = bs.createFolder(testRoot, "Home", bs.DEFAULT_INDEX); |
michael@0 | 246 | do_check_eq(bookmarksObserver._itemAddedId, homeFolder); |
michael@0 | 247 | do_check_eq(bookmarksObserver._itemAddedParent, testRoot); |
michael@0 | 248 | do_check_eq(bookmarksObserver._itemAddedIndex, 2); |
michael@0 | 249 | |
michael@0 | 250 | // insert item |
michael@0 | 251 | let newId5 = bs.insertBookmark(homeFolder, uri("http://espn.com/"), |
michael@0 | 252 | bs.DEFAULT_INDEX, ""); |
michael@0 | 253 | do_check_eq(bookmarksObserver._itemAddedId, newId5); |
michael@0 | 254 | do_check_eq(bookmarksObserver._itemAddedParent, homeFolder); |
michael@0 | 255 | do_check_eq(bookmarksObserver._itemAddedIndex, 0); |
michael@0 | 256 | |
michael@0 | 257 | // change item |
michael@0 | 258 | bs.setItemTitle(newId5, "ESPN"); |
michael@0 | 259 | do_check_eq(bookmarksObserver._itemChangedId, newId5); |
michael@0 | 260 | do_check_eq(bookmarksObserver._itemChangedProperty, "title"); |
michael@0 | 261 | |
michael@0 | 262 | // insert query item |
michael@0 | 263 | let uri6 = uri("place:domain=google.com&type="+ |
michael@0 | 264 | Ci.nsINavHistoryQueryOptions.RESULTS_AS_SITE_QUERY); |
michael@0 | 265 | let newId6 = bs.insertBookmark(testRoot, uri6, bs.DEFAULT_INDEX, ""); |
michael@0 | 266 | do_check_eq(bookmarksObserver._itemAddedParent, testRoot); |
michael@0 | 267 | do_check_eq(bookmarksObserver._itemAddedIndex, 3); |
michael@0 | 268 | |
michael@0 | 269 | // change item |
michael@0 | 270 | bs.setItemTitle(newId6, "Google Sites"); |
michael@0 | 271 | do_check_eq(bookmarksObserver._itemChangedProperty, "title"); |
michael@0 | 272 | |
michael@0 | 273 | // test getIdForItemAt |
michael@0 | 274 | do_check_eq(bs.getIdForItemAt(testRoot, 0), workFolder); |
michael@0 | 275 | // wrong parent, should return -1 |
michael@0 | 276 | do_check_eq(bs.getIdForItemAt(1337, 0), -1); |
michael@0 | 277 | // wrong index, should return -1 |
michael@0 | 278 | do_check_eq(bs.getIdForItemAt(testRoot, 1337), -1); |
michael@0 | 279 | // wrong parent and index, should return -1 |
michael@0 | 280 | do_check_eq(bs.getIdForItemAt(1337, 1337), -1); |
michael@0 | 281 | |
michael@0 | 282 | // move folder, appending, to different folder |
michael@0 | 283 | let oldParentCC = getChildCount(testRoot); |
michael@0 | 284 | bs.moveItem(workFolder, homeFolder, bs.DEFAULT_INDEX); |
michael@0 | 285 | do_check_eq(bookmarksObserver._itemMovedId, workFolder); |
michael@0 | 286 | do_check_eq(bookmarksObserver._itemMovedOldParent, testRoot); |
michael@0 | 287 | do_check_eq(bookmarksObserver._itemMovedOldIndex, 0); |
michael@0 | 288 | do_check_eq(bookmarksObserver._itemMovedNewParent, homeFolder); |
michael@0 | 289 | do_check_eq(bookmarksObserver._itemMovedNewIndex, 1); |
michael@0 | 290 | |
michael@0 | 291 | // test that the new index is properly stored |
michael@0 | 292 | do_check_eq(bs.getItemIndex(workFolder), 1); |
michael@0 | 293 | do_check_eq(bs.getFolderIdForItem(workFolder), homeFolder); |
michael@0 | 294 | |
michael@0 | 295 | // try to get index of the item from within the old parent folder |
michael@0 | 296 | // check that it has been really removed from there |
michael@0 | 297 | do_check_neq(bs.getIdForItemAt(testRoot, 0), workFolder); |
michael@0 | 298 | // check the last item from within the old parent folder |
michael@0 | 299 | do_check_neq(bs.getIdForItemAt(testRoot, -1), workFolder); |
michael@0 | 300 | // check the index of the item within the new parent folder |
michael@0 | 301 | do_check_eq(bs.getIdForItemAt(homeFolder, 1), workFolder); |
michael@0 | 302 | // try to get index of the last item within the new parent folder |
michael@0 | 303 | do_check_eq(bs.getIdForItemAt(homeFolder, -1), workFolder); |
michael@0 | 304 | // XXX expose FolderCount, and check that the old parent has one less child? |
michael@0 | 305 | do_check_eq(getChildCount(testRoot), oldParentCC-1); |
michael@0 | 306 | |
michael@0 | 307 | // move item, appending, to different folder |
michael@0 | 308 | bs.moveItem(newId5, testRoot, bs.DEFAULT_INDEX); |
michael@0 | 309 | do_check_eq(bookmarksObserver._itemMovedId, newId5); |
michael@0 | 310 | do_check_eq(bookmarksObserver._itemMovedOldParent, homeFolder); |
michael@0 | 311 | do_check_eq(bookmarksObserver._itemMovedOldIndex, 0); |
michael@0 | 312 | do_check_eq(bookmarksObserver._itemMovedNewParent, testRoot); |
michael@0 | 313 | do_check_eq(bookmarksObserver._itemMovedNewIndex, 3); |
michael@0 | 314 | |
michael@0 | 315 | // test get folder's index |
michael@0 | 316 | let tmpFolder = bs.createFolder(testRoot, "tmp", 2); |
michael@0 | 317 | do_check_eq(bs.getItemIndex(tmpFolder), 2); |
michael@0 | 318 | |
michael@0 | 319 | // test setKeywordForBookmark |
michael@0 | 320 | let kwTestItemId = bs.insertBookmark(testRoot, uri("http://keywordtest.com"), |
michael@0 | 321 | bs.DEFAULT_INDEX, ""); |
michael@0 | 322 | try { |
michael@0 | 323 | let dateAdded = bs.getItemDateAdded(kwTestItemId); |
michael@0 | 324 | // after just inserting, modified should not be set |
michael@0 | 325 | let lastModified = bs.getItemLastModified(kwTestItemId); |
michael@0 | 326 | do_check_eq(lastModified, dateAdded); |
michael@0 | 327 | |
michael@0 | 328 | // Workaround possible VM timers issues moving lastModified and dateAdded |
michael@0 | 329 | // to the past. |
michael@0 | 330 | bs.setItemLastModified(kwTestItemId, --lastModified); |
michael@0 | 331 | bs.setItemDateAdded(kwTestItemId, --dateAdded); |
michael@0 | 332 | |
michael@0 | 333 | bs.setKeywordForBookmark(kwTestItemId, "bar"); |
michael@0 | 334 | |
michael@0 | 335 | let lastModified2 = bs.getItemLastModified(kwTestItemId); |
michael@0 | 336 | LOG("test setKeywordForBookmark"); |
michael@0 | 337 | LOG("dateAdded = " + dateAdded); |
michael@0 | 338 | LOG("lastModified = " + lastModified); |
michael@0 | 339 | LOG("lastModified2 = " + lastModified2); |
michael@0 | 340 | do_check_true(is_time_ordered(lastModified, lastModified2)); |
michael@0 | 341 | do_check_true(is_time_ordered(dateAdded, lastModified2)); |
michael@0 | 342 | } catch(ex) { |
michael@0 | 343 | do_throw("setKeywordForBookmark: " + ex); |
michael@0 | 344 | } |
michael@0 | 345 | |
michael@0 | 346 | let lastModified3 = bs.getItemLastModified(kwTestItemId); |
michael@0 | 347 | // test getKeywordForBookmark |
michael@0 | 348 | let k = bs.getKeywordForBookmark(kwTestItemId); |
michael@0 | 349 | do_check_eq("bar", k); |
michael@0 | 350 | |
michael@0 | 351 | // test getKeywordForURI |
michael@0 | 352 | let k = bs.getKeywordForURI(uri("http://keywordtest.com/")); |
michael@0 | 353 | do_check_eq("bar", k); |
michael@0 | 354 | |
michael@0 | 355 | // test getURIForKeyword |
michael@0 | 356 | let u = bs.getURIForKeyword("bar"); |
michael@0 | 357 | do_check_eq("http://keywordtest.com/", u.spec); |
michael@0 | 358 | |
michael@0 | 359 | // test removeFolderChildren |
michael@0 | 360 | // 1) add/remove each child type (bookmark, separator, folder) |
michael@0 | 361 | let tmpFolder = bs.createFolder(testRoot, "removeFolderChildren", |
michael@0 | 362 | bs.DEFAULT_INDEX); |
michael@0 | 363 | bs.insertBookmark(tmpFolder, uri("http://foo9.com/"), bs.DEFAULT_INDEX, ""); |
michael@0 | 364 | bs.createFolder(tmpFolder, "subfolder", bs.DEFAULT_INDEX); |
michael@0 | 365 | bs.insertSeparator(tmpFolder, bs.DEFAULT_INDEX); |
michael@0 | 366 | // 2) confirm that folder has 3 children |
michael@0 | 367 | let options = hs.getNewQueryOptions(); |
michael@0 | 368 | let query = hs.getNewQuery(); |
michael@0 | 369 | query.setFolders([tmpFolder], 1); |
michael@0 | 370 | try { |
michael@0 | 371 | let result = hs.executeQuery(query, options); |
michael@0 | 372 | let rootNode = result.root; |
michael@0 | 373 | rootNode.containerOpen = true; |
michael@0 | 374 | do_check_eq(rootNode.childCount, 3); |
michael@0 | 375 | rootNode.containerOpen = false; |
michael@0 | 376 | } catch(ex) { |
michael@0 | 377 | do_throw("test removeFolderChildren() - querying for children failed: " + ex); |
michael@0 | 378 | } |
michael@0 | 379 | // 3) remove all children |
michael@0 | 380 | bs.removeFolderChildren(tmpFolder); |
michael@0 | 381 | // 4) confirm that folder has 0 children |
michael@0 | 382 | try { |
michael@0 | 383 | result = hs.executeQuery(query, options); |
michael@0 | 384 | let rootNode = result.root; |
michael@0 | 385 | rootNode.containerOpen = true; |
michael@0 | 386 | do_check_eq(rootNode.childCount, 0); |
michael@0 | 387 | rootNode.containerOpen = false; |
michael@0 | 388 | } catch(ex) { |
michael@0 | 389 | do_throw("removeFolderChildren(): " + ex); |
michael@0 | 390 | } |
michael@0 | 391 | |
michael@0 | 392 | // XXX - test folderReadOnly |
michael@0 | 393 | |
michael@0 | 394 | // test bookmark id in query output |
michael@0 | 395 | try { |
michael@0 | 396 | let options = hs.getNewQueryOptions(); |
michael@0 | 397 | let query = hs.getNewQuery(); |
michael@0 | 398 | query.setFolders([testRoot], 1); |
michael@0 | 399 | let result = hs.executeQuery(query, options); |
michael@0 | 400 | let rootNode = result.root; |
michael@0 | 401 | rootNode.containerOpen = true; |
michael@0 | 402 | let cc = rootNode.childCount; |
michael@0 | 403 | LOG("bookmark itemId test: CC = " + cc); |
michael@0 | 404 | do_check_true(cc > 0); |
michael@0 | 405 | for (let i=0; i < cc; ++i) { |
michael@0 | 406 | let node = rootNode.getChild(i); |
michael@0 | 407 | if (node.type == node.RESULT_TYPE_FOLDER || |
michael@0 | 408 | node.type == node.RESULT_TYPE_URI || |
michael@0 | 409 | node.type == node.RESULT_TYPE_SEPARATOR || |
michael@0 | 410 | node.type == node.RESULT_TYPE_QUERY) { |
michael@0 | 411 | do_check_true(node.itemId > 0); |
michael@0 | 412 | } |
michael@0 | 413 | else { |
michael@0 | 414 | do_check_eq(node.itemId, -1); |
michael@0 | 415 | } |
michael@0 | 416 | } |
michael@0 | 417 | rootNode.containerOpen = false; |
michael@0 | 418 | } |
michael@0 | 419 | catch(ex) { |
michael@0 | 420 | do_throw("bookmarks query: " + ex); |
michael@0 | 421 | } |
michael@0 | 422 | |
michael@0 | 423 | // test that multiple bookmarks with same URI show up right in bookmark |
michael@0 | 424 | // folder queries, todo: also to do for complex folder queries |
michael@0 | 425 | try { |
michael@0 | 426 | // test uri |
michael@0 | 427 | let mURI = uri("http://multiple.uris.in.query"); |
michael@0 | 428 | |
michael@0 | 429 | let testFolder = bs.createFolder(testRoot, "test Folder", bs.DEFAULT_INDEX); |
michael@0 | 430 | // add 2 bookmarks |
michael@0 | 431 | bs.insertBookmark(testFolder, mURI, bs.DEFAULT_INDEX, "title 1"); |
michael@0 | 432 | bs.insertBookmark(testFolder, mURI, bs.DEFAULT_INDEX, "title 2"); |
michael@0 | 433 | |
michael@0 | 434 | // query |
michael@0 | 435 | let options = hs.getNewQueryOptions(); |
michael@0 | 436 | let query = hs.getNewQuery(); |
michael@0 | 437 | query.setFolders([testFolder], 1); |
michael@0 | 438 | let result = hs.executeQuery(query, options); |
michael@0 | 439 | let rootNode = result.root; |
michael@0 | 440 | rootNode.containerOpen = true; |
michael@0 | 441 | let cc = rootNode.childCount; |
michael@0 | 442 | do_check_eq(cc, 2); |
michael@0 | 443 | do_check_eq(rootNode.getChild(0).title, "title 1"); |
michael@0 | 444 | do_check_eq(rootNode.getChild(1).title, "title 2"); |
michael@0 | 445 | rootNode.containerOpen = false; |
michael@0 | 446 | } |
michael@0 | 447 | catch(ex) { |
michael@0 | 448 | do_throw("bookmarks query: " + ex); |
michael@0 | 449 | } |
michael@0 | 450 | |
michael@0 | 451 | // test change bookmark uri |
michael@0 | 452 | let newId10 = bs.insertBookmark(testRoot, uri("http://foo10.com/"), |
michael@0 | 453 | bs.DEFAULT_INDEX, ""); |
michael@0 | 454 | let dateAdded = bs.getItemDateAdded(newId10); |
michael@0 | 455 | // after just inserting, modified should not be set |
michael@0 | 456 | let lastModified = bs.getItemLastModified(newId10); |
michael@0 | 457 | do_check_eq(lastModified, dateAdded); |
michael@0 | 458 | |
michael@0 | 459 | // Workaround possible VM timers issues moving lastModified and dateAdded |
michael@0 | 460 | // to the past. |
michael@0 | 461 | bs.setItemLastModified(newId10, --lastModified); |
michael@0 | 462 | bs.setItemDateAdded(newId10, --dateAdded); |
michael@0 | 463 | |
michael@0 | 464 | bs.changeBookmarkURI(newId10, uri("http://foo11.com/")); |
michael@0 | 465 | |
michael@0 | 466 | // check that lastModified is set after we change the bookmark uri |
michael@0 | 467 | let lastModified2 = bs.getItemLastModified(newId10); |
michael@0 | 468 | LOG("test changeBookmarkURI"); |
michael@0 | 469 | LOG("dateAdded = " + dateAdded); |
michael@0 | 470 | LOG("lastModified = " + lastModified); |
michael@0 | 471 | LOG("lastModified2 = " + lastModified2); |
michael@0 | 472 | do_check_true(is_time_ordered(lastModified, lastModified2)); |
michael@0 | 473 | do_check_true(is_time_ordered(dateAdded, lastModified2)); |
michael@0 | 474 | |
michael@0 | 475 | do_check_eq(bookmarksObserver._itemChangedId, newId10); |
michael@0 | 476 | do_check_eq(bookmarksObserver._itemChangedProperty, "uri"); |
michael@0 | 477 | do_check_eq(bookmarksObserver._itemChangedValue, "http://foo11.com/"); |
michael@0 | 478 | |
michael@0 | 479 | // test getBookmarkURI |
michael@0 | 480 | let newId11 = bs.insertBookmark(testRoot, uri("http://foo11.com/"), |
michael@0 | 481 | bs.DEFAULT_INDEX, ""); |
michael@0 | 482 | let bmURI = bs.getBookmarkURI(newId11); |
michael@0 | 483 | do_check_eq("http://foo11.com/", bmURI.spec); |
michael@0 | 484 | |
michael@0 | 485 | // test getBookmarkURI with non-bookmark items |
michael@0 | 486 | try { |
michael@0 | 487 | bs.getBookmarkURI(testRoot); |
michael@0 | 488 | do_throw("getBookmarkURI() should throw for non-bookmark items!"); |
michael@0 | 489 | } catch(ex) {} |
michael@0 | 490 | |
michael@0 | 491 | // test getItemIndex |
michael@0 | 492 | let newId12 = bs.insertBookmark(testRoot, uri("http://foo11.com/"), 1, ""); |
michael@0 | 493 | let bmIndex = bs.getItemIndex(newId12); |
michael@0 | 494 | do_check_eq(1, bmIndex); |
michael@0 | 495 | |
michael@0 | 496 | // insert a bookmark with title ZZZXXXYYY and then search for it. |
michael@0 | 497 | // this test confirms that we can find bookmarks that we haven't visited |
michael@0 | 498 | // (which are "hidden") and that we can find by title. |
michael@0 | 499 | // see bug #369887 for more details |
michael@0 | 500 | let newId13 = bs.insertBookmark(testRoot, uri("http://foobarcheese.com/"), |
michael@0 | 501 | bs.DEFAULT_INDEX, ""); |
michael@0 | 502 | do_check_eq(bookmarksObserver._itemAddedId, newId13); |
michael@0 | 503 | do_check_eq(bookmarksObserver._itemAddedParent, testRoot); |
michael@0 | 504 | do_check_eq(bookmarksObserver._itemAddedIndex, 11); |
michael@0 | 505 | |
michael@0 | 506 | // set bookmark title |
michael@0 | 507 | bs.setItemTitle(newId13, "ZZZXXXYYY"); |
michael@0 | 508 | do_check_eq(bookmarksObserver._itemChangedId, newId13); |
michael@0 | 509 | do_check_eq(bookmarksObserver._itemChangedProperty, "title"); |
michael@0 | 510 | do_check_eq(bookmarksObserver._itemChangedValue, "ZZZXXXYYY"); |
michael@0 | 511 | |
michael@0 | 512 | // check if setting an item annotation triggers onItemChanged |
michael@0 | 513 | bookmarksObserver._itemChangedId = -1; |
michael@0 | 514 | anno.setItemAnnotation(newId3, "test-annotation", "foo", 0, 0); |
michael@0 | 515 | do_check_eq(bookmarksObserver._itemChangedId, newId3); |
michael@0 | 516 | do_check_eq(bookmarksObserver._itemChangedProperty, "test-annotation"); |
michael@0 | 517 | do_check_true(bookmarksObserver._itemChanged_isAnnotationProperty); |
michael@0 | 518 | do_check_eq(bookmarksObserver._itemChangedValue, ""); |
michael@0 | 519 | |
michael@0 | 520 | // test search on bookmark title ZZZXXXYYY |
michael@0 | 521 | try { |
michael@0 | 522 | let options = hs.getNewQueryOptions(); |
michael@0 | 523 | options.excludeQueries = 1; |
michael@0 | 524 | options.queryType = Ci.nsINavHistoryQueryOptions.QUERY_TYPE_BOOKMARKS; |
michael@0 | 525 | let query = hs.getNewQuery(); |
michael@0 | 526 | query.searchTerms = "ZZZXXXYYY"; |
michael@0 | 527 | let result = hs.executeQuery(query, options); |
michael@0 | 528 | let rootNode = result.root; |
michael@0 | 529 | rootNode.containerOpen = true; |
michael@0 | 530 | let cc = rootNode.childCount; |
michael@0 | 531 | do_check_eq(cc, 1); |
michael@0 | 532 | let node = rootNode.getChild(0); |
michael@0 | 533 | do_check_eq(node.title, "ZZZXXXYYY"); |
michael@0 | 534 | do_check_true(node.itemId > 0); |
michael@0 | 535 | rootNode.containerOpen = false; |
michael@0 | 536 | } |
michael@0 | 537 | catch(ex) { |
michael@0 | 538 | do_throw("bookmarks query: " + ex); |
michael@0 | 539 | } |
michael@0 | 540 | |
michael@0 | 541 | // test dateAdded and lastModified properties |
michael@0 | 542 | // for a search query |
michael@0 | 543 | try { |
michael@0 | 544 | let options = hs.getNewQueryOptions(); |
michael@0 | 545 | options.excludeQueries = 1; |
michael@0 | 546 | options.queryType = Ci.nsINavHistoryQueryOptions.QUERY_TYPE_BOOKMARKS; |
michael@0 | 547 | let query = hs.getNewQuery(); |
michael@0 | 548 | query.searchTerms = "ZZZXXXYYY"; |
michael@0 | 549 | let result = hs.executeQuery(query, options); |
michael@0 | 550 | let rootNode = result.root; |
michael@0 | 551 | rootNode.containerOpen = true; |
michael@0 | 552 | let cc = rootNode.childCount; |
michael@0 | 553 | do_check_eq(cc, 1); |
michael@0 | 554 | let node = rootNode.getChild(0); |
michael@0 | 555 | |
michael@0 | 556 | do_check_eq(typeof node.dateAdded, "number"); |
michael@0 | 557 | do_check_true(node.dateAdded > 0); |
michael@0 | 558 | |
michael@0 | 559 | do_check_eq(typeof node.lastModified, "number"); |
michael@0 | 560 | do_check_true(node.lastModified > 0); |
michael@0 | 561 | |
michael@0 | 562 | rootNode.containerOpen = false; |
michael@0 | 563 | } |
michael@0 | 564 | catch(ex) { |
michael@0 | 565 | do_throw("bookmarks query: " + ex); |
michael@0 | 566 | } |
michael@0 | 567 | |
michael@0 | 568 | // test dateAdded and lastModified properties |
michael@0 | 569 | // for a folder query |
michael@0 | 570 | try { |
michael@0 | 571 | let options = hs.getNewQueryOptions(); |
michael@0 | 572 | let query = hs.getNewQuery(); |
michael@0 | 573 | query.setFolders([testRoot], 1); |
michael@0 | 574 | let result = hs.executeQuery(query, options); |
michael@0 | 575 | let rootNode = result.root; |
michael@0 | 576 | rootNode.containerOpen = true; |
michael@0 | 577 | let cc = rootNode.childCount; |
michael@0 | 578 | do_check_true(cc > 0); |
michael@0 | 579 | for (let i = 0; i < cc; i++) { |
michael@0 | 580 | let node = rootNode.getChild(i); |
michael@0 | 581 | |
michael@0 | 582 | if (node.type == node.RESULT_TYPE_URI) { |
michael@0 | 583 | do_check_eq(typeof node.dateAdded, "number"); |
michael@0 | 584 | do_check_true(node.dateAdded > 0); |
michael@0 | 585 | |
michael@0 | 586 | do_check_eq(typeof node.lastModified, "number"); |
michael@0 | 587 | do_check_true(node.lastModified > 0); |
michael@0 | 588 | break; |
michael@0 | 589 | } |
michael@0 | 590 | } |
michael@0 | 591 | rootNode.containerOpen = false; |
michael@0 | 592 | } |
michael@0 | 593 | catch(ex) { |
michael@0 | 594 | do_throw("bookmarks query: " + ex); |
michael@0 | 595 | } |
michael@0 | 596 | |
michael@0 | 597 | // check setItemLastModified() and setItemDateAdded() |
michael@0 | 598 | let newId14 = bs.insertBookmark(testRoot, uri("http://bar.tld/"), |
michael@0 | 599 | bs.DEFAULT_INDEX, ""); |
michael@0 | 600 | let dateAdded = bs.getItemDateAdded(newId14); |
michael@0 | 601 | let lastModified = bs.getItemLastModified(newId14); |
michael@0 | 602 | do_check_eq(lastModified, dateAdded); |
michael@0 | 603 | bs.setItemLastModified(newId14, 1234); |
michael@0 | 604 | let fakeLastModified = bs.getItemLastModified(newId14); |
michael@0 | 605 | do_check_eq(fakeLastModified, 1234); |
michael@0 | 606 | bs.setItemDateAdded(newId14, 4321); |
michael@0 | 607 | let fakeDateAdded = bs.getItemDateAdded(newId14); |
michael@0 | 608 | do_check_eq(fakeDateAdded, 4321); |
michael@0 | 609 | |
michael@0 | 610 | // ensure that removing an item removes its annotations |
michael@0 | 611 | do_check_true(anno.itemHasAnnotation(newId3, "test-annotation")); |
michael@0 | 612 | bs.removeItem(newId3); |
michael@0 | 613 | do_check_false(anno.itemHasAnnotation(newId3, "test-annotation")); |
michael@0 | 614 | |
michael@0 | 615 | // bug 378820 |
michael@0 | 616 | let uri1 = uri("http://foo.tld/a"); |
michael@0 | 617 | bs.insertBookmark(testRoot, uri1, bs.DEFAULT_INDEX, ""); |
michael@0 | 618 | yield promiseAddVisits(uri1); |
michael@0 | 619 | |
michael@0 | 620 | // bug 646993 - test bookmark titles longer than the maximum allowed length |
michael@0 | 621 | let title15 = Array(TITLE_LENGTH_MAX + 5).join("X"); |
michael@0 | 622 | let title15expected = title15.substring(0, TITLE_LENGTH_MAX); |
michael@0 | 623 | let newId15 = bs.insertBookmark(testRoot, uri("http://evil.com/"), |
michael@0 | 624 | bs.DEFAULT_INDEX, title15); |
michael@0 | 625 | |
michael@0 | 626 | do_check_eq(bs.getItemTitle(newId15).length, |
michael@0 | 627 | title15expected.length); |
michael@0 | 628 | do_check_eq(bookmarksObserver._itemAddedTitle, title15expected); |
michael@0 | 629 | // test title length after updates |
michael@0 | 630 | bs.setItemTitle(newId15, title15 + " updated"); |
michael@0 | 631 | do_check_eq(bs.getItemTitle(newId15).length, |
michael@0 | 632 | title15expected.length); |
michael@0 | 633 | do_check_eq(bookmarksObserver._itemChangedId, newId15); |
michael@0 | 634 | do_check_eq(bookmarksObserver._itemChangedProperty, "title"); |
michael@0 | 635 | do_check_eq(bookmarksObserver._itemChangedValue, title15expected); |
michael@0 | 636 | |
michael@0 | 637 | testSimpleFolderResult(); |
michael@0 | 638 | }); |
michael@0 | 639 | |
michael@0 | 640 | function testSimpleFolderResult() { |
michael@0 | 641 | // the time before we create a folder, in microseconds |
michael@0 | 642 | // Workaround possible VM timers issues subtracting 1us. |
michael@0 | 643 | let beforeCreate = Date.now() * 1000 - 1; |
michael@0 | 644 | do_check_true(beforeCreate > 0); |
michael@0 | 645 | |
michael@0 | 646 | // create a folder |
michael@0 | 647 | let parent = bs.createFolder(root, "test", bs.DEFAULT_INDEX); |
michael@0 | 648 | |
michael@0 | 649 | let dateCreated = bs.getItemDateAdded(parent); |
michael@0 | 650 | LOG("check that the folder was created with a valid dateAdded"); |
michael@0 | 651 | LOG("beforeCreate = " + beforeCreate); |
michael@0 | 652 | LOG("dateCreated = " + dateCreated); |
michael@0 | 653 | do_check_true(is_time_ordered(beforeCreate, dateCreated)); |
michael@0 | 654 | |
michael@0 | 655 | // the time before we insert, in microseconds |
michael@0 | 656 | // Workaround possible VM timers issues subtracting 1ms. |
michael@0 | 657 | let beforeInsert = Date.now() * 1000 - 1; |
michael@0 | 658 | do_check_true(beforeInsert > 0); |
michael@0 | 659 | |
michael@0 | 660 | // insert a separator |
michael@0 | 661 | let sep = bs.insertSeparator(parent, bs.DEFAULT_INDEX); |
michael@0 | 662 | |
michael@0 | 663 | let dateAdded = bs.getItemDateAdded(sep); |
michael@0 | 664 | LOG("check that the separator was created with a valid dateAdded"); |
michael@0 | 665 | LOG("beforeInsert = " + beforeInsert); |
michael@0 | 666 | LOG("dateAdded = " + dateAdded); |
michael@0 | 667 | do_check_true(is_time_ordered(beforeInsert, dateAdded)); |
michael@0 | 668 | |
michael@0 | 669 | // re-set item title separately so can test nodes' last modified |
michael@0 | 670 | let item = bs.insertBookmark(parent, uri("about:blank"), |
michael@0 | 671 | bs.DEFAULT_INDEX, ""); |
michael@0 | 672 | bs.setItemTitle(item, "test bookmark"); |
michael@0 | 673 | |
michael@0 | 674 | // see above |
michael@0 | 675 | let folder = bs.createFolder(parent, "test folder", bs.DEFAULT_INDEX); |
michael@0 | 676 | bs.setItemTitle(folder, "test folder"); |
michael@0 | 677 | |
michael@0 | 678 | let longName = Array(TITLE_LENGTH_MAX + 5).join("A"); |
michael@0 | 679 | let folderLongName = bs.createFolder(parent, longName, bs.DEFAULT_INDEX); |
michael@0 | 680 | do_check_eq(bookmarksObserver._itemAddedTitle, longName.substring(0, TITLE_LENGTH_MAX)); |
michael@0 | 681 | |
michael@0 | 682 | let options = hs.getNewQueryOptions(); |
michael@0 | 683 | let query = hs.getNewQuery(); |
michael@0 | 684 | query.setFolders([parent], 1); |
michael@0 | 685 | let result = hs.executeQuery(query, options); |
michael@0 | 686 | let rootNode = result.root; |
michael@0 | 687 | rootNode.containerOpen = true; |
michael@0 | 688 | do_check_eq(rootNode.childCount, 4); |
michael@0 | 689 | |
michael@0 | 690 | let node = rootNode.getChild(0); |
michael@0 | 691 | do_check_true(node.dateAdded > 0); |
michael@0 | 692 | do_check_eq(node.lastModified, node.dateAdded); |
michael@0 | 693 | do_check_eq(node.itemId, sep); |
michael@0 | 694 | do_check_eq(node.title, ""); |
michael@0 | 695 | node = rootNode.getChild(1); |
michael@0 | 696 | do_check_eq(node.itemId, item); |
michael@0 | 697 | do_check_true(node.dateAdded > 0); |
michael@0 | 698 | do_check_true(node.lastModified > 0); |
michael@0 | 699 | do_check_eq(node.title, "test bookmark"); |
michael@0 | 700 | node = rootNode.getChild(2); |
michael@0 | 701 | do_check_eq(node.itemId, folder); |
michael@0 | 702 | do_check_eq(node.title, "test folder"); |
michael@0 | 703 | do_check_true(node.dateAdded > 0); |
michael@0 | 704 | do_check_true(node.lastModified > 0); |
michael@0 | 705 | node = rootNode.getChild(3); |
michael@0 | 706 | do_check_eq(node.itemId, folderLongName); |
michael@0 | 707 | do_check_eq(node.title, longName.substring(0, TITLE_LENGTH_MAX)); |
michael@0 | 708 | do_check_true(node.dateAdded > 0); |
michael@0 | 709 | do_check_true(node.lastModified > 0); |
michael@0 | 710 | |
michael@0 | 711 | // update with another long title |
michael@0 | 712 | bs.setItemTitle(folderLongName, longName + " updated"); |
michael@0 | 713 | do_check_eq(bookmarksObserver._itemChangedId, folderLongName); |
michael@0 | 714 | do_check_eq(bookmarksObserver._itemChangedProperty, "title"); |
michael@0 | 715 | do_check_eq(bookmarksObserver._itemChangedValue, longName.substring(0, TITLE_LENGTH_MAX)); |
michael@0 | 716 | |
michael@0 | 717 | node = rootNode.getChild(3); |
michael@0 | 718 | do_check_eq(node.title, longName.substring(0, TITLE_LENGTH_MAX)); |
michael@0 | 719 | |
michael@0 | 720 | rootNode.containerOpen = false; |
michael@0 | 721 | } |
michael@0 | 722 | |
michael@0 | 723 | function getChildCount(aFolderId) { |
michael@0 | 724 | let cc = -1; |
michael@0 | 725 | try { |
michael@0 | 726 | let options = hs.getNewQueryOptions(); |
michael@0 | 727 | let query = hs.getNewQuery(); |
michael@0 | 728 | query.setFolders([aFolderId], 1); |
michael@0 | 729 | let result = hs.executeQuery(query, options); |
michael@0 | 730 | let rootNode = result.root; |
michael@0 | 731 | rootNode.containerOpen = true; |
michael@0 | 732 | cc = rootNode.childCount; |
michael@0 | 733 | rootNode.containerOpen = false; |
michael@0 | 734 | } catch(ex) { |
michael@0 | 735 | do_throw("getChildCount failed: " + ex); |
michael@0 | 736 | } |
michael@0 | 737 | return cc; |
michael@0 | 738 | } |