Bug 897954: Add a test for purging caches. r=mak

Differential Revision: https://phabricator.services.mozilla.com/D105589
This commit is contained in:
Daisuke Akatsuka 2021-02-25 00:12:41 +00:00
parent 9f8f7cf96f
commit d13e84ccdd
2 changed files with 32 additions and 0 deletions

View File

@ -0,0 +1,31 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
// Test whether purge-caches event works collectry when maintenance the places.
add_task(async function test_history() {
await PlacesTestUtils.addVisits({ uri: "http://example.com/" });
await assertPurgingCaches();
});
add_task(async function test_bookmark() {
await PlacesTestUtils.addBookmarkWithDetails({ uri: "http://example.com/" });
await assertPurgingCaches();
});
async function assertPurgingCaches() {
const query = PlacesUtils.history.getNewQuery();
const options = PlacesUtils.history.getNewQueryOptions();
const result = PlacesUtils.history.executeQuery(query, options);
result.root.containerOpen = true;
const onInvalidateContainer = new Promise(resolve => {
const resultObserver = new NavHistoryResultObserver();
resultObserver.invalidateContainer = resolve;
result.addObserver(resultObserver, false);
});
await PlacesDBUtils.maintenanceOnIdle();
await onInvalidateContainer;
ok(true, "InvalidateContainer is called");
}

View File

@ -12,6 +12,7 @@ support-files =
[test_favicons_replaceOnStartup.js]
[test_favicons_replaceOnStartup_clone.js]
[test_integrity_replacement.js]
[test_places_purge_caches.js]
[test_places_replaceOnStartup.js]
[test_places_replaceOnStartup_clone.js]
[test_preventive_maintenance.js]