diff --git a/browser/base/content/test/general/head.js b/browser/base/content/test/general/head.js index fcbb0c8f3e3c..09a4079906c9 100644 --- a/browser/base/content/test/general/head.js +++ b/browser/base/content/test/general/head.js @@ -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 = { diff --git a/browser/components/places/tests/browser/head.js b/browser/components/places/tests/browser/head.js index 1b8324ea7fd1..d138719fc395 100644 --- a/browser/components/places/tests/browser/head.js +++ b/browser/components/places/tests/browser/head.js @@ -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 diff --git a/toolkit/components/places/tests/history/test_removeVisits.js b/toolkit/components/places/tests/history/test_removeVisits.js index ab33c9058763..bd1bb24cb735 100644 --- a/toolkit/components/places/tests/history/test_removeVisits.js +++ b/toolkit/components/places/tests/history/test_removeVisits.js @@ -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}));