tor-browser

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

commit 2be6b6c7d802ce276ca383898c03b741525bacf3
parent 6b239e496c39cf1a59732096921c963dadbfcfa9
Author: Thomas Wisniewski <twisniewski@mozilla.com>
Date:   Thu,  8 Jan 2026 15:52:20 +0000

Bug 2009181 - be more careful when unregistering content scripts in the webcompat addon; r=ksenia,webcompat-reviewers

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

Diffstat:
Mbrowser/extensions/webcompat/lib/interventions.js | 10++++++++--
Mbrowser/extensions/webcompat/lib/shims.js | 10++++++++--
2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/browser/extensions/webcompat/lib/interventions.js b/browser/extensions/webcompat/lib/interventions.js @@ -564,8 +564,14 @@ class Interventions { const contentScripts = this._contentScriptsPerIntervention.get(intervention); if (contentScripts) { - const ids = contentScripts.map(s => s.id); - await browser.scripting.unregisterContentScripts({ ids }); + const ids = ( + await browser.scripting.getRegisteredContentScripts({ + ids: contentScripts.map(script => script.id), + }) + )?.map(script => script.id); + if (ids?.length) { + await browser.scripting.unregisterContentScripts({ ids }); + } } } diff --git a/browser/extensions/webcompat/lib/shims.js b/browser/extensions/webcompat/lib/shims.js @@ -353,8 +353,14 @@ class Shim { async _unregisterContentScripts() { if (this.shouldUseScriptingAPI) { - const ids = this._contentScriptRegistrations; - await browser.scripting.unregisterContentScripts({ ids }); + const ids = ( + await browser.scripting.getRegisteredContentScripts({ + ids: this._contentScriptRegistrations, + }) + )?.map(script => script.id); + if (ids?.length) { + await browser.scripting.unregisterContentScripts({ ids }); + } } else { for (const registration of this._contentScriptRegistrations) { registration.unregister();