зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1113178 - Add PlacesTestUtils.clearHistory() r=mak
This commit is contained in:
Родитель
75e5c463c1
Коммит
5da982316b
|
@ -7,6 +7,7 @@ this.EXPORTED_SYMBOLS = [
|
||||||
const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
|
const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
|
||||||
|
|
||||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||||
|
Cu.import("resource://gre/modules/Services.jsm");
|
||||||
|
|
||||||
XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils",
|
XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils",
|
||||||
"resource://gre/modules/PlacesUtils.jsm");
|
"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()]);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
Загрузка…
Ссылка в новой задаче