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