4 const dm =
Cc[
"@mozilla.org/download-manager;1"].getService(
Ci.nsIDownloadManager);
5 const bhist =
Cc[
"@mozilla.org/browser/global-history;2"].getService(
Ci.nsIBrowserHistory);
6 const formhist =
Cc[
"@mozilla.org/satchel/form-history;1"].getService(
Ci.nsIFormHistory2);
8 Cc[
"@mozilla.org/moz/jssubscript-loader;1"].getService(
Ci.mozIJSSubScriptLoader)
9 .loadSubScript(
"chrome://browser/content/sanitize.js");
13 var hoursSinceMidnight =
new Date().getHours();
14 var minutesSinceMidnight =
new Date().getMinutes();
24 s.ignoreTimespan =
false;
25 s.prefDomain =
"privacy.cpd.";
27 itemPrefs.setBoolPref(
"history",
true);
28 itemPrefs.setBoolPref(
"downloads",
true);
29 itemPrefs.setBoolPref(
"cache",
false);
30 itemPrefs.setBoolPref(
"cookies",
false);
31 itemPrefs.setBoolPref(
"formdata",
true);
32 itemPrefs.setBoolPref(
"offlineApps",
false);
33 itemPrefs.setBoolPref(
"passwords",
false);
34 itemPrefs.setBoolPref(
"sessions",
false);
35 itemPrefs.setBoolPref(
"siteSettings",
false);
42 ok(!
bhist.isVisited(
makeURI(
"http://10minutes.com")),
"10minutes.com should now be deleted");
43 ok(
bhist.isVisited(
makeURI(
"http://1hour.com")),
"Pretend visit to 1hour.com should still exist");
44 ok(
bhist.isVisited(
makeURI(
"http://1hour10minutes.com/")),
"Pretend visit to 1hour10minutes.com should still exist");
45 ok(
bhist.isVisited(
makeURI(
"http://2hour.com")),
"Pretend visit to 2hour.com should still exist");
46 ok(
bhist.isVisited(
makeURI(
"http://2hour10minutes.com/")),
"Pretend visit to 2hour10minutes.com should still exist");
47 ok(
bhist.isVisited(
makeURI(
"http://4hour.com")),
"Pretend visit to 4hour.com should still exist");
48 ok(
bhist.isVisited(
makeURI(
"http://4hour10minutes.com/")),
"Pretend visit to 4hour10minutes.com should still exist");
50 if(minutesSinceMidnight > 10)
51 ok(
bhist.isVisited(
makeURI(
"http://today.com")),
"Pretend visit to today.com should still exist");
52 ok(
bhist.isVisited(
makeURI(
"http://before-today.com")),
"Pretend visit to before-today.com should still exist");
54 ok(!
formhist.nameExists(
"10minutes"),
"10minutes form entry should be deleted");
55 ok(
formhist.nameExists(
"1hour"),
"1hour form entry should still exist");
56 ok(
formhist.nameExists(
"1hour10minutes"),
"1hour10minutes form entry should still exist");
57 ok(
formhist.nameExists(
"2hour"),
"2hour form entry should still exist");
58 ok(
formhist.nameExists(
"2hour10minutes"),
"2hour10minutes form entry should still exist");
59 ok(
formhist.nameExists(
"4hour"),
"4hour form entry should still exist");
60 ok(
formhist.nameExists(
"4hour10minutes"),
"4hour10minutes form entry should still exist");
61 if(minutesSinceMidnight > 10)
62 ok(
formhist.nameExists(
"today"),
"today form entry should still exist");
63 ok(
formhist.nameExists(
"b4today"),
"b4today form entry should still exist");
65 ok(!
downloadExists(5555555),
"10 minute download should now be deleted");
66 ok(
downloadExists(5555551),
"<1 hour download should still be present");
67 ok(
downloadExists(5555556),
"1 hour 10 minute download should still be present");
68 ok(
downloadExists(5555550),
"Year old download should still be present");
69 ok(
downloadExists(5555552),
"<2 hour old download should still be present");
70 ok(
downloadExists(5555557),
"2 hour 10 minute download should still be present");
71 ok(
downloadExists(5555553),
"<4 hour old download should still be present");
72 ok(
downloadExists(5555558),
"4 hour 10 minute download should still be present");
74 if(minutesSinceMidnight > 10)
75 ok(
downloadExists(5555554),
"'Today' download should still be present");
78 Sanitizer.prefs.setIntPref(
"timeSpan", 1);
81 ok(!
bhist.isVisited(
makeURI(
"http://1hour.com")),
"1hour.com should now be deleted");
82 ok(
bhist.isVisited(
makeURI(
"http://1hour10minutes.com/")),
"Pretend visit to 1hour10minutes.com should still exist");
83 ok(
bhist.isVisited(
makeURI(
"http://2hour.com")),
"Pretend visit to 2hour.com should still exist");
84 ok(
bhist.isVisited(
makeURI(
"http://2hour10minutes.com/")),
"Pretend visit to 2hour10minutes.com should still exist");
85 ok(
bhist.isVisited(
makeURI(
"http://4hour.com")),
"Pretend visit to 4hour.com should still exist");
86 ok(
bhist.isVisited(
makeURI(
"http://4hour10minutes.com/")),
"Pretend visit to 4hour10minutes.com should still exist");
88 if(hoursSinceMidnight > 1)
89 ok(
bhist.isVisited(
makeURI(
"http://today.com")),
"Pretend visit to today.com should still exist");
90 ok(
bhist.isVisited(
makeURI(
"http://before-today.com")),
"Pretend visit to before-today.com should still exist");
92 ok(!
formhist.nameExists(
"1hour"),
"1hour form entry should be deleted");
93 ok(
formhist.nameExists(
"1hour10minutes"),
"1hour10minutes form entry should still exist");
94 ok(
formhist.nameExists(
"2hour"),
"2hour form entry should still exist");
95 ok(
formhist.nameExists(
"2hour10minutes"),
"2hour10minutes form entry should still exist");
96 ok(
formhist.nameExists(
"4hour"),
"4hour form entry should still exist");
97 ok(
formhist.nameExists(
"4hour10minutes"),
"4hour10minutes form entry should still exist");
98 if(hoursSinceMidnight > 1)
99 ok(
formhist.nameExists(
"today"),
"today form entry should still exist");
100 ok(
formhist.nameExists(
"b4today"),
"b4today form entry should still exist");
102 ok(!
downloadExists(5555551),
"<1 hour download should now be deleted");
103 ok(
downloadExists(5555556),
"1 hour 10 minute download should still be present");
104 ok(
downloadExists(5555550),
"Year old download should still be present");
105 ok(
downloadExists(5555552),
"<2 hour old download should still be present");
106 ok(
downloadExists(5555557),
"2 hour 10 minute download should still be present");
107 ok(
downloadExists(5555553),
"<4 hour old download should still be present");
108 ok(
downloadExists(5555558),
"4 hour 10 minute download should still be present");
110 if(hoursSinceMidnight > 1)
111 ok(
downloadExists(5555554),
"'Today' download should still be present");
118 ok(!
bhist.isVisited(
makeURI(
"http://1hour10minutes.com")),
"Pretend visit to 1hour10minutes.com should now be deleted");
119 ok(
bhist.isVisited(
makeURI(
"http://2hour.com")),
"Pretend visit to 2hour.com should still exist");
120 ok(
bhist.isVisited(
makeURI(
"http://2hour10minutes.com/")),
"Pretend visit to 2hour10minutes.com should still exist");
121 ok(
bhist.isVisited(
makeURI(
"http://4hour.com")),
"Pretend visit to 4hour.com should still exist");
122 ok(
bhist.isVisited(
makeURI(
"http://4hour10minutes.com/")),
"Pretend visit to 4hour10minutes.com should still exist");
123 if(minutesSinceMidnight > 70)
124 ok(
bhist.isVisited(
makeURI(
"http://today.com")),
"Pretend visit to today.com should still exist");
125 ok(
bhist.isVisited(
makeURI(
"http://before-today.com")),
"Pretend visit to before-today.com should still exist");
127 ok(!
formhist.nameExists(
"1hour10minutes"),
"1hour10minutes form entry should be deleted");
128 ok(
formhist.nameExists(
"2hour"),
"2hour form entry should still exist");
129 ok(
formhist.nameExists(
"2hour10minutes"),
"2hour10minutes form entry should still exist");
130 ok(
formhist.nameExists(
"4hour"),
"4hour form entry should still exist");
131 ok(
formhist.nameExists(
"4hour10minutes"),
"4hour10minutes form entry should still exist");
132 if(minutesSinceMidnight > 70)
133 ok(
formhist.nameExists(
"today"),
"today form entry should still exist");
134 ok(
formhist.nameExists(
"b4today"),
"b4today form entry should still exist");
136 ok(!
downloadExists(5555556),
"1 hour 10 minute old download should now be deleted");
137 ok(
downloadExists(5555550),
"Year old download should still be present");
138 ok(
downloadExists(5555552),
"<2 hour old download should still be present");
139 ok(
downloadExists(5555557),
"2 hour 10 minute download should still be present");
140 ok(
downloadExists(5555553),
"<4 hour old download should still be present");
141 ok(
downloadExists(5555558),
"4 hour 10 minute download should still be present");
142 if(minutesSinceMidnight > 70)
143 ok(
downloadExists(5555554),
"'Today' download should still be present");
146 Sanitizer.prefs.setIntPref(
"timeSpan", 2);
149 ok(!
bhist.isVisited(
makeURI(
"http://2hour.com")),
"Pretend visit to 2hour.com should now be deleted");
150 ok(
bhist.isVisited(
makeURI(
"http://2hour10minutes.com/")),
"Pretend visit to 2hour10minutes.com should still exist");
151 ok(
bhist.isVisited(
makeURI(
"http://4hour.com")),
"Pretend visit to 4hour.com should still exist");
152 ok(
bhist.isVisited(
makeURI(
"http://4hour10minutes.com/")),
"Pretend visit to 4hour10minutes.com should still exist");
153 if(hoursSinceMidnight > 2)
154 ok(
bhist.isVisited(
makeURI(
"http://today.com")),
"Pretend visit to today.com should still exist");
155 ok(
bhist.isVisited(
makeURI(
"http://before-today.com")),
"Pretend visit to before-today.com should still exist");
157 ok(!
formhist.nameExists(
"2hour"),
"2hour form entry should be deleted");
158 ok(
formhist.nameExists(
"2hour10minutes"),
"2hour10minutes form entry should still exist");
159 ok(
formhist.nameExists(
"4hour"),
"4hour form entry should still exist");
160 ok(
formhist.nameExists(
"4hour10minutes"),
"4hour10minutes form entry should still exist");
161 if(hoursSinceMidnight > 2)
162 ok(
formhist.nameExists(
"today"),
"today form entry should still exist");
163 ok(
formhist.nameExists(
"b4today"),
"b4today form entry should still exist");
165 ok(
formhist.nameExists(
"b4today"),
"b4today form entry should still exist");
166 ok(!
downloadExists(5555552),
"<2 hour old download should now be deleted");
167 ok(
downloadExists(5555550),
"Year old download should still be present");
168 ok(
downloadExists(5555557),
"2 hour 10 minute download should still be present");
169 ok(
downloadExists(5555553),
"<4 hour old download should still be present");
170 ok(
downloadExists(5555558),
"4 hour 10 minute download should still be present");
171 if(hoursSinceMidnight > 2)
172 ok(
downloadExists(5555554),
"'Today' download should still be present");
179 ok(!
bhist.isVisited(
makeURI(
"http://2hour10minutes.com")),
"Pretend visit to 2hour10minutes.com should now be deleted");
180 ok(
bhist.isVisited(
makeURI(
"http://4hour.com")),
"Pretend visit to 4hour.com should still exist");
181 ok(
bhist.isVisited(
makeURI(
"http://4hour10minutes.com/")),
"Pretend visit to 4hour10minutes.com should still exist");
182 if(minutesSinceMidnight > 130)
183 ok(
bhist.isVisited(
makeURI(
"http://today.com")),
"Pretend visit to today.com should still exist");
184 ok(
bhist.isVisited(
makeURI(
"http://before-today.com")),
"Pretend visit to before-today.com should still exist");
186 ok(!
formhist.nameExists(
"2hour10minutes"),
"2hour10minutes form entry should be deleted");
187 ok(
formhist.nameExists(
"4hour"),
"4hour form entry should still exist");
188 ok(
formhist.nameExists(
"4hour10minutes"),
"4hour10minutes form entry should still exist");
189 if(minutesSinceMidnight > 130)
190 ok(
formhist.nameExists(
"today"),
"today form entry should still exist");
191 ok(
formhist.nameExists(
"b4today"),
"b4today form entry should still exist");
193 ok(!
downloadExists(5555557),
"2 hour 10 minute old download should now be deleted");
194 ok(
downloadExists(5555553),
"<4 hour old download should still be present");
195 ok(
downloadExists(5555558),
"4 hour 10 minute download should still be present");
196 ok(
downloadExists(5555550),
"Year old download should still be present");
197 if(minutesSinceMidnight > 130)
198 ok(
downloadExists(5555554),
"'Today' download should still be present");
201 Sanitizer.prefs.setIntPref(
"timeSpan", 3);
204 ok(!
bhist.isVisited(
makeURI(
"http://4hour.com")),
"Pretend visit to 4hour.com should now be deleted");
205 ok(
bhist.isVisited(
makeURI(
"http://4hour10minutes.com/")),
"Pretend visit to 4hour10minutes.com should still exist");
206 if(hoursSinceMidnight > 4)
207 ok(
bhist.isVisited(
makeURI(
"http://today.com")),
"Pretend visit to today.com should still exist");
208 ok(
bhist.isVisited(
makeURI(
"http://before-today.com")),
"Pretend visit to before-today.com should still exist");
210 ok(!
formhist.nameExists(
"4hour"),
"4hour form entry should be deleted");
211 ok(
formhist.nameExists(
"4hour10minutes"),
"4hour10minutes form entry should still exist");
212 if(hoursSinceMidnight > 4)
213 ok(
formhist.nameExists(
"today"),
"today form entry should still exist");
214 ok(
formhist.nameExists(
"b4today"),
"b4today form entry should still exist");
216 ok(!
downloadExists(5555553),
"<4 hour old download should now be deleted");
217 ok(
downloadExists(5555558),
"4 hour 10 minute download should still be present");
218 ok(
downloadExists(5555550),
"Year old download should still be present");
219 if(hoursSinceMidnight > 4)
220 ok(
downloadExists(5555554),
"'Today' download should still be present");
227 ok(!
bhist.isVisited(
makeURI(
"http://4hour10minutes.com/")),
"Pretend visit to 4hour10minutes.com should now be deleted");
228 if(minutesSinceMidnight > 250)
229 ok(
bhist.isVisited(
makeURI(
"http://today.com")),
"Pretend visit to today.com should still exist");
230 ok(
bhist.isVisited(
makeURI(
"http://before-today.com")),
"Pretend visit to before-today.com should still exist");
232 ok(!
formhist.nameExists(
"4hour10minutes"),
"4hour10minutes form entry should be deleted");
233 if(minutesSinceMidnight > 250)
234 ok(
formhist.nameExists(
"today"),
"today form entry should still exist");
235 ok(
formhist.nameExists(
"b4today"),
"b4today form entry should still exist");
237 ok(!
downloadExists(5555558),
"4 hour 10 minute download should now be deleted");
238 ok(
downloadExists(5555550),
"Year old download should still be present");
239 if(minutesSinceMidnight > 250)
240 ok(
downloadExists(5555554),
"'Today' download should still be present");
243 Sanitizer.prefs.setIntPref(
"timeSpan", 4);
246 ok(!
bhist.isVisited(
makeURI(
"http://today.com")),
"Pretend visit to today.com should now be deleted");
247 ok(
bhist.isVisited(
makeURI(
"http://before-today.com")),
"Pretend visit to before-today.com should still exist");
249 ok(!
formhist.nameExists(
"today"),
"today form entry should be deleted");
250 ok(
formhist.nameExists(
"b4today"),
"b4today form entry should still exist");
252 ok(!
downloadExists(5555554),
"'Today' download should now be deleted");
253 ok(
downloadExists(5555550),
"Year old download should still be present");
256 Sanitizer.prefs.setIntPref(
"timeSpan", 0);
259 ok(!
bhist.isVisited(
makeURI(
"http://before-today.com")),
"Pretend visit to before-today.com should now be deleted");
261 ok(!
formhist.nameExists(
"b4today"),
"b4today form entry should be deleted");
263 ok(!
downloadExists(5555550),
"Year old download should now be deleted");
268 bhist.addPageWithDetails(
makeURI(
"http://10minutes.com/"),
"10 minutes ago",
now_uSec - 10*60*1000000);
269 bhist.addPageWithDetails(
makeURI(
"http://1hour.com/"),
"Less than 1 hour ago",
now_uSec - 45*60*1000000);
270 bhist.addPageWithDetails(
makeURI(
"http://1hour10minutes.com/"),
"1 hour 10 minutes ago",
now_uSec - 70*60*1000000);
271 bhist.addPageWithDetails(
makeURI(
"http://2hour.com/"),
"Less than 2 hours ago",
now_uSec - 90*60*1000000);
272 bhist.addPageWithDetails(
makeURI(
"http://2hour10minutes.com/"),
"2 hours 10 minutes ago",
now_uSec - 130*60*1000000);
273 bhist.addPageWithDetails(
makeURI(
"http://4hour.com/"),
"Less than 4 hours ago",
now_uSec - 180*60*1000000);
274 bhist.addPageWithDetails(
makeURI(
"http://4hour10minutes.com/"),
"4 hours 10 minutesago",
now_uSec - 250*60*1000000);
276 let today =
new Date();
279 today.setSeconds(30);
280 bhist.addPageWithDetails(
makeURI(
"http://today.com/"),
"Today", today.valueOf() * 1000);
282 let lastYear =
new Date();
283 lastYear.setFullYear(lastYear.getFullYear() - 1);
284 bhist.addPageWithDetails(
makeURI(
"http://before-today.com/"),
"Before Today", lastYear.valueOf() * 1000);
287 ok(
bhist.isVisited(
makeURI(
"http://10minutes.com/")),
"Pretend visit to 10minutes.com should exist");
288 ok(
bhist.isVisited(
makeURI(
"http://1hour.com")),
"Pretend visit to 1hour.com should exist");
289 ok(
bhist.isVisited(
makeURI(
"http://1hour10minutes.com/")),
"Pretend visit to 1hour10minutes.com should exist");
290 ok(
bhist.isVisited(
makeURI(
"http://2hour.com")),
"Pretend visit to 2hour.com should exist");
291 ok(
bhist.isVisited(
makeURI(
"http://2hour10minutes.com/")),
"Pretend visit to 2hour10minutes.com should exist");
292 ok(
bhist.isVisited(
makeURI(
"http://4hour.com")),
"Pretend visit to 4hour.com should exist");
293 ok(
bhist.isVisited(
makeURI(
"http://4hour10minutes.com/")),
"Pretend visit to 4hour10minutes.com should exist");
294 ok(
bhist.isVisited(
makeURI(
"http://today.com")),
"Pretend visit to today.com should exist");
295 ok(
bhist.isVisited(
makeURI(
"http://before-today.com")),
"Pretend visit to before-today.com should exist");
303 formhist.addEntry(
"10minutes",
"10m");
305 formhist.addEntry(
"1hour10minutes",
"1h10m");
307 formhist.addEntry(
"2hour10minutes",
"2h10m");
309 formhist.addEntry(
"4hour10minutes",
"4h10m");
315 let timestamp =
now_uSec - 10*60*1000000;
316 db.executeSimpleSQL(
"UPDATE moz_formhistory SET firstUsed = " +
317 timestamp +
" WHERE fieldname = '10minutes'");
318 timestamp =
now_uSec - 45*60*1000000;
319 db.executeSimpleSQL(
"UPDATE moz_formhistory SET firstUsed = " +
320 timestamp +
" WHERE fieldname = '1hour'");
321 timestamp =
now_uSec - 70*60*1000000;
322 db.executeSimpleSQL(
"UPDATE moz_formhistory SET firstUsed = " +
323 timestamp +
" WHERE fieldname = '1hour10minutes'");
324 timestamp =
now_uSec - 90*60*1000000;
325 db.executeSimpleSQL(
"UPDATE moz_formhistory SET firstUsed = " +
326 timestamp +
" WHERE fieldname = '2hour'");
327 timestamp =
now_uSec - 130*60*1000000;
328 db.executeSimpleSQL(
"UPDATE moz_formhistory SET firstUsed = " +
329 timestamp +
" WHERE fieldname = '2hour10minutes'");
330 timestamp =
now_uSec - 180*60*1000000;
331 db.executeSimpleSQL(
"UPDATE moz_formhistory SET firstUsed = " +
332 timestamp +
" WHERE fieldname = '4hour'");
333 timestamp =
now_uSec - 250*60*1000000;
334 db.executeSimpleSQL(
"UPDATE moz_formhistory SET firstUsed = " +
335 timestamp +
" WHERE fieldname = '4hour10minutes'");
337 let today =
new Date();
341 timestamp = today.valueOf() * 1000;
342 db.executeSimpleSQL(
"UPDATE moz_formhistory SET firstUsed = " +
343 timestamp +
" WHERE fieldname = 'today'");
345 let lastYear =
new Date();
346 lastYear.setFullYear(lastYear.getFullYear() - 1);
347 timestamp = lastYear.valueOf() * 1000;
348 db.executeSimpleSQL(
"UPDATE moz_formhistory SET firstUsed = " +
349 timestamp +
" WHERE fieldname = 'b4today'");
352 ok(
formhist.nameExists(
"10minutes"),
"Checking for 10minutes form history entry creation");
353 ok(
formhist.nameExists(
"1hour"),
"Checking for 1hour form history entry creation");
354 ok(
formhist.nameExists(
"1hour10minutes"),
"Checking for 1hour10minutes form history entry creation");
355 ok(
formhist.nameExists(
"2hour"),
"Checking for 2hour form history entry creation");
356 ok(
formhist.nameExists(
"2hour10minutes"),
"Checking for 2hour10minutes form history entry creation");
357 ok(
formhist.nameExists(
"4hour"),
"Checking for 4hour form history entry creation");
358 ok(
formhist.nameExists(
"4hour10minutes"),
"Checking for 4hour10minutes form history entry creation");
359 ok(
formhist.nameExists(
"today"),
"Checking for today form history entry creation");
360 ok(
formhist.nameExists(
"b4today"),
"Checking for b4today form history entry creation");
368 name:
"fakefile-10-minutes",
369 source:
"https://bugzilla.mozilla.org/show_bug.cgi?id=480169",
370 target:
"fakefile-10-minutes",
371 startTime:
now_uSec - 10*60*1000000,
373 state:
Ci.nsIDownloadManager.DOWNLOAD_FINISHED,
374 currBytes: 0, maxBytes: -1, preferredAction: 0, autoResume: 0
377 let db =
dm.DBConnection;
378 let stmt = db.createStatement(
379 "INSERT INTO moz_downloads (id, name, source, target, startTime, endTime, " +
380 "state, currBytes, maxBytes, preferredAction, autoResume) " +
381 "VALUES (:id, :name, :source, :target, :startTime, :endTime, :state, " +
382 ":currBytes, :maxBytes, :preferredAction, :autoResume)");
384 for (let prop in data)
385 stmt.params[prop] = data[prop];
395 name:
"fakefile-1-hour",
396 source:
"https://bugzilla.mozilla.org/show_bug.cgi?id=453440",
397 target:
"fakefile-1-hour",
398 startTime:
now_uSec - 45*60*1000000,
400 state:
Ci.nsIDownloadManager.DOWNLOAD_FINISHED,
401 currBytes: 0, maxBytes: -1, preferredAction: 0, autoResume: 0
405 for (let prop in data)
406 stmt.params[prop] = data[prop];
416 name:
"fakefile-1-hour-10-minutes",
417 source:
"https://bugzilla.mozilla.org/show_bug.cgi?id=480169",
418 target:
"fakefile-1-hour-10-minutes",
419 startTime:
now_uSec - 70*60*1000000,
421 state:
Ci.nsIDownloadManager.DOWNLOAD_FINISHED,
422 currBytes: 0, maxBytes: -1, preferredAction: 0, autoResume: 0
426 for (let prop in data)
427 stmt.params[prop] = data[prop];
437 name:
"fakefile-2-hour",
438 source:
"https://bugzilla.mozilla.org/show_bug.cgi?id=453440",
439 target:
"fakefile-2-hour",
440 startTime:
now_uSec - 90*60*1000000,
442 state:
Ci.nsIDownloadManager.DOWNLOAD_FINISHED,
443 currBytes: 0, maxBytes: -1, preferredAction: 0, autoResume: 0
447 for (let prop in data)
448 stmt.params[prop] = data[prop];
458 name:
"fakefile-2-hour-10-minutes",
459 source:
"https://bugzilla.mozilla.org/show_bug.cgi?id=480169",
460 target:
"fakefile-2-hour-10-minutes",
461 startTime:
now_uSec - 130*60*1000000,
463 state:
Ci.nsIDownloadManager.DOWNLOAD_FINISHED,
464 currBytes: 0, maxBytes: -1, preferredAction: 0, autoResume: 0
468 for (let prop in data)
469 stmt.params[prop] = data[prop];
479 name:
"fakefile-4-hour",
480 source:
"https://bugzilla.mozilla.org/show_bug.cgi?id=453440",
481 target:
"fakefile-4-hour",
482 startTime:
now_uSec - 180*60*1000000,
484 state:
Ci.nsIDownloadManager.DOWNLOAD_FINISHED,
485 currBytes: 0, maxBytes: -1, preferredAction: 0, autoResume: 0
489 for (let prop in data)
490 stmt.params[prop] = data[prop];
500 name:
"fakefile-4-hour-10-minutes",
501 source:
"https://bugzilla.mozilla.org/show_bug.cgi?id=480169",
502 target:
"fakefile-4-hour-10-minutes",
503 startTime:
now_uSec - 250*60*1000000,
505 state:
Ci.nsIDownloadManager.DOWNLOAD_FINISHED,
506 currBytes: 0, maxBytes: -1, preferredAction: 0, autoResume: 0
510 for (let prop in data)
511 stmt.params[prop] = data[prop];
519 let today =
new Date();
522 today.setSeconds(30);
526 name:
"fakefile-today",
527 source:
"https://bugzilla.mozilla.org/show_bug.cgi?id=453440",
529 startTime: today.valueOf() * 1000,
530 endTime: (today.valueOf() + 1000) * 1000,
531 state:
Ci.nsIDownloadManager.DOWNLOAD_FINISHED,
532 currBytes: 0, maxBytes: -1, preferredAction: 0, autoResume: 0
536 for (let prop in data)
537 stmt.params[prop] = data[prop];
545 let lastYear =
new Date();
546 lastYear.setFullYear(lastYear.getFullYear() - 1);
549 name:
"fakefile-old",
550 source:
"https://bugzilla.mozilla.org/show_bug.cgi?id=453440",
552 startTime: lastYear.valueOf() * 1000,
553 endTime: (lastYear.valueOf() + 1000) * 1000,
554 state:
Ci.nsIDownloadManager.DOWNLOAD_FINISHED,
555 currBytes: 0, maxBytes: -1, preferredAction: 0, autoResume: 0
559 for (let prop in data)
560 stmt.params[prop] = data[prop];
568 ok(
downloadExists(5555550),
"Pretend download for everything case should exist");
569 ok(
downloadExists(5555555),
"Pretend download for 10-minutes case should exist");
570 ok(
downloadExists(5555551),
"Pretend download for 1-hour case should exist");
571 ok(
downloadExists(5555556),
"Pretend download for 1-hour-10-minutes case should exist");
572 ok(
downloadExists(5555552),
"Pretend download for 2-hour case should exist");
573 ok(
downloadExists(5555557),
"Pretend download for 2-hour-10-minutes case should exist");
574 ok(
downloadExists(5555553),
"Pretend download for 4-hour case should exist");
575 ok(
downloadExists(5555558),
"Pretend download for 4-hour-10-minutes case should exist");
576 ok(
downloadExists(5555554),
"Pretend download for Today case should exist");
587 let db =
dm.DBConnection;
588 let stmt = db.createStatement(
590 "FROM moz_downloads " +
593 stmt.params.id = aID;
594 var rows = stmt.step();
function downloadExists(aID)
function makeURI(aURLSpec, aCharset)
function setupDownloads()
function setupFormHistory()