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 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: sw=2 ts=2 et lcs=trail\:.,tab\:>~ :
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /**
8 * What this is aimed to test:
9 *
10 * EXPIRE_NEVER annotations should be expired when a page is removed from the
11 * database.
12 * If the annotation is a page annotation this will happen when the page is
13 * expired, namely when the page has no visits and is not bookmarked.
14 * Otherwise if it's an item annotation the annotation will be expired when
15 * the item is removed, thus expiration won't handle this case at all.
16 */
18 let bs = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
19 getService(Ci.nsINavBookmarksService);
20 let as = Cc["@mozilla.org/browser/annotation-service;1"].
21 getService(Ci.nsIAnnotationService);
23 function run_test() {
24 run_next_test();
25 }
27 add_task(function test_annos_expire_never() {
28 // Set interval to a large value so we don't expire on it.
29 setInterval(3600); // 1h
31 // Expire all expirable pages.
32 setMaxPages(0);
34 // Add some visited page and a couple expire never annotations for each.
35 let now = getExpirablePRTime();
36 for (let i = 0; i < 5; i++) {
37 let pageURI = uri("http://page_anno." + i + ".mozilla.org/");
38 yield promiseAddVisits({ uri: pageURI, visitDate: now++ });
39 as.setPageAnnotation(pageURI, "page_expire1", "test", 0, as.EXPIRE_NEVER);
40 as.setPageAnnotation(pageURI, "page_expire2", "test", 0, as.EXPIRE_NEVER);
41 }
43 let pages = as.getPagesWithAnnotation("page_expire1");
44 do_check_eq(pages.length, 5);
45 pages = as.getPagesWithAnnotation("page_expire2");
46 do_check_eq(pages.length, 5);
48 // Add some bookmarked page and a couple expire never annotations for each.
49 for (let i = 0; i < 5; i++) {
50 let pageURI = uri("http://item_anno." + i + ".mozilla.org/");
51 // We also add a visit before bookmarking.
52 yield promiseAddVisits({ uri: pageURI, visitDate: now++ });
53 let id = bs.insertBookmark(bs.unfiledBookmarksFolder, pageURI,
54 bs.DEFAULT_INDEX, null);
55 as.setItemAnnotation(id, "item_persist1", "test", 0, as.EXPIRE_NEVER);
56 as.setItemAnnotation(id, "item_persist2", "test", 0, as.EXPIRE_NEVER);
57 }
59 let items = as.getItemsWithAnnotation("item_persist1");
60 do_check_eq(items.length, 5);
61 items = as.getItemsWithAnnotation("item_persist2");
62 do_check_eq(items.length, 5);
64 // Add other visited page and a couple expire never annotations for each.
65 // We won't expire these visits, so the annotations should survive.
66 for (let i = 0; i < 5; i++) {
67 let pageURI = uri("http://persist_page_anno." + i + ".mozilla.org/");
68 yield promiseAddVisits({ uri: pageURI, visitDate: now++ });
69 as.setPageAnnotation(pageURI, "page_persist1", "test", 0, as.EXPIRE_NEVER);
70 as.setPageAnnotation(pageURI, "page_persist2", "test", 0, as.EXPIRE_NEVER);
71 }
73 pages = as.getPagesWithAnnotation("page_persist1");
74 do_check_eq(pages.length, 5);
75 pages = as.getPagesWithAnnotation("page_persist2");
76 do_check_eq(pages.length, 5);
78 // Expire all visits for the first 5 pages and the bookmarks.
79 yield promiseForceExpirationStep(10);
81 let pages = as.getPagesWithAnnotation("page_expire1");
82 do_check_eq(pages.length, 0);
83 pages = as.getPagesWithAnnotation("page_expire2");
84 do_check_eq(pages.length, 0);
85 let items = as.getItemsWithAnnotation("item_persist1");
86 do_check_eq(items.length, 5);
87 items = as.getItemsWithAnnotation("item_persist2");
88 do_check_eq(items.length, 5);
89 pages = as.getPagesWithAnnotation("page_persist1");
90 do_check_eq(pages.length, 5);
91 pages = as.getPagesWithAnnotation("page_persist2");
92 do_check_eq(pages.length, 5);
93 });