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 | * TEST DESCRIPTION: |
michael@0 | 9 | * |
michael@0 | 10 | * Tests patch to Bug 412132: |
michael@0 | 11 | * https://bugzilla.mozilla.org/show_bug.cgi?id=412132 |
michael@0 | 12 | */ |
michael@0 | 13 | |
michael@0 | 14 | add_task(function changeuri_unvisited_bookmark() |
michael@0 | 15 | { |
michael@0 | 16 | do_log_info("After changing URI of bookmark, frecency of bookmark's " + |
michael@0 | 17 | "original URI should be zero if original URI is unvisited and " + |
michael@0 | 18 | "no longer bookmarked."); |
michael@0 | 19 | const TEST_URI = NetUtil.newURI("http://example.com/1"); |
michael@0 | 20 | let id = PlacesUtils.bookmarks.insertBookmark(PlacesUtils.unfiledBookmarksFolderId, |
michael@0 | 21 | TEST_URI, |
michael@0 | 22 | PlacesUtils.bookmarks.DEFAULT_INDEX, |
michael@0 | 23 | "bookmark title"); |
michael@0 | 24 | yield promiseAsyncUpdates(); |
michael@0 | 25 | |
michael@0 | 26 | do_log_info("Bookmarked => frecency of URI should be != 0"); |
michael@0 | 27 | do_check_neq(frecencyForUrl(TEST_URI), 0); |
michael@0 | 28 | |
michael@0 | 29 | PlacesUtils.bookmarks.changeBookmarkURI(id, uri("http://example.com/2")); |
michael@0 | 30 | |
michael@0 | 31 | yield promiseAsyncUpdates(); |
michael@0 | 32 | |
michael@0 | 33 | do_log_info("Unvisited URI no longer bookmarked => frecency should = 0"); |
michael@0 | 34 | do_check_eq(frecencyForUrl(TEST_URI), 0); |
michael@0 | 35 | |
michael@0 | 36 | remove_all_bookmarks(); |
michael@0 | 37 | yield promiseClearHistory(); |
michael@0 | 38 | }); |
michael@0 | 39 | |
michael@0 | 40 | add_task(function changeuri_visited_bookmark() |
michael@0 | 41 | { |
michael@0 | 42 | do_log_info("After changing URI of bookmark, frecency of bookmark's " + |
michael@0 | 43 | "original URI should not be zero if original URI is visited."); |
michael@0 | 44 | const TEST_URI = NetUtil.newURI("http://example.com/1"); |
michael@0 | 45 | let id = PlacesUtils.bookmarks.insertBookmark(PlacesUtils.unfiledBookmarksFolderId, |
michael@0 | 46 | TEST_URI, |
michael@0 | 47 | PlacesUtils.bookmarks.DEFAULT_INDEX, |
michael@0 | 48 | "bookmark title"); |
michael@0 | 49 | |
michael@0 | 50 | yield promiseAsyncUpdates(); |
michael@0 | 51 | |
michael@0 | 52 | do_log_info("Bookmarked => frecency of URI should be != 0"); |
michael@0 | 53 | do_check_neq(frecencyForUrl(TEST_URI), 0); |
michael@0 | 54 | |
michael@0 | 55 | yield promiseAddVisits(TEST_URI); |
michael@0 | 56 | |
michael@0 | 57 | yield promiseAsyncUpdates(); |
michael@0 | 58 | |
michael@0 | 59 | PlacesUtils.bookmarks.changeBookmarkURI(id, uri("http://example.com/2")); |
michael@0 | 60 | |
michael@0 | 61 | yield promiseAsyncUpdates(); |
michael@0 | 62 | |
michael@0 | 63 | do_log_info("*Visited* URI no longer bookmarked => frecency should != 0"); |
michael@0 | 64 | do_check_neq(frecencyForUrl(TEST_URI), 0); |
michael@0 | 65 | |
michael@0 | 66 | remove_all_bookmarks(); |
michael@0 | 67 | yield promiseClearHistory(); |
michael@0 | 68 | }); |
michael@0 | 69 | |
michael@0 | 70 | add_task(function changeuri_bookmark_still_bookmarked() |
michael@0 | 71 | { |
michael@0 | 72 | do_log_info("After changing URI of bookmark, frecency of bookmark's " + |
michael@0 | 73 | "original URI should not be zero if original URI is still " + |
michael@0 | 74 | "bookmarked."); |
michael@0 | 75 | const TEST_URI = NetUtil.newURI("http://example.com/1"); |
michael@0 | 76 | let id1 = PlacesUtils.bookmarks.insertBookmark(PlacesUtils.unfiledBookmarksFolderId, |
michael@0 | 77 | TEST_URI, |
michael@0 | 78 | PlacesUtils.bookmarks.DEFAULT_INDEX, |
michael@0 | 79 | "bookmark 1 title"); |
michael@0 | 80 | let id2 = PlacesUtils.bookmarks.insertBookmark(PlacesUtils.unfiledBookmarksFolderId, |
michael@0 | 81 | TEST_URI, |
michael@0 | 82 | PlacesUtils.bookmarks.DEFAULT_INDEX, |
michael@0 | 83 | "bookmark 2 title"); |
michael@0 | 84 | |
michael@0 | 85 | yield promiseAsyncUpdates(); |
michael@0 | 86 | |
michael@0 | 87 | do_log_info("Bookmarked => frecency of URI should be != 0"); |
michael@0 | 88 | do_check_neq(frecencyForUrl(TEST_URI), 0); |
michael@0 | 89 | |
michael@0 | 90 | PlacesUtils.bookmarks.changeBookmarkURI(id1, uri("http://example.com/2")); |
michael@0 | 91 | |
michael@0 | 92 | yield promiseAsyncUpdates(); |
michael@0 | 93 | |
michael@0 | 94 | do_log_info("URI still bookmarked => frecency should != 0"); |
michael@0 | 95 | do_check_neq(frecencyForUrl(TEST_URI), 0); |
michael@0 | 96 | |
michael@0 | 97 | remove_all_bookmarks(); |
michael@0 | 98 | yield promiseClearHistory(); |
michael@0 | 99 | }); |
michael@0 | 100 | |
michael@0 | 101 | add_task(function changeuri_nonexistent_bookmark() |
michael@0 | 102 | { |
michael@0 | 103 | do_log_info("Changing the URI of a nonexistent bookmark should fail."); |
michael@0 | 104 | function tryChange(itemId) |
michael@0 | 105 | { |
michael@0 | 106 | try { |
michael@0 | 107 | PlacesUtils.bookmarks.changeBookmarkURI(itemId + 1, uri("http://example.com/2")); |
michael@0 | 108 | do_throw("Nonexistent bookmark should throw."); |
michael@0 | 109 | } |
michael@0 | 110 | catch (ex) {} |
michael@0 | 111 | } |
michael@0 | 112 | |
michael@0 | 113 | // First try a straight-up bogus item ID, one greater than the current max |
michael@0 | 114 | // ID. |
michael@0 | 115 | let stmt = DBConn().createStatement("SELECT MAX(id) FROM moz_bookmarks"); |
michael@0 | 116 | stmt.executeStep(); |
michael@0 | 117 | let maxId = stmt.getInt32(0); |
michael@0 | 118 | stmt.finalize(); |
michael@0 | 119 | tryChange(maxId + 1); |
michael@0 | 120 | |
michael@0 | 121 | // Now add a bookmark, delete it, and check. |
michael@0 | 122 | let id = PlacesUtils.bookmarks.insertBookmark(PlacesUtils.unfiledBookmarksFolderId, |
michael@0 | 123 | uri("http://example.com/"), |
michael@0 | 124 | PlacesUtils.bookmarks.DEFAULT_INDEX, |
michael@0 | 125 | "bookmark title"); |
michael@0 | 126 | PlacesUtils.bookmarks.removeItem(id); |
michael@0 | 127 | tryChange(id); |
michael@0 | 128 | |
michael@0 | 129 | remove_all_bookmarks(); |
michael@0 | 130 | yield promiseClearHistory(); |
michael@0 | 131 | }); |
michael@0 | 132 | |
michael@0 | 133 | /////////////////////////////////////////////////////////////////////////////// |
michael@0 | 134 | |
michael@0 | 135 | function run_test() |
michael@0 | 136 | { |
michael@0 | 137 | run_next_test(); |
michael@0 | 138 | } |