From 5da982316b1e6987d162a457ab8f460194a8a998 Mon Sep 17 00:00:00 2001 From: Tim Taubert Date: Thu, 15 Jan 2015 20:20:51 +0100 Subject: [PATCH] Bug 1113178 - Add PlacesTestUtils.clearHistory() r=mak --- .../places/tests/PlacesTestUtils.jsm | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/toolkit/components/places/tests/PlacesTestUtils.jsm b/toolkit/components/places/tests/PlacesTestUtils.jsm index 3ee74896168f..5cdd43b2457c 100644 --- a/toolkit/components/places/tests/PlacesTestUtils.jsm +++ b/toolkit/components/places/tests/PlacesTestUtils.jsm @@ -7,6 +7,7 @@ this.EXPORTED_SYMBOLS = [ const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components; Cu.import("resource://gre/modules/XPCOMUtils.jsm"); +Cu.import("resource://gre/modules/Services.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils", "resource://gre/modules/PlacesUtils.jsm"); @@ -73,4 +74,22 @@ this.PlacesTestUtils = Object.freeze({ ); }); }, + + /** + * Clear all history. + * + * @return {Promise} + * @resolves When history was cleared successfully. + * @rejects JavaScript exception. + */ + clearHistory() { + let expirationFinished = new Promise(resolve => { + Services.obs.addObserver(function observe(subj, topic, data) { + Services.obs.removeObserver(observe, topic); + resolve(); + }, PlacesUtils.TOPIC_EXPIRATION_FINISHED, false); + }); + + return Promise.all([expirationFinished, PlacesUtils.history.clear()]); + } });