Bug 1433492 - Remove remaining instances of PlacesUtils.asyncHistory.isURIVisited being called directly. r=mak

MozReview-Commit-ID: B1sqEtJcq4L

--HG--
extra : rebase_source : 62a7c91e06f28712e9ba29a2e3ef73fa7dd9a0e1
This commit is contained in:
Mark Banner 2018-01-26 16:40:25 +00:00
Родитель a73a6015a8
Коммит dd6c928ffd
3 изменённых файлов: 18 добавлений и 40 удалений

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

@ -304,22 +304,12 @@ function promiseTabLoaded(aTab) {
* @param aShouldBeCleared
* True if each visit to the URI should be cleared, false otherwise
*/
function promiseHistoryClearedState(aURIs, aShouldBeCleared) {
return new Promise(resolve => {
let callbackCount = 0;
let niceStr = aShouldBeCleared ? "no longer" : "still";
function callbackDone() {
if (++callbackCount == aURIs.length)
resolve();
}
aURIs.forEach(function(aURI) {
PlacesUtils.asyncHistory.isURIVisited(aURI, function(uri, isVisited) {
is(isVisited, !aShouldBeCleared,
"history visit " + uri.spec + " should " + niceStr + " exist");
callbackDone();
});
});
});
async function promiseHistoryClearedState(aURIs, aShouldBeCleared) {
for (let uri of aURIs) {
let visited = await PlacesUtils.history.hasVisits(uri);
Assert.equal(visited, !aShouldBeCleared,
`history visit ${uri.spec} should ${aShouldBeCleared ? "no longer" : "still"} exist`);
}
}
var FullZoomHelper = {

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

@ -142,18 +142,6 @@ function synthesizeClickOnSelectedTreeCell(aTree, aOptions) {
aTree.ownerGlobal);
}
/**
* Asynchronously check a url is visited.
*
* @param aURI The URI.
* @return {Promise}
* @resolves When the check has been added successfully.
* @rejects JavaScript exception.
*/
function promiseIsURIVisited(aURI) {
return PlacesUtils.history.hasVisits(aURI);
}
/**
* Makes the specified toolbar visible or invisible and returns a Promise object
* that is resolved when the toolbar has completed any animations associated

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

@ -44,8 +44,8 @@ add_task(async function remove_visits_outside_unbookmarked_uri() {
}
root.containerOpen = false;
info("PlacesUtils.history.hasVisits should return true.");
Assert.ok(await PlacesUtils.history.hasVisits(TEST_URI));
Assert.ok(await PlacesUtils.history.hasVisits(TEST_URI),
"visit should exist");
await PlacesTestUtils.promiseAsyncUpdates();
info("Frecency should be positive.");
@ -95,8 +95,8 @@ add_task(async function remove_visits_outside_bookmarked_uri() {
}
root.containerOpen = false;
info("asyncHistory.isURIVisited should return true.");
Assert.ok(await PlacesUtils.history.hasVisits(TEST_URI));
Assert.ok(await PlacesUtils.history.hasVisits(TEST_URI),
"visit should exist");
await PlacesTestUtils.promiseAsyncUpdates();
info("Frecency should be positive.");
@ -140,8 +140,8 @@ add_task(async function remove_visits_unbookmarked_uri() {
}
root.containerOpen = false;
info("asyncHistory.isURIVisited should return true.");
Assert.ok(await PlacesUtils.history.hasVisits(TEST_URI));
Assert.ok(await PlacesUtils.history.hasVisits(TEST_URI),
"visit should exist");
await PlacesTestUtils.promiseAsyncUpdates();
info("Frecency should be positive.");
@ -191,8 +191,8 @@ add_task(async function remove_visits_bookmarked_uri() {
}
root.containerOpen = false;
info("asyncHistory.isURIVisited should return true.");
Assert.ok(await PlacesUtils.history.hasVisits(TEST_URI));
Assert.ok(await PlacesUtils.history.hasVisits(TEST_URI),
"visit should exist");
await PlacesTestUtils.promiseAsyncUpdates();
info("Frecency should be positive.");
@ -232,8 +232,8 @@ add_task(async function remove_all_visits_unbookmarked_uri() {
Assert.equal(root.childCount, 0);
root.containerOpen = false;
info("asyncHistory.isURIVisited should return false.");
Assert.equal(false, await PlacesUtils.history.hasVisits(TEST_URI));
Assert.equal(false, await PlacesUtils.history.hasVisits(TEST_URI),
"visit should not exist");
await cleanup();
});
@ -276,8 +276,8 @@ add_task(async function remove_all_visits_bookmarked_uri() {
Assert.equal(root.childCount, 0);
root.containerOpen = false;
info("asyncHistory.isURIVisited should return false.");
Assert.equal(false, await PlacesUtils.history.hasVisits(TEST_URI));
Assert.equal(false, await PlacesUtils.history.hasVisits(TEST_URI),
"visit should not exist");
info("URI should be bookmarked");
Assert.ok(await PlacesUtils.bookmarks.fetch({url: TEST_URI}));