tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 1f2e70f323be31fb98a9cfa0dc14579c347d6d79
parent bba40dbf5b389da32eef025fd8ea868948eb03e5
Author: Tom Schuster <tschuster@mozilla.com>
Date:   Wed,  7 Jan 2026 08:58:12 +0000

Bug 2006037 - Use the moz-remote-image: protocol for Synced Tabs favicons. r=sync-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D276438

Diffstat:
Mbrowser/base/content/browser-sync.js | 23++++++++++++++++++++++-
Mbrowser/components/customizableui/test/browser_synced_tabs_menu.js | 15+++++++++++++++
2 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/browser/base/content/browser-sync.js b/browser/base/content/browser-sync.js @@ -11,6 +11,9 @@ const { "resource://gre/modules/FxAccountsCommon.sys.mjs" ); +const { TRUSTED_FAVICON_SCHEMES, getMozRemoteImageURL } = + ChromeUtils.importESModule("moz-src:///browser/modules/FaviconUtils.sys.mjs"); + const { UIState } = ChromeUtils.importESModule( "resource://services-sync/UIState.sys.mjs" ); @@ -295,7 +298,20 @@ this.SyncedTabsPanelList = class SyncedTabsPanelList { tabInfo.title != "" ? tabInfo.title : tabInfo.url ); if (tabInfo.icon) { - item.setAttribute("image", tabInfo.icon); + let icon = tabInfo.icon; + if (gSync.REMOTE_SVG_ICON_DECODING) { + try { + const uri = NetUtil.newURI(icon); + if (!TRUSTED_FAVICON_SCHEMES.includes(uri.scheme)) { + const size = Math.floor(16 * window.devicePixelRatio); + icon = getMozRemoteImageURL(uri.spec, size); + } + } catch (e) { + console.error(e); + icon = ""; + } + } + item.setAttribute("image", icon); } item.setAttribute("tooltiptext", tooltipText); // We need to use "click" instead of "command" here so openUILink @@ -561,6 +577,11 @@ var gSync = { "FXA_CTA_MENU_ENABLED", "identity.fxaccounts.toolbar.pxiToolbarEnabled" ); + XPCOMUtils.defineLazyPreferenceGetter( + this, + "REMOTE_SVG_ICON_DECODING", + "browser.tabs.remoteSVGIconDecoding" + ); }, maybeUpdateUIState() { diff --git a/browser/components/customizableui/test/browser_synced_tabs_menu.js b/browser/components/customizableui/test/browser_synced_tabs_menu.js @@ -259,6 +259,10 @@ add_task(async function () { // Test the "Sync Now" button add_task(async function () { + await SpecialPowers.pushPrefEnv({ + set: [["browser.tabs.remoteSVGIconDecoding", true]], + }); + gSync.updateAllUI({ status: UIState.STATUS_SIGNED_IN, syncEnabled: true, @@ -336,6 +340,7 @@ add_task(async function () { tabs: [ { title: "http://example.com/6", + icon: "http://example.com/favicon.ico", lastUsed: 6, }, ], @@ -398,6 +403,14 @@ add_task(async function () { childNode = node.firstElementChild; is(childNode.getAttribute("itemtype"), "tab", "node is a tab"); is(childNode.getAttribute("label"), "http://example.com/6"); + // Check the favicon image. + let image = new URL(childNode.getAttribute("image")); + is(image.protocol, "moz-remote-image:", "image protocol is correct"); + is( + image.searchParams.get("url"), + "http://example.com/favicon.ico", + "image url is correct" + ); node = node.nextElementSibling; is(node, null, "no more siblings"); @@ -451,6 +464,8 @@ add_task(async function () { ok(didSync, "clicking the button called the correct function"); await hideOverflow(); + + await SpecialPowers.popPrefEnv(); }); // Test the pagination capabilities (Show More/All tabs)