toolkit/components/places/tests/bookmarks/test_675416.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 /* Any copyright is dedicated to the Public Domain.
michael@0 2 http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0 3
michael@0 4 function run_test() {
michael@0 5 /**
michael@0 6 * Requests information to the service, so that bookmark's data is cached.
michael@0 7 * @param aItemId
michael@0 8 * Id of the bookmark to be cached.
michael@0 9 */
michael@0 10 function forceBookmarkCaching(aItemId) {
michael@0 11 PlacesUtils.bookmarks.getFolderIdForItem(aItemId);
michael@0 12 }
michael@0 13
michael@0 14 let observer = {
michael@0 15 onBeginUpdateBatch: function() forceBookmarkCaching(itemId1),
michael@0 16 onEndUpdateBatch: function() forceBookmarkCaching(itemId1),
michael@0 17 onItemAdded: forceBookmarkCaching,
michael@0 18 onItemChanged: forceBookmarkCaching,
michael@0 19 onItemMoved: forceBookmarkCaching,
michael@0 20 onItemRemoved: function(id) {
michael@0 21 try {
michael@0 22 forceBookmarkCaching(id);
michael@0 23 do_throw("trying to fetch a removed bookmark should throw");
michael@0 24 } catch (ex) {}
michael@0 25 },
michael@0 26 onItemVisited: forceBookmarkCaching,
michael@0 27 QueryInterface: XPCOMUtils.generateQI([Ci.nsINavBookmarkObserver])
michael@0 28 };
michael@0 29 PlacesUtils.bookmarks.addObserver(observer, false);
michael@0 30
michael@0 31 let folderId1 = PlacesUtils.bookmarks
michael@0 32 .createFolder(PlacesUtils.bookmarksMenuFolderId,
michael@0 33 "Bookmarks",
michael@0 34 PlacesUtils.bookmarks.DEFAULT_INDEX);
michael@0 35 let itemId1 = PlacesUtils.bookmarks
michael@0 36 .insertBookmark(folderId1,
michael@0 37 NetUtil.newURI("http:/www.wired.com/wiredscience"),
michael@0 38 PlacesUtils.bookmarks.DEFAULT_INDEX,
michael@0 39 "Wired Science");
michael@0 40
michael@0 41 PlacesUtils.bookmarks.removeItem(folderId1);
michael@0 42
michael@0 43 let folderId2 = PlacesUtils.bookmarks
michael@0 44 .createFolder(PlacesUtils.bookmarksMenuFolderId,
michael@0 45 "Science",
michael@0 46 PlacesUtils.bookmarks.DEFAULT_INDEX);
michael@0 47 let folderId3 = PlacesUtils.bookmarks
michael@0 48 .createFolder(folderId2,
michael@0 49 "Blogs",
michael@0 50 PlacesUtils.bookmarks.DEFAULT_INDEX);
michael@0 51 // Check title is correctly reported.
michael@0 52 do_check_eq(PlacesUtils.bookmarks.getItemTitle(folderId3), "Blogs");
michael@0 53 do_check_eq(PlacesUtils.bookmarks.getItemTitle(folderId2), "Science");
michael@0 54
michael@0 55 PlacesUtils.bookmarks.removeObserver(observer, false);
michael@0 56 }

mercurial