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