diff --git a/toolkit/modules/NewTabUtils.jsm b/toolkit/modules/NewTabUtils.jsm index 86043e234c44..34715dd49704 100644 --- a/toolkit/modules/NewTabUtils.jsm +++ b/toolkit/modules/NewTabUtils.jsm @@ -1296,6 +1296,7 @@ var ActivityStreamLinks = { * @param {Object} aOptions * {bool} excludeBookmarks: Don't add bookmark items. * {bool} excludeHistory: Don't add history items. + * {bool} withFavicons: Add favicon data: URIs, when possible. * {int} numItems: Maximum number of (bookmark or history) items to return. * * @return {Promise} Returns a promise with the array of links as the payload @@ -1328,6 +1329,11 @@ var ActivityStreamLinks = { } } + if (aOptions.withFavicons) { + return ActivityStreamProvider._faviconBytesToDataURI( + await ActivityStreamProvider._addFavicons(results)); + } + return results; }, diff --git a/toolkit/modules/tests/xpcshell/test_NewTabUtils.js b/toolkit/modules/tests/xpcshell/test_NewTabUtils.js index 70281f1651c2..0fe7813e39c4 100644 --- a/toolkit/modules/tests/xpcshell/test_NewTabUtils.js +++ b/toolkit/modules/tests/xpcshell/test_NewTabUtils.js @@ -478,6 +478,15 @@ add_task(async function getHighlights() { Assert.equal(links[0].type, "bookmark", "was history now bookmark"); Assert.equal(links[1].url, bookmarks[1].url, "still have younger bookmark now second"); Assert.equal(links[2].url, bookmarks[0].url, "still have older bookmark now third"); + + // Test the `withFavicons` option. + links = await provider.getHighlights({ withFavicons: true }); + Assert.equal(links.length, 3, "We're not expecting a change in links"); + // We don't have the favicon service all bootstrapped and that's unnecessary + // for this unit. + Assert.ok("favicon" in links[0], "Link 1 should contain a favicon"); + Assert.ok("favicon" in links[1], "Link 2 should contain a favicon"); + Assert.ok("favicon" in links[2], "Link 3 should contain a favicon"); }); add_task(async function getTopFrecentSites() {