зеркало из https://github.com/mozilla/gecko-dev.git
Bug 480437 - test_expiration is working on wrong assumptions, r=dietrich
This commit is contained in:
Родитель
210065158a
Коммит
2bb18fd030
|
@ -476,6 +476,7 @@ function run_test() {
|
||||||
// run async, chained
|
// run async, chained
|
||||||
|
|
||||||
function startIncrementalExpirationTests() {
|
function startIncrementalExpirationTests() {
|
||||||
|
do_test_pending();
|
||||||
startExpireNeither();
|
startExpireNeither();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -502,13 +503,15 @@ confirmation:
|
||||||
*/
|
*/
|
||||||
function startExpireNeither() {
|
function startExpireNeither() {
|
||||||
dump("startExpireNeither()\n");
|
dump("startExpireNeither()\n");
|
||||||
// setup
|
// Cleanup.
|
||||||
histsvc.removeAllPages();
|
histsvc.removeAllPages();
|
||||||
observer.expiredURI = null;
|
observer.expiredURI = null;
|
||||||
|
|
||||||
// add data
|
// Setup data.
|
||||||
histsvc.addVisit(testURI, Date.now() * 1000, null, histsvc.TRANSITION_TYPED, false, 0);
|
histsvc.addVisit(testURI, Date.now() * 1000, null, histsvc.TRANSITION_TYPED, false, 0);
|
||||||
annosvc.setPageAnnotation(testURI, testAnnoName, testAnnoVal, 0, annosvc.EXPIRE_NEVER);
|
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
|
// set sites cap to 2
|
||||||
prefs.setIntPref("browser.history_expire_sites", 2);
|
prefs.setIntPref("browser.history_expire_sites", 2);
|
||||||
|
@ -517,12 +520,11 @@ function startExpireNeither() {
|
||||||
// set date maximum to 3
|
// set date maximum to 3
|
||||||
prefs.setIntPref("browser.history_expire_days", 3);
|
prefs.setIntPref("browser.history_expire_days", 3);
|
||||||
|
|
||||||
// trigger expiration
|
// Changing expiration preferences has already triggered expiration, it will
|
||||||
ghist.addURI(triggerURI, false, true, null);
|
// run after the partial expiration timer (3,5s).
|
||||||
|
|
||||||
// setup confirmation
|
// Check results.
|
||||||
do_test_pending();
|
do_timeout(3600, "checkExpireNeither();");
|
||||||
do_timeout(3600, "checkExpireNeither();"); // incremental expiration timer is 3500
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkExpireNeither() {
|
function checkExpireNeither() {
|
||||||
|
@ -530,6 +532,7 @@ function checkExpireNeither() {
|
||||||
try {
|
try {
|
||||||
do_check_eq(observer.expiredURI, null);
|
do_check_eq(observer.expiredURI, null);
|
||||||
do_check_eq(annosvc.getPageAnnotationNames(testURI, {}).length, 1);
|
do_check_eq(annosvc.getPageAnnotationNames(testURI, {}).length, 1);
|
||||||
|
do_check_eq(annosvc.getPageAnnotationNames(triggerURI, {}).length, 1);
|
||||||
} catch(ex) {
|
} catch(ex) {
|
||||||
do_throw(ex);
|
do_throw(ex);
|
||||||
}
|
}
|
||||||
|
@ -558,12 +561,11 @@ confirmation:
|
||||||
- query for the visit, confirm it's there
|
- query for the visit, confirm it's there
|
||||||
*/
|
*/
|
||||||
function startExpireDaysOnly() {
|
function startExpireDaysOnly() {
|
||||||
// setup
|
dump("startExpireDaysOnly()\n");
|
||||||
|
// Cleanup.
|
||||||
histsvc.removeAllPages();
|
histsvc.removeAllPages();
|
||||||
observer.expiredURI = null;
|
observer.expiredURI = null;
|
||||||
|
|
||||||
dump("startExpireDaysOnly()\n");
|
|
||||||
|
|
||||||
// add expirable visit
|
// add expirable visit
|
||||||
histsvc.addVisit(testURI, (Date.now() - (86400 * 4 * 1000)) * 1000, null, histsvc.TRANSITION_TYPED, false, 0);
|
histsvc.addVisit(testURI, (Date.now() - (86400 * 4 * 1000)) * 1000, null, histsvc.TRANSITION_TYPED, false, 0);
|
||||||
annosvc.setPageAnnotation(testURI, testAnnoName, testAnnoVal, 0, annosvc.EXPIRE_NEVER);
|
annosvc.setPageAnnotation(testURI, testAnnoName, testAnnoVal, 0, annosvc.EXPIRE_NEVER);
|
||||||
|
@ -580,11 +582,11 @@ function startExpireDaysOnly() {
|
||||||
// set date maximum to 3
|
// set date maximum to 3
|
||||||
prefs.setIntPref("browser.history_expire_days", 3);
|
prefs.setIntPref("browser.history_expire_days", 3);
|
||||||
|
|
||||||
// trigger expiration
|
// Changing expiration preferences has already triggered expiration, it will
|
||||||
ghist.addURI(triggerURI, false, true, null);
|
// run after the partial expiration timer (3,5s).
|
||||||
|
|
||||||
// setup confirmation
|
// Check results.
|
||||||
do_timeout(3600, "checkExpireDaysOnly();"); // incremental expiration timer is 3500
|
do_timeout(3600, "checkExpireDaysOnly();");
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkExpireDaysOnly() {
|
function checkExpireDaysOnly() {
|
||||||
|
@ -623,18 +625,17 @@ confirmation:
|
||||||
- query for the oldest visit, confirm it's not there
|
- query for the oldest visit, confirm it's not there
|
||||||
*/
|
*/
|
||||||
function startExpireBoth() {
|
function startExpireBoth() {
|
||||||
// setup
|
dump("starting expiration test 3: both criteria met\n");
|
||||||
|
// Cleanup.
|
||||||
histsvc.removeAllPages();
|
histsvc.removeAllPages();
|
||||||
observer.expiredURI = null;
|
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
|
// Inserting a bookmark will force a sync, this will ensure that later we will
|
||||||
// both temp and disk table, and that the expire site cap count is correct.
|
// have the same place in both temp and disk table, and that the expire site
|
||||||
// adw: Commented out per bug 412132. The patch to that bug made it illegal
|
// cap count is correct.
|
||||||
// to pass bad item IDs into changeBookmarkURI; |bookmark| was removed up in
|
var bmId = bmsvc.insertBookmark(bmsvc.toolbarFolder, testURI, bmsvc.DEFAULT_INDEX, "foo");
|
||||||
// run_test, and it's never added or used again. The only thing this call
|
bmsvc.removeItem(bmId);
|
||||||
// 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);
|
|
||||||
// add visits
|
// add visits
|
||||||
// 2 days old, in microseconds
|
// 2 days old, in microseconds
|
||||||
var age = (Date.now() - (86400 * 2 * 1000)) * 1000;
|
var age = (Date.now() - (86400 * 2 * 1000)) * 1000;
|
||||||
|
@ -642,6 +643,9 @@ function startExpireBoth() {
|
||||||
histsvc.addVisit(testURI, age, null, histsvc.TRANSITION_TYPED, false, 0);
|
histsvc.addVisit(testURI, age, null, histsvc.TRANSITION_TYPED, false, 0);
|
||||||
annosvc.setPageAnnotation(testURI, testAnnoName, testAnnoVal, 0, annosvc.EXPIRE_NEVER);
|
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
|
// set sites cap to 1
|
||||||
prefs.setIntPref("browser.history_expire_sites", 1);
|
prefs.setIntPref("browser.history_expire_sites", 1);
|
||||||
// set date max to 3
|
// set date max to 3
|
||||||
|
@ -649,11 +653,10 @@ function startExpireBoth() {
|
||||||
// set date minimum to 1
|
// set date minimum to 1
|
||||||
prefs.setIntPref("browser.history_expire_days_min", 1);
|
prefs.setIntPref("browser.history_expire_days_min", 1);
|
||||||
|
|
||||||
// trigger expiration
|
// Changing expiration preferences has already triggered expiration, it will
|
||||||
histsvc.addVisit(triggerURI, Date.now() * 1000, null, histsvc.TRANSITION_TYPED, false, 0);
|
// run after the partial expiration timer (3,5s).
|
||||||
annosvc.setPageAnnotation(triggerURI, testAnnoName, testAnnoVal, 0, annosvc.EXPIRE_NEVER);
|
|
||||||
|
|
||||||
// setup confirmation
|
// Check results.
|
||||||
do_timeout(3600, "checkExpireBoth();"); // incremental expiration timer is 3500
|
do_timeout(3600, "checkExpireBoth();"); // incremental expiration timer is 3500
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -691,7 +694,7 @@ confirmation:
|
||||||
*/
|
*/
|
||||||
function startExpireNeitherOver() {
|
function startExpireNeitherOver() {
|
||||||
dump("startExpireNeitherOver()\n");
|
dump("startExpireNeitherOver()\n");
|
||||||
// setup
|
// Cleanup.
|
||||||
histsvc.removeAllPages();
|
histsvc.removeAllPages();
|
||||||
observer.expiredURI = null;
|
observer.expiredURI = null;
|
||||||
|
|
||||||
|
@ -699,6 +702,9 @@ function startExpireNeitherOver() {
|
||||||
histsvc.addVisit(testURI, Date.now() * 1000, null, histsvc.TRANSITION_TYPED, false, 0);
|
histsvc.addVisit(testURI, Date.now() * 1000, null, histsvc.TRANSITION_TYPED, false, 0);
|
||||||
annosvc.setPageAnnotation(testURI, testAnnoName, testAnnoVal, 0, annosvc.EXPIRE_NEVER);
|
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
|
// set sites cap to 1
|
||||||
prefs.setIntPref("browser.history_expire_sites", 1);
|
prefs.setIntPref("browser.history_expire_sites", 1);
|
||||||
// set date minimum to 2
|
// set date minimum to 2
|
||||||
|
@ -706,12 +712,11 @@ function startExpireNeitherOver() {
|
||||||
// set date maximum to 3
|
// set date maximum to 3
|
||||||
prefs.setIntPref("browser.history_expire_days", 3);
|
prefs.setIntPref("browser.history_expire_days", 3);
|
||||||
|
|
||||||
// trigger expiration
|
// Changing expiration preferences has already triggered expiration, it will
|
||||||
histsvc.addVisit(triggerURI, Date.now() * 1000, null, histsvc.TRANSITION_TYPED, false, 0);
|
// run after the partial expiration timer (3,5s).
|
||||||
annosvc.setPageAnnotation(triggerURI, testAnnoName, testAnnoVal, 0, annosvc.EXPIRE_NEVER);
|
|
||||||
|
|
||||||
// setup confirmation
|
// Check results.
|
||||||
do_timeout(3600, "checkExpireNeitherOver();"); // incremental expiration timer is 3500
|
do_timeout(3600, "checkExpireNeitherOver();");
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkExpireNeitherOver() {
|
function checkExpireNeitherOver() {
|
||||||
|
@ -746,7 +751,7 @@ confirmation:
|
||||||
*/
|
*/
|
||||||
function startExpireHistoryDisabled() {
|
function startExpireHistoryDisabled() {
|
||||||
dump("startExpireHistoryDisabled()\n");
|
dump("startExpireHistoryDisabled()\n");
|
||||||
// setup
|
// Cleanup.
|
||||||
histsvc.removeAllPages();
|
histsvc.removeAllPages();
|
||||||
observer.expiredURI = null;
|
observer.expiredURI = null;
|
||||||
|
|
||||||
|
@ -757,8 +762,11 @@ function startExpireHistoryDisabled() {
|
||||||
// set date maximum to 0
|
// set date maximum to 0
|
||||||
prefs.setIntPref("browser.history_expire_days", 0);
|
prefs.setIntPref("browser.history_expire_days", 0);
|
||||||
|
|
||||||
// setup confirmation
|
// Changing expiration preferences has already triggered expiration, it will
|
||||||
do_timeout(3600, "checkExpireHistoryDisabled();"); // incremental expiration timer is 3500
|
// run after the partial expiration timer (3,5s).
|
||||||
|
|
||||||
|
// Check results.
|
||||||
|
do_timeout(3600, "checkExpireHistoryDisabled();");
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkExpireHistoryDisabled() {
|
function checkExpireHistoryDisabled() {
|
||||||
|
@ -793,7 +801,7 @@ confirmation:
|
||||||
*/
|
*/
|
||||||
function startExpireBadPrefs() {
|
function startExpireBadPrefs() {
|
||||||
dump("startExpireBadPrefs()\n");
|
dump("startExpireBadPrefs()\n");
|
||||||
// setup
|
// Cleanup.
|
||||||
histsvc.removeAllPages();
|
histsvc.removeAllPages();
|
||||||
observer.expiredURI = null;
|
observer.expiredURI = null;
|
||||||
|
|
||||||
|
@ -807,8 +815,11 @@ function startExpireBadPrefs() {
|
||||||
// set date maximum to 1
|
// set date maximum to 1
|
||||||
prefs.setIntPref("browser.history_expire_days", 1);
|
prefs.setIntPref("browser.history_expire_days", 1);
|
||||||
|
|
||||||
// setup confirmation
|
// Changing expiration preferences has already triggered expiration, it will
|
||||||
do_timeout(3600, "checkExpireBadPrefs();"); // incremental expiration timer is 3500
|
// run after the partial expiration timer (3,5s).
|
||||||
|
|
||||||
|
// Check results.
|
||||||
|
do_timeout(3600, "checkExpireBadPrefs();");
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkExpireBadPrefs() {
|
function checkExpireBadPrefs() {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче