Bug 480437 - test_expiration is working on wrong assumptions, r=dietrich

This commit is contained in:
Marco Bonardo 2009-03-05 13:08:43 +01:00
Родитель 210065158a
Коммит 2bb18fd030
1 изменённых файлов: 51 добавлений и 40 удалений

Просмотреть файл

@ -476,6 +476,7 @@ function run_test() {
// run async, chained
function startIncrementalExpirationTests() {
do_test_pending();
startExpireNeither();
}
@ -502,13 +503,15 @@ confirmation:
*/
function startExpireNeither() {
dump("startExpireNeither()\n");
// setup
// Cleanup.
histsvc.removeAllPages();
observer.expiredURI = null;
// add data
// Setup data.
histsvc.addVisit(testURI, Date.now() * 1000, null, histsvc.TRANSITION_TYPED, false, 0);
annosvc.setPageAnnotation(testURI, testAnnoName, testAnnoVal, 0, annosvc.EXPIRE_NEVER);
histsvc.addVisit(triggerURI, Date.now() * 1000, null, histsvc.TRANSITION_TYPED, false, 0);
annosvc.setPageAnnotation(triggerURI, testAnnoName, testAnnoVal, 0, annosvc.EXPIRE_NEVER);
// set sites cap to 2
prefs.setIntPref("browser.history_expire_sites", 2);
@ -517,12 +520,11 @@ function startExpireNeither() {
// set date maximum to 3
prefs.setIntPref("browser.history_expire_days", 3);
// trigger expiration
ghist.addURI(triggerURI, false, true, null);
// Changing expiration preferences has already triggered expiration, it will
// run after the partial expiration timer (3,5s).
// setup confirmation
do_test_pending();
do_timeout(3600, "checkExpireNeither();"); // incremental expiration timer is 3500
// Check results.
do_timeout(3600, "checkExpireNeither();");
}
function checkExpireNeither() {
@ -530,6 +532,7 @@ function checkExpireNeither() {
try {
do_check_eq(observer.expiredURI, null);
do_check_eq(annosvc.getPageAnnotationNames(testURI, {}).length, 1);
do_check_eq(annosvc.getPageAnnotationNames(triggerURI, {}).length, 1);
} catch(ex) {
do_throw(ex);
}
@ -558,12 +561,11 @@ confirmation:
- query for the visit, confirm it's there
*/
function startExpireDaysOnly() {
// setup
dump("startExpireDaysOnly()\n");
// Cleanup.
histsvc.removeAllPages();
observer.expiredURI = null;
dump("startExpireDaysOnly()\n");
// add expirable visit
histsvc.addVisit(testURI, (Date.now() - (86400 * 4 * 1000)) * 1000, null, histsvc.TRANSITION_TYPED, false, 0);
annosvc.setPageAnnotation(testURI, testAnnoName, testAnnoVal, 0, annosvc.EXPIRE_NEVER);
@ -580,11 +582,11 @@ function startExpireDaysOnly() {
// set date maximum to 3
prefs.setIntPref("browser.history_expire_days", 3);
// trigger expiration
ghist.addURI(triggerURI, false, true, null);
// Changing expiration preferences has already triggered expiration, it will
// run after the partial expiration timer (3,5s).
// setup confirmation
do_timeout(3600, "checkExpireDaysOnly();"); // incremental expiration timer is 3500
// Check results.
do_timeout(3600, "checkExpireDaysOnly();");
}
function checkExpireDaysOnly() {
@ -623,18 +625,17 @@ confirmation:
- query for the oldest visit, confirm it's not there
*/
function startExpireBoth() {
// setup
dump("starting expiration test 3: both criteria met\n");
// Cleanup.
histsvc.removeAllPages();
observer.expiredURI = null;
dump("starting expiration test 3: both criteria met\n");
// force a sync, this will ensure that later we will have the same place in
// both temp and disk table, and that the expire site cap count is correct.
// adw: Commented out per bug 412132. The patch to that bug made it illegal
// to pass bad item IDs into changeBookmarkURI; |bookmark| was removed up in
// run_test, and it's never added or used again. The only thing this call
// ended up doing was updating testURI's frecency and notifying bookmark
// observers that testURI had changed. Neither appears relevant to this test.
//bmsvc.changeBookmarkURI(bookmark, testURI);
// Inserting a bookmark will force a sync, this will ensure that later we will
// have the same place in both temp and disk table, and that the expire site
// cap count is correct.
var bmId = bmsvc.insertBookmark(bmsvc.toolbarFolder, testURI, bmsvc.DEFAULT_INDEX, "foo");
bmsvc.removeItem(bmId);
// add visits
// 2 days old, in microseconds
var age = (Date.now() - (86400 * 2 * 1000)) * 1000;
@ -642,6 +643,9 @@ function startExpireBoth() {
histsvc.addVisit(testURI, age, null, histsvc.TRANSITION_TYPED, false, 0);
annosvc.setPageAnnotation(testURI, testAnnoName, testAnnoVal, 0, annosvc.EXPIRE_NEVER);
histsvc.addVisit(triggerURI, Date.now() * 1000, null, histsvc.TRANSITION_TYPED, false, 0);
annosvc.setPageAnnotation(triggerURI, testAnnoName, testAnnoVal, 0, annosvc.EXPIRE_NEVER);
// set sites cap to 1
prefs.setIntPref("browser.history_expire_sites", 1);
// set date max to 3
@ -649,11 +653,10 @@ function startExpireBoth() {
// set date minimum to 1
prefs.setIntPref("browser.history_expire_days_min", 1);
// trigger expiration
histsvc.addVisit(triggerURI, Date.now() * 1000, null, histsvc.TRANSITION_TYPED, false, 0);
annosvc.setPageAnnotation(triggerURI, testAnnoName, testAnnoVal, 0, annosvc.EXPIRE_NEVER);
// Changing expiration preferences has already triggered expiration, it will
// run after the partial expiration timer (3,5s).
// setup confirmation
// Check results.
do_timeout(3600, "checkExpireBoth();"); // incremental expiration timer is 3500
}
@ -691,7 +694,7 @@ confirmation:
*/
function startExpireNeitherOver() {
dump("startExpireNeitherOver()\n");
// setup
// Cleanup.
histsvc.removeAllPages();
observer.expiredURI = null;
@ -699,6 +702,9 @@ function startExpireNeitherOver() {
histsvc.addVisit(testURI, Date.now() * 1000, null, histsvc.TRANSITION_TYPED, false, 0);
annosvc.setPageAnnotation(testURI, testAnnoName, testAnnoVal, 0, annosvc.EXPIRE_NEVER);
histsvc.addVisit(triggerURI, Date.now() * 1000, null, histsvc.TRANSITION_TYPED, false, 0);
annosvc.setPageAnnotation(triggerURI, testAnnoName, testAnnoVal, 0, annosvc.EXPIRE_NEVER);
// set sites cap to 1
prefs.setIntPref("browser.history_expire_sites", 1);
// set date minimum to 2
@ -706,12 +712,11 @@ function startExpireNeitherOver() {
// set date maximum to 3
prefs.setIntPref("browser.history_expire_days", 3);
// trigger expiration
histsvc.addVisit(triggerURI, Date.now() * 1000, null, histsvc.TRANSITION_TYPED, false, 0);
annosvc.setPageAnnotation(triggerURI, testAnnoName, testAnnoVal, 0, annosvc.EXPIRE_NEVER);
// Changing expiration preferences has already triggered expiration, it will
// run after the partial expiration timer (3,5s).
// setup confirmation
do_timeout(3600, "checkExpireNeitherOver();"); // incremental expiration timer is 3500
// Check results.
do_timeout(3600, "checkExpireNeitherOver();");
}
function checkExpireNeitherOver() {
@ -746,7 +751,7 @@ confirmation:
*/
function startExpireHistoryDisabled() {
dump("startExpireHistoryDisabled()\n");
// setup
// Cleanup.
histsvc.removeAllPages();
observer.expiredURI = null;
@ -757,8 +762,11 @@ function startExpireHistoryDisabled() {
// set date maximum to 0
prefs.setIntPref("browser.history_expire_days", 0);
// setup confirmation
do_timeout(3600, "checkExpireHistoryDisabled();"); // incremental expiration timer is 3500
// Changing expiration preferences has already triggered expiration, it will
// run after the partial expiration timer (3,5s).
// Check results.
do_timeout(3600, "checkExpireHistoryDisabled();");
}
function checkExpireHistoryDisabled() {
@ -793,7 +801,7 @@ confirmation:
*/
function startExpireBadPrefs() {
dump("startExpireBadPrefs()\n");
// setup
// Cleanup.
histsvc.removeAllPages();
observer.expiredURI = null;
@ -807,8 +815,11 @@ function startExpireBadPrefs() {
// set date maximum to 1
prefs.setIntPref("browser.history_expire_days", 1);
// setup confirmation
do_timeout(3600, "checkExpireBadPrefs();"); // incremental expiration timer is 3500
// Changing expiration preferences has already triggered expiration, it will
// run after the partial expiration timer (3,5s).
// Check results.
do_timeout(3600, "checkExpireBadPrefs();");
}
function checkExpireBadPrefs() {