tor-browser

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

commit dea83376f29eaa27d11df6562a178ad6df412810
parent 2be355c689d5f12f51b7ac63af0d6bc6955301ef
Author: Henrik Skupin <mail@hskupin.info>
Date:   Thu, 18 Dec 2025 12:29:33 +0000

Bug 1944570 - [remote] Only use the webprogress in the RootTransport module for content browsing contexts. r=Sasha

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

Diffstat:
Mremote/shared/messagehandler/transports/RootTransport.sys.mjs | 28++++++++++++++++++----------
1 file changed, 18 insertions(+), 10 deletions(-)

diff --git a/remote/shared/messagehandler/transports/RootTransport.sys.mjs b/remote/shared/messagehandler/transports/RootTransport.sys.mjs @@ -119,10 +119,12 @@ export class RootTransport { retryOnAbort = lazy.isInitialDocument(browsingContext); } - // If a top-level browsing context was replaced and retrying is allowed, - // retrieve the new one for the current browser. + // If a top-level content browsing context was replaced and + // retrying is allowed, retrieve the new one for the current browser. if ( - browsingContext?.isReplaced && + browsingContext && + browsingContext.isContent && + browsingContext.isReplaced && browsingContext.top === browsingContext && retryOnAbort ) { @@ -137,17 +139,23 @@ export class RootTransport { ); } - // Keep a reference to the webProgress, which will persist, and always use - // it to retrieve the currently valid browsing context. + // For content browsing contexts keep a reference to the + // webProgress, which will persist, and always use it to + // retrieve the currently valid browsing context. const webProgress = browsingContext.webProgress; let attempts = 0; while (true) { try { - if (!webProgress.browsingContext.currentWindowGlobal) { - await lazy.waitForCurrentWindowGlobal(webProgress.browsingContext); + if (browsingContext.isContent) { + browsingContext = webProgress.browsingContext; } - return await webProgress.browsingContext.currentWindowGlobal + + if (!browsingContext.currentWindowGlobal) { + await lazy.waitForCurrentWindowGlobal(browsingContext); + } + + return await browsingContext.currentWindowGlobal .getActor("MessageHandlerFrame") .sendCommand(command, this._messageHandler.sessionId); } catch (e) { @@ -165,14 +173,14 @@ export class RootTransport { if (++attempts > MAX_RETRY_ATTEMPTS) { lazy.logger.trace( `RootTransport reached the limit of retry attempts (${MAX_RETRY_ATTEMPTS})` + - ` for command ${name} and browsing context ${webProgress.browsingContext.id}.` + ` for command ${name} and browsing context ${browsingContext.id}.` ); throw new lazy.error.DiscardedBrowsingContextError(e.message); } lazy.logger.trace( `RootTransport retrying command ${name} for ` + - `browsing context ${webProgress.browsingContext.id}, attempt: ${attempts}.` + `browsing context ${browsingContext.id}, attempt: ${attempts}.` ); await new Promise(resolve => Services.tm.dispatchToMainThread(resolve)); }