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.
michael@0 | 1 | /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* vim:set ts=2 sw=2 sts=2 et: */ |
michael@0 | 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | const DAY_MSEC = 86400000; |
michael@0 | 8 | const MIN_MSEC = 60000; |
michael@0 | 9 | const HOUR_MSEC = 3600000; |
michael@0 | 10 | // Jan 6 2008 at 8am is our begin edge of the query |
michael@0 | 11 | var beginTimeDate = new Date(2008, 0, 6, 8, 0, 0, 0); |
michael@0 | 12 | // Jan 15 2008 at 9:30pm is our ending edge of the query |
michael@0 | 13 | var endTimeDate = new Date(2008, 0, 15, 21, 30, 0, 0); |
michael@0 | 14 | |
michael@0 | 15 | // These as millisecond values |
michael@0 | 16 | var beginTime = beginTimeDate.getTime(); |
michael@0 | 17 | var endTime = endTimeDate.getTime(); |
michael@0 | 18 | |
michael@0 | 19 | // Some range dates inside our query - mult by 1000 to convert to PRTIME |
michael@0 | 20 | var jan7_800 = (beginTime + DAY_MSEC) * 1000; |
michael@0 | 21 | var jan6_815 = (beginTime + (MIN_MSEC * 15)) * 1000; |
michael@0 | 22 | var jan11_800 = (beginTime + (DAY_MSEC * 5)) * 1000; |
michael@0 | 23 | var jan14_2130 = (endTime - DAY_MSEC) * 1000; |
michael@0 | 24 | var jan15_2045 = (endTime - (MIN_MSEC * 45)) * 1000; |
michael@0 | 25 | var jan12_1730 = (endTime - (DAY_MSEC * 3) - (HOUR_MSEC*4)) * 1000; |
michael@0 | 26 | |
michael@0 | 27 | // Dates outside our query - mult by 1000 to convert to PRTIME |
michael@0 | 28 | var jan6_700 = (beginTime - HOUR_MSEC) * 1000; |
michael@0 | 29 | var jan5_800 = (beginTime - DAY_MSEC) * 1000; |
michael@0 | 30 | var dec27_800 = (beginTime - (DAY_MSEC * 10)) * 1000; |
michael@0 | 31 | var jan15_2145 = (endTime + (MIN_MSEC * 15)) * 1000; |
michael@0 | 32 | var jan16_2130 = (endTime + (DAY_MSEC)) * 1000; |
michael@0 | 33 | var jan25_2130 = (endTime + (DAY_MSEC * 10)) * 1000; |
michael@0 | 34 | |
michael@0 | 35 | // So that we can easily use these too, convert them to PRTIME |
michael@0 | 36 | beginTime *= 1000; |
michael@0 | 37 | endTime *= 1000; |
michael@0 | 38 | |
michael@0 | 39 | /** |
michael@0 | 40 | * Array of objects to build our test database |
michael@0 | 41 | */ |
michael@0 | 42 | var goodAnnoName = "moz-test-places/testing123"; |
michael@0 | 43 | var val = "test"; |
michael@0 | 44 | var badAnnoName = "text/foo"; |
michael@0 | 45 | |
michael@0 | 46 | // The test data for our database, note that the ordering of the results that |
michael@0 | 47 | // will be returned by the query (the isInQuery: true objects) is IMPORTANT. |
michael@0 | 48 | // see compareArrayToResult in head_queries.js for more info. |
michael@0 | 49 | var testData = [ |
michael@0 | 50 | |
michael@0 | 51 | // Test flat domain with annotation |
michael@0 | 52 | {isInQuery: true, isVisit: true, isDetails: true, isPageAnnotation: true, |
michael@0 | 53 | uri: "http://foo.com/", annoName: goodAnnoName, annoVal: val, |
michael@0 | 54 | lastVisit: jan14_2130, title: "moz"}, |
michael@0 | 55 | |
michael@0 | 56 | // Test begin edge of time |
michael@0 | 57 | {isInQuery: true, isVisit: true, isDetails: true, title: "moz mozilla", |
michael@0 | 58 | uri: "http://foo.com/begin.html", lastVisit: beginTime}, |
michael@0 | 59 | |
michael@0 | 60 | // Test end edge of time |
michael@0 | 61 | {isInQuery: true, isVisit: true, isDetails: true, title: "moz mozilla", |
michael@0 | 62 | uri: "http://foo.com/end.html", lastVisit: endTime}, |
michael@0 | 63 | |
michael@0 | 64 | // Test uri included with isRedirect=true, different transtype |
michael@0 | 65 | {isInQuery: true, isVisit: true, isDetails: true, title: "moz", |
michael@0 | 66 | isRedirect: true, uri: "http://foo.com/redirect", lastVisit: jan11_800, |
michael@0 | 67 | transType: PlacesUtils.history.TRANSITION_LINK}, |
michael@0 | 68 | |
michael@0 | 69 | // Test leading time edge with tag string is included |
michael@0 | 70 | {isInQuery: true, isVisit: true, isDetails: true, title: "taggariffic", |
michael@0 | 71 | uri: "http://foo.com/tagging/test.html", lastVisit: beginTime, isTag: true, |
michael@0 | 72 | tagArray: ["moz"] }, |
michael@0 | 73 | |
michael@0 | 74 | // Begin the invalid queries: |
michael@0 | 75 | // Test www. style URI is not included, with an annotation |
michael@0 | 76 | {isInQuery: false, isVisit: true, isDetails: true, isPageAnnotation: true, |
michael@0 | 77 | uri: "http://www.foo.com/yiihah", annoName: goodAnnoName, annoVal: val, |
michael@0 | 78 | lastVisit: jan7_800, title: "moz"}, |
michael@0 | 79 | |
michael@0 | 80 | // Test subdomain not inclued at the leading time edge |
michael@0 | 81 | {isInQuery: false, isVisit: true, isDetails: true, |
michael@0 | 82 | uri: "http://mail.foo.com/yiihah", title: "moz", lastVisit: jan6_815}, |
michael@0 | 83 | |
michael@0 | 84 | // Test https protocol |
michael@0 | 85 | {isInQuery: false, isVisit: true, isDetails: true, title: "moz", |
michael@0 | 86 | uri: "https://foo.com/", lastVisit: jan15_2045}, |
michael@0 | 87 | |
michael@0 | 88 | // Test ftp protocol |
michael@0 | 89 | {isInQuery: false, isVisit: true, isDetails: true, |
michael@0 | 90 | uri: "ftp://foo.com/ftp", lastVisit: jan12_1730, |
michael@0 | 91 | title: "hugelongconfmozlagurationofwordswithasearchtermsinit whoo-hoo"}, |
michael@0 | 92 | |
michael@0 | 93 | // Test too early |
michael@0 | 94 | {isInQuery: false, isVisit:true, isDetails: true, title: "moz", |
michael@0 | 95 | uri: "http://foo.com/tooearly.php", lastVisit: jan6_700}, |
michael@0 | 96 | |
michael@0 | 97 | // Test Bad Annotation |
michael@0 | 98 | {isInQuery: false, isVisit:true, isDetails: true, isPageAnnotation: true, |
michael@0 | 99 | title: "moz", uri: "http://foo.com/badanno.htm", lastVisit: jan12_1730, |
michael@0 | 100 | annoName: badAnnoName, annoVal: val}, |
michael@0 | 101 | |
michael@0 | 102 | // Test afterward, one to update |
michael@0 | 103 | {isInQuery: false, isVisit:true, isDetails: true, title: "changeme", |
michael@0 | 104 | uri: "http://foo.com/changeme1.htm", lastVisit: jan12_1730}, |
michael@0 | 105 | |
michael@0 | 106 | // Test invalid title |
michael@0 | 107 | {isInQuery: false, isVisit:true, isDetails: true, title: "changeme2", |
michael@0 | 108 | uri: "http://foo.com/changeme2.htm", lastVisit: jan7_800}, |
michael@0 | 109 | |
michael@0 | 110 | // Test changing the lastVisit |
michael@0 | 111 | {isInQuery: false, isVisit:true, isDetails: true, title: "moz", |
michael@0 | 112 | uri: "http://foo.com/changeme3.htm", lastVisit: dec27_800}]; |
michael@0 | 113 | |
michael@0 | 114 | /** |
michael@0 | 115 | * This test will test a Query using several terms and do a bit of negative |
michael@0 | 116 | * testing for items that should be ignored while querying over history. |
michael@0 | 117 | * The Query:WHERE absoluteTime(matches) AND searchTerms AND URI |
michael@0 | 118 | * AND annotationIsNot(match) GROUP BY Domain, Day SORT BY uri,ascending |
michael@0 | 119 | * excludeITems(should be ignored) |
michael@0 | 120 | */ |
michael@0 | 121 | function run_test() |
michael@0 | 122 | { |
michael@0 | 123 | run_next_test(); |
michael@0 | 124 | } |
michael@0 | 125 | |
michael@0 | 126 | add_task(function test_abstime_annotation_uri() |
michael@0 | 127 | { |
michael@0 | 128 | //Initialize database |
michael@0 | 129 | yield task_populateDB(testData); |
michael@0 | 130 | |
michael@0 | 131 | // Query |
michael@0 | 132 | var query = PlacesUtils.history.getNewQuery(); |
michael@0 | 133 | query.beginTime = beginTime; |
michael@0 | 134 | query.endTime = endTime; |
michael@0 | 135 | query.beginTimeReference = PlacesUtils.history.TIME_RELATIVE_EPOCH; |
michael@0 | 136 | query.endTimeReference = PlacesUtils.history.TIME_RELATIVE_EPOCH; |
michael@0 | 137 | query.searchTerms = "moz"; |
michael@0 | 138 | query.uri = uri("http://foo.com"); |
michael@0 | 139 | query.uriIsPrefix = true; |
michael@0 | 140 | query.annotation = "text/foo"; |
michael@0 | 141 | query.annotationIsNot = true; |
michael@0 | 142 | |
michael@0 | 143 | // Options |
michael@0 | 144 | var options = PlacesUtils.history.getNewQueryOptions(); |
michael@0 | 145 | options.sortingMode = options.SORT_BY_URI_ASCENDING; |
michael@0 | 146 | options.resultType = options.RESULTS_AS_URI; |
michael@0 | 147 | // The next two options should be ignored |
michael@0 | 148 | // can't use this one, breaks test - bug 419779 |
michael@0 | 149 | // options.excludeItems = true; |
michael@0 | 150 | |
michael@0 | 151 | // Results |
michael@0 | 152 | var result = PlacesUtils.history.executeQuery(query, options); |
michael@0 | 153 | var root = result.root; |
michael@0 | 154 | root.containerOpen = true; |
michael@0 | 155 | |
michael@0 | 156 | // Ensure the result set is correct |
michael@0 | 157 | compareArrayToResult(testData, root); |
michael@0 | 158 | |
michael@0 | 159 | // Make some changes to the result set |
michael@0 | 160 | // Let's add something first |
michael@0 | 161 | var addItem = [{isInQuery: true, isVisit: true, isDetails: true, title: "moz", |
michael@0 | 162 | uri: "http://foo.com/i-am-added.html", lastVisit: jan11_800}]; |
michael@0 | 163 | yield task_populateDB(addItem); |
michael@0 | 164 | LOG("Adding item foo.com/i-am-added.html"); |
michael@0 | 165 | do_check_eq(isInResult(addItem, root), true); |
michael@0 | 166 | |
michael@0 | 167 | // Let's update something by title |
michael@0 | 168 | var change1 = [{isDetails: true, uri: "http://foo.com/changeme1", |
michael@0 | 169 | lastVisit: jan12_1730, title: "moz moz mozzie"}]; |
michael@0 | 170 | yield task_populateDB(change1); |
michael@0 | 171 | LOG("LiveUpdate by changing title"); |
michael@0 | 172 | do_check_eq(isInResult(change1, root), true); |
michael@0 | 173 | |
michael@0 | 174 | // Let's update something by annotation |
michael@0 | 175 | // Updating a page by removing an annotation does not cause it to join this |
michael@0 | 176 | // query set. I tend to think that it should cause that page to join this |
michael@0 | 177 | // query set, because this visit fits all theother specified criteria once the |
michael@0 | 178 | // annotation is removed. Uncommenting this will fail the test. |
michael@0 | 179 | // This is bug 424050 - appears to happen for both domain and URI queries |
michael@0 | 180 | /*var change2 = [{isPageAnnotation: true, uri: "http://foo.com/badannotaion.html", |
michael@0 | 181 | annoName: "text/mozilla", annoVal: "test"}]; |
michael@0 | 182 | yield task_populateDB(change2); |
michael@0 | 183 | LOG("LiveUpdate by removing annotation"); |
michael@0 | 184 | do_check_eq(isInResult(change2, root), true);*/ |
michael@0 | 185 | |
michael@0 | 186 | // Let's update by adding a visit in the time range for an existing URI |
michael@0 | 187 | var change3 = [{isDetails: true, uri: "http://foo.com/changeme3.htm", |
michael@0 | 188 | title: "moz", lastVisit: jan15_2045}]; |
michael@0 | 189 | yield task_populateDB(change3); |
michael@0 | 190 | LOG("LiveUpdate by adding visit within timerange"); |
michael@0 | 191 | do_check_eq(isInResult(change3, root), true); |
michael@0 | 192 | |
michael@0 | 193 | // And delete something from the result set - using annotation |
michael@0 | 194 | // Once more, bug 424050 |
michael@0 | 195 | /*var change4 = [{isPageAnnotation: true, uri: "http://foo.com/", |
michael@0 | 196 | annoVal: "test", annoName: badAnnoName}]; |
michael@0 | 197 | yield task_populateDB(change4); |
michael@0 | 198 | LOG("LiveUpdate by deleting item from set by adding annotation"); |
michael@0 | 199 | do_check_eq(isInResult(change4, root), false);*/ |
michael@0 | 200 | |
michael@0 | 201 | // Delete something by changing the title |
michael@0 | 202 | var change5 = [{isDetails: true, uri: "http://foo.com/end.html", title: "deleted"}]; |
michael@0 | 203 | yield task_populateDB(change5); |
michael@0 | 204 | LOG("LiveUpdate by deleting item by changing title"); |
michael@0 | 205 | do_check_eq(isInResult(change5, root), false); |
michael@0 | 206 | |
michael@0 | 207 | root.containerOpen = false; |
michael@0 | 208 | }); |