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: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:set ts=2 sw=2 sts=2 et: */
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 // Get bookmarks service
8 try {
9 var bmsvc = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
10 getService(Ci.nsINavBookmarksService);
11 }
12 catch(ex) {
13 do_throw("Could not get bookmarks service\n");
14 }
16 // Get database connection
17 try {
18 var histsvc = Cc["@mozilla.org/browser/nav-history-service;1"].
19 getService(Ci.nsINavHistoryService);
20 var mDBConn = histsvc.QueryInterface(Ci.nsPIPlacesDatabase).DBConnection;
21 }
22 catch(ex) {
23 do_throw("Could not get database connection\n");
24 }
26 add_test(function test_keywordRemovedOnUniqueItemRemoval() {
27 var bookmarkedURI = uri("http://foo.bar");
28 var keyword = "testkeyword";
30 // TEST 1
31 // 1. add a bookmark
32 // 2. add a keyword to it
33 // 3. remove bookmark
34 // 4. check that keyword has gone
35 var bookmarkId = bmsvc.insertBookmark(bmsvc.bookmarksMenuFolder,
36 bookmarkedURI,
37 bmsvc.DEFAULT_INDEX,
38 "A bookmark");
39 bmsvc.setKeywordForBookmark(bookmarkId, keyword);
40 // remove bookmark
41 bmsvc.removeItem(bookmarkId);
43 promiseAsyncUpdates().then(function() {
44 // Check that keyword has been removed from the database.
45 // The removal is asynchronous.
46 var sql = "SELECT id FROM moz_keywords WHERE keyword = ?1";
47 var stmt = mDBConn.createStatement(sql);
48 stmt.bindByIndex(0, keyword);
49 do_check_false(stmt.executeStep());
50 stmt.finalize();
52 run_next_test();
53 });
54 });
56 add_test(function test_keywordNotRemovedOnNonUniqueItemRemoval() {
57 var bookmarkedURI = uri("http://foo.bar");
58 var keyword = "testkeyword";
60 // TEST 2
61 // 1. add 2 bookmarks
62 // 2. add the same keyword to them
63 // 3. remove first bookmark
64 // 4. check that keyword is still there
65 var bookmarkId1 = bmsvc.insertBookmark(bmsvc.bookmarksMenuFolder,
66 bookmarkedURI,
67 bmsvc.DEFAULT_INDEX,
68 "A bookmark");
69 bmsvc.setKeywordForBookmark(bookmarkId1, keyword);
71 var bookmarkId2 = bmsvc.insertBookmark(bmsvc.toolbarFolder,
72 bookmarkedURI,
73 bmsvc.DEFAULT_INDEX,
74 keyword);
75 bmsvc.setKeywordForBookmark(bookmarkId2, keyword);
77 // remove first bookmark
78 bmsvc.removeItem(bookmarkId1);
80 promiseAsyncUpdates().then(function() {
81 // check that keyword is still there
82 var sql = "SELECT id FROM moz_keywords WHERE keyword = ?1";
83 var stmt = mDBConn.createStatement(sql);
84 stmt.bindByIndex(0, keyword);
85 do_check_true(stmt.executeStep());
86 stmt.finalize();
88 run_next_test();
89 });
90 });
92 function run_test() {
93 run_next_test();
94 }