1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/components/places/tests/bookmarks/test_711914.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,57 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this file, 1.6 + * You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +function run_test() { 1.9 + /** 1.10 + * Requests information to the service, so that bookmark's data is cached. 1.11 + * @param aItemId 1.12 + * Id of the bookmark to be cached. 1.13 + */ 1.14 + function forceBookmarkCaching(aItemId) { 1.15 + let parent = PlacesUtils.bookmarks.getFolderIdForItem(aItemId); 1.16 + PlacesUtils.bookmarks.getFolderIdForItem(parent); 1.17 + } 1.18 + 1.19 + let observer = { 1.20 + onBeginUpdateBatch: function () forceBookmarkCaching(itemId1), 1.21 + onEndUpdateBatch: function () forceBookmarkCaching(itemId1), 1.22 + onItemAdded: forceBookmarkCaching, 1.23 + onItemChanged: forceBookmarkCaching, 1.24 + onItemMoved: forceBookmarkCaching, 1.25 + onItemRemoved: function (id) { 1.26 + try { 1.27 + forceBookmarkCaching(id); 1.28 + do_throw("trying to fetch a removed bookmark should throw"); 1.29 + } catch (ex) {} 1.30 + }, 1.31 + onItemVisited: forceBookmarkCaching, 1.32 + QueryInterface: XPCOMUtils.generateQI([Ci.nsINavBookmarkObserver]) 1.33 + }; 1.34 + PlacesUtils.bookmarks.addObserver(observer, false); 1.35 + 1.36 + let folder1 = PlacesUtils.bookmarks 1.37 + .createFolder(PlacesUtils.bookmarksMenuFolderId, 1.38 + "Folder1", 1.39 + PlacesUtils.bookmarks.DEFAULT_INDEX); 1.40 + let folder2 = PlacesUtils.bookmarks 1.41 + .createFolder(folder1, 1.42 + "Folder2", 1.43 + PlacesUtils.bookmarks.DEFAULT_INDEX); 1.44 + let itemId = PlacesUtils.bookmarks 1.45 + .insertBookmark(folder2, 1.46 + NetUtil.newURI("http://mozilla.org/"), 1.47 + PlacesUtils.bookmarks.DEFAULT_INDEX, 1.48 + "Mozilla"); 1.49 + 1.50 + PlacesUtils.bookmarks.removeFolderChildren(folder1); 1.51 + 1.52 + // Check title is correctly reported. 1.53 + do_check_eq(PlacesUtils.bookmarks.getItemTitle(folder1), "Folder1"); 1.54 + try { 1.55 + PlacesUtils.bookmarks.getItemTitle(folder2); 1.56 + do_throw("trying to fetch a removed bookmark should throw"); 1.57 + } catch (ex) {} 1.58 + 1.59 + PlacesUtils.bookmarks.removeObserver(observer, false); 1.60 +}