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 // The test data for our database, note that the ordering of the results that
8 // will be returned by the query (the isInQuery: true objects) is IMPORTANT.
9 // see compareArrayToResult in head_queries.js for more info.
10 var testData = [
11 // Test ftp protocol - vary the title length, embed search term
12 {isInQuery: true, isVisit: true, isDetails: true,
13 uri: "ftp://foo.com/ftp", lastVisit: lastweek,
14 title: "hugelongconfmozlagurationofwordswithasearchtermsinit whoo-hoo"},
16 // Test flat domain with annotation, search term in sentence
17 {isInQuery: true, isVisit: true, isDetails: true, isPageAnnotation: true,
18 uri: "http://foo.com/", annoName: "moz/test", annoVal: "val",
19 lastVisit: lastweek, title: "you know, moz is cool"},
21 // Test subdomain included with isRedirect=true, different transtype
22 {isInQuery: true, isVisit: true, isDetails: true, title: "amozzie",
23 isRedirect: true, uri: "http://mail.foo.com/redirect", lastVisit: old,
24 referrer: "http://myreferrer.com", transType: PlacesUtils.history.TRANSITION_LINK},
26 // Test subdomain inclued, search term at end
27 {isInQuery: true, isVisit: true, isDetails: true,
28 uri: "http://mail.foo.com/yiihah", title: "blahmoz", lastVisit: daybefore},
30 // Test www. style URI is included, with a tag
31 {isInQuery: true, isVisit: true, isDetails: true, isTag: true,
32 uri: "http://www.foo.com/yiihah", tagArray: ["moz"],
33 lastVisit: yesterday, title: "foo"},
35 // Test https protocol
36 {isInQuery: true, isVisit: true, isDetails: true, title: "moz",
37 uri: "https://foo.com/", lastVisit: today},
39 // Begin the invalid queries: wrong search term
40 {isInQuery: false, isVisit:true, isDetails: true, title: "m o z",
41 uri: "http://foo.com/tooearly.php", lastVisit: today},
43 // Test bad URI
44 {isInQuery: false, isVisit:true, isDetails: true, title: "moz",
45 uri: "http://sffoo.com/justwrong.htm", lastVisit: tomorrow},
47 // Test what we do with escaping in titles
48 {isInQuery: false, isVisit:true, isDetails: true, title: "m%0o%0z",
49 uri: "http://foo.com/changeme1.htm", lastVisit: yesterday},
51 // Test another invalid title - for updating later
52 {isInQuery: false, isVisit:true, isDetails: true, title: "m,oz",
53 uri: "http://foo.com/changeme2.htm", lastVisit: tomorrow}];
55 /**
56 * This test will test Queries that use relative search terms and domain options
57 */
58 function run_test()
59 {
60 run_next_test();
61 }
63 add_task(function test_searchterms_domain()
64 {
65 yield task_populateDB(testData);
66 var query = PlacesUtils.history.getNewQuery();
67 query.searchTerms = "moz";
68 query.domain = "foo.com";
69 query.domainIsHost = false;
71 // Options
72 var options = PlacesUtils.history.getNewQueryOptions();
73 options.sortingMode = options.SORT_BY_DATE_ASCENDING;
74 options.resultType = options.RESULTS_AS_URI;
76 // Results
77 var result = PlacesUtils.history.executeQuery(query, options);
78 var root = result.root;
79 root.containerOpen = true;
81 LOG("Number of items in result set: " + root.childCount);
82 for(var i=0; i < root.childCount; ++i) {
83 LOG("result: " + root.getChild(i).uri + " Title: " + root.getChild(i).title);
84 }
86 // Check our inital result set
87 compareArrayToResult(testData, root);
89 // If that passes, check liveupdate
90 // Add to the query set
91 LOG("Adding item to query")
92 var change1 = [{isVisit: true, isDetails: true, uri: "http://foo.com/added.htm",
93 title: "moz", transType: PlacesUtils.history.TRANSITION_LINK}];
94 yield task_populateDB(change1);
95 do_check_true(isInResult(change1, root));
97 // Update an existing URI
98 LOG("Updating Item");
99 var change2 = [{isDetails: true, uri: "http://foo.com/changeme1.htm",
100 title: "moz" }];
101 yield task_populateDB(change2);
102 do_check_true(isInResult(change2, root));
104 // Add one and take one out of query set, and simply change one so that it
105 // still applies to the query.
106 LOG("Updating More Items");
107 var change3 = [{isDetails: true, uri:"http://foo.com/changeme2.htm",
108 title: "moz"},
109 {isDetails: true, uri: "http://mail.foo.com/yiihah",
110 title: "moz now updated"},
111 {isDetails: true, uri: "ftp://foo.com/ftp", title: "gone"}];
112 yield task_populateDB(change3);
113 do_check_true(isInResult({uri: "http://foo.com/changeme2.htm"}, root));
114 do_check_true(isInResult({uri: "http://mail.foo.com/yiihah"}, root));
115 do_check_false(isInResult({uri: "ftp://foo.com/ftp"}, root));
117 // And now, delete one
118 LOG("Deleting items");
119 var change4 = [{isDetails: true, uri: "https://foo.com/",
120 title: "mo,z"}];
121 yield task_populateDB(change4);
122 do_check_false(isInResult(change4, root));
124 root.containerOpen = false;
125 });