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 * Session annotations should be expired when browsing session ends.
11 */
13 let bs = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
14 getService(Ci.nsINavBookmarksService);
15 let as = Cc["@mozilla.org/browser/annotation-service;1"].
16 getService(Ci.nsIAnnotationService);
18 function run_test() {
19 run_next_test();
20 }
22 add_task(function test_annos_expire_session() {
23 // Set interval to a large value so we don't expire on it.
24 setInterval(3600); // 1h
26 // Add some visited page and a couple session annotations for each.
27 let now = Date.now() * 1000;
28 for (let i = 0; i < 10; i++) {
29 let pageURI = uri("http://session_page_anno." + i + ".mozilla.org/");
30 yield promiseAddVisits({ uri: pageURI, visitDate: now++ });
31 as.setPageAnnotation(pageURI, "test1", "test", 0, as.EXPIRE_SESSION);
32 as.setPageAnnotation(pageURI, "test2", "test", 0, as.EXPIRE_SESSION);
33 }
35 // Add some bookmarked page and a couple session annotations for each.
36 for (let i = 0; i < 10; i++) {
37 let pageURI = uri("http://session_item_anno." + i + ".mozilla.org/");
38 let id = bs.insertBookmark(bs.unfiledBookmarksFolder, pageURI,
39 bs.DEFAULT_INDEX, null);
40 as.setItemAnnotation(id, "test1", "test", 0, as.EXPIRE_SESSION);
41 as.setItemAnnotation(id, "test2", "test", 0, as.EXPIRE_SESSION);
42 }
45 let pages = as.getPagesWithAnnotation("test1");
46 do_check_eq(pages.length, 10);
47 pages = as.getPagesWithAnnotation("test2");
48 do_check_eq(pages.length, 10);
49 let items = as.getItemsWithAnnotation("test1");
50 do_check_eq(items.length, 10);
51 items = as.getItemsWithAnnotation("test2");
52 do_check_eq(items.length, 10);
54 let deferred = Promise.defer();
55 waitForConnectionClosed(function() {
56 let stmt = DBConn(true).createAsyncStatement(
57 "SELECT id FROM moz_annos "
58 + "UNION ALL "
59 + "SELECT id FROM moz_items_annos "
60 );
61 stmt.executeAsync({
62 handleResult: function(aResultSet) {
63 dump_table("moz_annos");
64 dump_table("moz_items_annos");
65 do_throw("Should not find any leftover session annotations");
66 },
67 handleError: function(aError) {
68 do_throw("Error code " + aError.result + " with message '" +
69 aError.message + "' returned.");
70 },
71 handleCompletion: function(aReason) {
72 do_check_eq(aReason, Ci.mozIStorageStatementCallback.REASON_FINISHED);
73 deferred.resolve();
74 }
75 });
76 stmt.finalize();
77 });
78 yield deferred.promise;
79 });