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.
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 | run_next_test(); |
michael@0 | 7 | } |
michael@0 | 8 | |
michael@0 | 9 | add_task(function test_execute() |
michael@0 | 10 | { |
michael@0 | 11 | PlacesUtils.bookmarks.insertBookmark( |
michael@0 | 12 | PlacesUtils.unfiledBookmarksFolderId, NetUtil.newURI("http://1.moz.org/"), |
michael@0 | 13 | PlacesUtils.bookmarks.DEFAULT_INDEX, "Bookmark 1" |
michael@0 | 14 | ); |
michael@0 | 15 | let id1 = PlacesUtils.bookmarks.insertBookmark( |
michael@0 | 16 | PlacesUtils.unfiledBookmarksFolderId, NetUtil.newURI("place:folder=1234"), |
michael@0 | 17 | PlacesUtils.bookmarks.DEFAULT_INDEX, "Shortcut 1" |
michael@0 | 18 | ); |
michael@0 | 19 | let id2 = PlacesUtils.bookmarks.insertBookmark( |
michael@0 | 20 | PlacesUtils.unfiledBookmarksFolderId, NetUtil.newURI("place:folder=-1"), |
michael@0 | 21 | PlacesUtils.bookmarks.DEFAULT_INDEX, "Shortcut 2" |
michael@0 | 22 | ); |
michael@0 | 23 | PlacesUtils.bookmarks.insertBookmark( |
michael@0 | 24 | PlacesUtils.unfiledBookmarksFolderId, NetUtil.newURI("http://2.moz.org/"), |
michael@0 | 25 | PlacesUtils.bookmarks.DEFAULT_INDEX, "Bookmark 2" |
michael@0 | 26 | ); |
michael@0 | 27 | |
michael@0 | 28 | // Add also a simple visit. |
michael@0 | 29 | yield promiseAddVisits(uri(("http://3.moz.org/"))); |
michael@0 | 30 | |
michael@0 | 31 | // Query containing a broken folder shortcuts among results. |
michael@0 | 32 | let query = PlacesUtils.history.getNewQuery(); |
michael@0 | 33 | query.setFolders([PlacesUtils.unfiledBookmarksFolderId], 1); |
michael@0 | 34 | let options = PlacesUtils.history.getNewQueryOptions(); |
michael@0 | 35 | let root = PlacesUtils.history.executeQuery(query, options).root; |
michael@0 | 36 | root.containerOpen = true; |
michael@0 | 37 | |
michael@0 | 38 | do_check_eq(root.childCount, 4); |
michael@0 | 39 | |
michael@0 | 40 | let shortcut = root.getChild(1); |
michael@0 | 41 | do_check_eq(shortcut.uri, "place:folder=1234"); |
michael@0 | 42 | PlacesUtils.asContainer(shortcut); |
michael@0 | 43 | shortcut.containerOpen = true; |
michael@0 | 44 | do_check_eq(shortcut.childCount, 0); |
michael@0 | 45 | shortcut.containerOpen = false; |
michael@0 | 46 | // Remove the broken shortcut while the containing result is open. |
michael@0 | 47 | PlacesUtils.bookmarks.removeItem(id1); |
michael@0 | 48 | do_check_eq(root.childCount, 3); |
michael@0 | 49 | |
michael@0 | 50 | shortcut = root.getChild(1); |
michael@0 | 51 | do_check_eq(shortcut.uri, "place:folder=-1"); |
michael@0 | 52 | PlacesUtils.asContainer(shortcut); |
michael@0 | 53 | shortcut.containerOpen = true; |
michael@0 | 54 | do_check_eq(shortcut.childCount, 0); |
michael@0 | 55 | shortcut.containerOpen = false; |
michael@0 | 56 | // Remove the broken shortcut while the containing result is open. |
michael@0 | 57 | PlacesUtils.bookmarks.removeItem(id2); |
michael@0 | 58 | do_check_eq(root.childCount, 2); |
michael@0 | 59 | |
michael@0 | 60 | root.containerOpen = false; |
michael@0 | 61 | |
michael@0 | 62 | // Broken folder shortcut as root node. |
michael@0 | 63 | let query = PlacesUtils.history.getNewQuery(); |
michael@0 | 64 | query.setFolders([1234], 1); |
michael@0 | 65 | let options = PlacesUtils.history.getNewQueryOptions(); |
michael@0 | 66 | let root = PlacesUtils.history.executeQuery(query, options).root; |
michael@0 | 67 | root.containerOpen = true; |
michael@0 | 68 | do_check_eq(root.childCount, 0); |
michael@0 | 69 | root.containerOpen = false; |
michael@0 | 70 | |
michael@0 | 71 | // Broken folder shortcut as root node with folder=-1. |
michael@0 | 72 | query = PlacesUtils.history.getNewQuery(); |
michael@0 | 73 | query.setFolders([-1], 1); |
michael@0 | 74 | options = PlacesUtils.history.getNewQueryOptions(); |
michael@0 | 75 | root = PlacesUtils.history.executeQuery(query, options).root; |
michael@0 | 76 | root.containerOpen = true; |
michael@0 | 77 | do_check_eq(root.childCount, 0); |
michael@0 | 78 | root.containerOpen = false; |
michael@0 | 79 | }); |