Bug 1113178 - Add PlacesTestUtils.clearHistory() r=mak

This commit is contained in:
Tim Taubert 2015-01-15 20:20:51 +01:00
Родитель 75e5c463c1
Коммит 5da982316b
1 изменённых файлов: 19 добавлений и 0 удалений

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

@ -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()]);
}
});