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 | /* -*- 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 | /* |
michael@0 | 8 | * Tests nsNavHistoryContainerResultNode::GetChildIndex(aNode) functionality. |
michael@0 | 9 | */ |
michael@0 | 10 | |
michael@0 | 11 | function run_test() { |
michael@0 | 12 | // Add a bookmark to the menu. |
michael@0 | 13 | PlacesUtils.bookmarks.insertBookmark(PlacesUtils.bookmarksMenuFolderId, |
michael@0 | 14 | uri("http://test.mozilla.org/bookmark/"), |
michael@0 | 15 | Ci.nsINavBookmarksService.DEFAULT_INDEX, |
michael@0 | 16 | "Test bookmark"); |
michael@0 | 17 | |
michael@0 | 18 | // Add a bookmark to unfiled folder. |
michael@0 | 19 | PlacesUtils.bookmarks.insertBookmark(PlacesUtils.unfiledBookmarksFolderId, |
michael@0 | 20 | uri("http://test.mozilla.org/unfiled/"), |
michael@0 | 21 | Ci.nsINavBookmarksService.DEFAULT_INDEX, |
michael@0 | 22 | "Unfiled bookmark"); |
michael@0 | 23 | |
michael@0 | 24 | // Get the unfiled bookmark node. |
michael@0 | 25 | let unfiledNode = getNodeAt(PlacesUtils.unfiledBookmarksFolderId, 0); |
michael@0 | 26 | if (!unfiledNode) |
michael@0 | 27 | do_throw("Unable to find bookmark in hierarchy!"); |
michael@0 | 28 | do_check_eq(unfiledNode.title, "Unfiled bookmark"); |
michael@0 | 29 | |
michael@0 | 30 | let hs = PlacesUtils.history; |
michael@0 | 31 | let query = hs.getNewQuery(); |
michael@0 | 32 | query.setFolders([PlacesUtils.bookmarksMenuFolderId], 1); |
michael@0 | 33 | let options = hs.getNewQueryOptions(); |
michael@0 | 34 | options.queryType = options.QUERY_TYPE_BOOKMARKS; |
michael@0 | 35 | let root = hs.executeQuery(query, options).root; |
michael@0 | 36 | root.containerOpen = true; |
michael@0 | 37 | |
michael@0 | 38 | // Check functionality for proper nodes. |
michael@0 | 39 | for (let i = 0; i < root.childCount; i++) { |
michael@0 | 40 | let node = root.getChild(i); |
michael@0 | 41 | print("Now testing: " + node.title); |
michael@0 | 42 | do_check_eq(root.getChildIndex(node), i); |
michael@0 | 43 | } |
michael@0 | 44 | |
michael@0 | 45 | // Now search for an invalid node and expect an exception. |
michael@0 | 46 | try { |
michael@0 | 47 | root.getChildIndex(unfiledNode); |
michael@0 | 48 | do_throw("Searching for an invalid node should have thrown."); |
michael@0 | 49 | } catch(ex) { |
michael@0 | 50 | print("We correctly got an exception."); |
michael@0 | 51 | } |
michael@0 | 52 | |
michael@0 | 53 | root.containerOpen = false; |
michael@0 | 54 | } |
michael@0 | 55 | |
michael@0 | 56 | function getNodeAt(aFolderId, aIndex) { |
michael@0 | 57 | let hs = PlacesUtils.history; |
michael@0 | 58 | let query = hs.getNewQuery(); |
michael@0 | 59 | query.setFolders([aFolderId], 1); |
michael@0 | 60 | let options = hs.getNewQueryOptions(); |
michael@0 | 61 | options.queryType = options.QUERY_TYPE_BOOKMARKS; |
michael@0 | 62 | let root = hs.executeQuery(query, options).root; |
michael@0 | 63 | root.containerOpen = true; |
michael@0 | 64 | if (root.childCount < aIndex) |
michael@0 | 65 | do_throw("Not enough children to find bookmark!"); |
michael@0 | 66 | let node = root.getChild(aIndex); |
michael@0 | 67 | root.containerOpen = false; |
michael@0 | 68 | return node; |
michael@0 | 69 | } |