tor-browser

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

commit a71a17c837d036576a7ce75ae3469887fdb77297
parent b09ef74238c48fcfcdc7668e072f702e0c5c89fd
Author: Serban Stanca <sstanca@mozilla.com>
Date:   Fri, 19 Dec 2025 22:49:57 +0200

Revert "Bug 2004329, Bug 1960549, Bug 2006181 - [devtools] Display webTransport session request in the netmonitor r=devtools-reviewers,nchevobbe" for causing xpcshell failures in test_webtransport_simple.js.

This reverts commit 63760f73c8971618240cbd485304f21bc01f1fe0.

This reverts commit 4aafd5370851211ca68948717799a3b0c8037614.

This reverts commit 7fcfc7eec91dd48ccc484c3bf49337e5e8608e82.

Diffstat:
Mdevtools/client/netmonitor/src/connector/index.js | 27++++++++++-----------------
Mdevtools/server/actors/resources/index.js | 4----
Mdevtools/server/actors/resources/moz.build | 1-
Ddevtools/server/actors/resources/webtransport.js | 92-------------------------------------------------------------------------------
Mdevtools/server/actors/watcher/session-context.js | 1-
Mdevtools/server/tests/chrome/chrome.toml | 2--
Ddevtools/server/tests/chrome/test_webtransport-listeners.html | 32--------------------------------
Mdevtools/shared/commands/resource/resource-command.js | 1-
Mdevtools/shared/network-observer/NetworkUtils.sys.mjs | 1-
Mdom/webtransport/api/WebTransport.cpp | 11+++--------
Mdom/webtransport/api/WebTransport.h | 1-
Mdom/webtransport/parent/WebTransportParent.cpp | 8+++-----
Mdom/webtransport/parent/WebTransportParent.h | 1-
Mipc/glue/BackgroundParentImpl.cpp | 8+++-----
Mipc/glue/BackgroundParentImpl.h | 1-
Mipc/glue/PBackground.ipdl | 1-
Mnetwerk/base/LoadInfo.h | 7++-----
Mnetwerk/protocol/webtransport/WebTransportSessionProxy.cpp | 24++++++------------------
Mnetwerk/protocol/webtransport/nsIWebTransport.idl | 2--
19 files changed, 27 insertions(+), 198 deletions(-)

diff --git a/devtools/client/netmonitor/src/connector/index.js b/devtools/client/netmonitor/src/connector/index.js @@ -66,16 +66,6 @@ class Connector { TYPES.SERVER_SENT_EVENT, ]; - get networkResources() { - const networkResources = Array.from(Connector.NETWORK_RESOURCES); - if ( - Services.prefs.getBoolPref("devtools.netmonitor.features.webtransport") - ) { - networkResources.push(TYPES.WEBTRANSPORT); - } - return networkResources; - } - get currentTarget() { return this.commands.targetCommand.targetFront; } @@ -171,7 +161,7 @@ class Connector { if (isExplicitClear) { // Only clear the resources if the clear was initiated explicitly by the // UI, in other cases (eg navigation) the server handles the cleanup. - this.commands.resourceCommand.clearResources(this.networkResources); + this.commands.resourceCommand.clearResources(Connector.NETWORK_RESOURCES); this.emitForTests("clear-network-resources"); } @@ -181,7 +171,7 @@ class Connector { pause() { return this.commands.resourceCommand.unwatchResources( - this.networkResources, + Connector.NETWORK_RESOURCES, { onAvailable: this.onResourceAvailable, onUpdated: this.onResourceUpdated, @@ -190,11 +180,14 @@ class Connector { } resume(ignoreExistingResources = true) { - return this.commands.resourceCommand.watchResources(this.networkResources, { - onAvailable: this.onResourceAvailable, - onUpdated: this.onResourceUpdated, - ignoreExistingResources, - }); + return this.commands.resourceCommand.watchResources( + Connector.NETWORK_RESOURCES, + { + onAvailable: this.onResourceAvailable, + onUpdated: this.onResourceUpdated, + ignoreExistingResources, + } + ); } async onResourceAvailable(resources, { areExistingResources }) { diff --git a/devtools/server/actors/resources/index.js b/devtools/server/actors/resources/index.js @@ -25,7 +25,6 @@ const TYPES = { JSTRACER_TRACE: "jstracer-trace", JSTRACER_STATE: "jstracer-state", WEBSOCKET: "websocket", - WEBTRANSPORT: "webtransport", // storage types CACHE_STORAGE: "Cache", @@ -117,9 +116,6 @@ const FrameTargetResources = augmentResourceDictionary({ [TYPES.WEBSOCKET]: { path: "devtools/server/actors/resources/websockets", }, - [TYPES.WEBTRANSPORT]: { - path: "devtools/server/actors/resources/webtransport", - }, }); // Process target resources are spawned via a Process Target Actor. diff --git a/devtools/server/actors/resources/moz.build b/devtools/server/actors/resources/moz.build @@ -38,7 +38,6 @@ DevToolsModules( "stylesheets.js", "thread-states.js", "websockets.js", - "webtransport.js", ) with Files("*-messages.js"): diff --git a/devtools/server/actors/resources/webtransport.js b/devtools/server/actors/resources/webtransport.js @@ -1,92 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -"use strict"; - -const webTransportEventService = Cc[ - "@mozilla.org/webtransportevent/service;1" -].getService(Ci.nsIWebTransportEventService); - -class WebTransportWatcher { - constructor() { - this.windowIds = new Map(); - this.abortController = new AbortController(); - this.onWindowReady = this.onWindowReady.bind(this); - this.onWindowDestroy = this.onWindowDestroy.bind(this); - } - - static createResource(wtMessageType, eventParams) { - return { - wtMessageType, - ...eventParams, - }; - } - - watch(targetActor, { onAvailable }) { - this.targetActor = targetActor; - this.onAvailable = onAvailable; - - for (const window of this.targetActor.windows) { - const { innerWindowId } = window.windowGlobalChild; - this.startListening(innerWindowId); - } - - // On navigate/reload we should re-start listening with the new `innerWindowID` - if (!this.targetActor.followWindowGlobalLifeCycle) { - this.targetActor.on("window-ready", this.onWindowReady, { - signal: this.abortController.signal, - }); - this.targetActor.on("window-destroyed", this.onWindowDestroy, { - signal: this.abortController.signal, - }); - } - } - - onWindowReady({ window }) { - const { innerWindowId } = window.windowGlobalChild; - this.startListening(innerWindowId); - } - - onWindowDestroy({ id }) { - this.stopListening(id); - } - - startListening(innerWindowId) { - if (!this.windowIds.has(innerWindowId)) { - const listener = { - // methods for the webTransportEventService - webTransportSessionCreated: () => {}, - webTransportSessionClosed: () => {}, - }; - this.windowIds.set(innerWindowId, listener); - webTransportEventService.addListener(innerWindowId, listener); - } - } - - stopListening(innerWindowId) { - if (this.windowIds.has(innerWindowId)) { - if (!webTransportEventService.hasListenerFor(innerWindowId)) { - // The listener might have already been cleaned up on `window-destroy`. - console.warn( - "Already stopped listening to webtransport events for this window." - ); - return; - } - webTransportEventService.removeListener( - innerWindowId, - this.windowIds.get(innerWindowId) - ); - this.windowIds.delete(innerWindowId); - } - } - - destroy() { - this.abortController.abort(); - for (const id of this.windowIds) { - this.stopListening(id); - } - } -} - -module.exports = WebTransportWatcher; diff --git a/devtools/server/actors/watcher/session-context.js b/devtools/server/actors/watcher/session-context.js @@ -201,7 +201,6 @@ function getWatcherSupportedResources(_type) { [Resources.TYPES.THREAD_STATE]: true, [Resources.TYPES.SERVER_SENT_EVENT]: true, [Resources.TYPES.WEBSOCKET]: true, - [Resources.TYPES.WEBTRANSPORT]: true, [Resources.TYPES.JSTRACER_TRACE]: true, [Resources.TYPES.JSTRACER_STATE]: true, [Resources.TYPES.LAST_PRIVATE_CONTEXT_EXIT]: true, diff --git a/devtools/server/tests/chrome/chrome.toml b/devtools/server/tests/chrome/chrome.toml @@ -147,5 +147,3 @@ support-files = [ ["test_unsafeDereference.html"] ["test_webconsole-node-grip.html"] - -["test_webtransport-listeners.html"] diff --git a/devtools/server/tests/chrome/test_webtransport-listeners.html b/devtools/server/tests/chrome/test_webtransport-listeners.html @@ -1,32 +0,0 @@ -<!DOCTYPE HTML> -<html> -<head> - <title>Test the WebTransport watcher </title> - <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> - <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/> -</head> -<body> -<script class="testbody" type="text/javascript"> - 'use strict'; - const { require } = ChromeUtils.importESModule("resource://devtools/shared/loader/Loader.sys.mjs"); - const WebTransportWatcher = require("devtools/server/actors/resources/webtransport.js"); - var service = Cc["@mozilla.org/webtransportevent/service;1"] - .getService(Ci.nsIWebTransportEventService); - ok(!!service, "We have the nsIWebTransportEventService"); - - var innerWindowId = window.windowGlobalChild.innerWindowId; - ok(innerWindowId, "We have a valid innerWindowID: " + innerWindowId); - - const watcher = new WebTransportWatcher(); - - watcher.startListening(innerWindowId); - ok(service.hasListenerFor(innerWindowId), "Service has listener for the window"); - - watcher.stopListening(innerWindowId); - ok(!service.hasListenerFor(innerWindowId), "Service no longer has a listener for the window"); - - // Make sure this does not throw if the listener does not exist. - watcher.stopListening(innerWindowId); -</script> -</body> -</html> diff --git a/devtools/shared/commands/resource/resource-command.js b/devtools/shared/commands/resource/resource-command.js @@ -1287,7 +1287,6 @@ ResourceCommand.TYPES = ResourceCommand.prototype.TYPES = { STYLESHEET: "stylesheet", NETWORK_EVENT: "network-event", WEBSOCKET: "websocket", - WEBTRANSPORT: "webtransport", COOKIE: "cookies", LOCAL_STORAGE: "local-storage", SESSION_STORAGE: "session-storage", diff --git a/devtools/shared/network-observer/NetworkUtils.sys.mjs b/devtools/shared/network-observer/NetworkUtils.sys.mjs @@ -76,7 +76,6 @@ const LOAD_CAUSE_STRINGS = { [Ci.nsIContentPolicy.TYPE_FONT]: "font", [Ci.nsIContentPolicy.TYPE_MEDIA]: "media", [Ci.nsIContentPolicy.TYPE_WEBSOCKET]: "websocket", - [Ci.nsIContentPolicy.TYPE_WEB_TRANSPORT]: "webtransport", [Ci.nsIContentPolicy.TYPE_CSP_REPORT]: "csp", [Ci.nsIContentPolicy.TYPE_XSLT]: "xslt", [Ci.nsIContentPolicy.TYPE_BEACON]: "beacon", diff --git a/dom/webtransport/api/WebTransport.cpp b/dom/webtransport/api/WebTransport.cpp @@ -294,11 +294,6 @@ void WebTransport::Init(const GlobalObject& aGlobal, const nsAString& aURL, if (mGlobal->GetClientInfo().isSome()) { ipcClientInfo = mozilla::Some(mGlobal->GetClientInfo().ref().ToIPC()); } - - nsPIDOMWindowInner* window = mGlobal->GetAsInnerWindow(); - if (window) { - mBrowsingContextID = window->GetBrowsingContext()->Id(); - } // Create a new IPC connection Endpoint<PWebTransportParent> parentEndpoint; Endpoint<PWebTransportChild> childEndpoint; @@ -377,9 +372,9 @@ void WebTransport::Init(const GlobalObject& aGlobal, const nsAString& aURL, mChild = child; backgroundChild ->SendCreateWebTransportParent( - aURL, principal, mBrowsingContextID, ipcClientInfo, dedicated, - requireUnreliable, (uint32_t)congestionControl, - std::move(aServerCertHashes), std::move(parentEndpoint)) + aURL, principal, ipcClientInfo, dedicated, requireUnreliable, + (uint32_t)congestionControl, std::move(aServerCertHashes), + std::move(parentEndpoint)) ->Then(GetCurrentSerialEventTarget(), __func__, [self = RefPtr{this}]( PBackgroundChild::CreateWebTransportParentPromise:: diff --git a/dom/webtransport/api/WebTransport.h b/dom/webtransport/api/WebTransport.h @@ -152,7 +152,6 @@ class WebTransport final : public nsISupports, public nsWrapperCache { RefPtr<Promise> mReady; uint64_t mInnerWindowID = 0; uint64_t mHttpChannelID = 0; - uint64_t mBrowsingContextID = 0; RefPtr<mozilla::net::WebTransportEventService> mService; // XXX may not need to be a RefPtr, since we own it through the Streams RefPtr<WebTransportIncomingStreamsAlgorithms> mIncomingBidirectionalAlgorithm; diff --git a/dom/webtransport/parent/WebTransportParent.cpp b/dom/webtransport/parent/WebTransportParent.cpp @@ -35,7 +35,6 @@ WebTransportParent::~WebTransportParent() { void WebTransportParent::Create( const nsAString& aURL, nsIPrincipal* aPrincipal, - const int64_t& aBrowsingContextID, const mozilla::Maybe<IPCClientInfo>& aClientInfo, const bool& aDedicated, const bool& aRequireUnreliable, const uint32_t& aCongestionControl, nsTArray<WebTransportHash>&& aServerCertHashes, @@ -93,14 +92,13 @@ void WebTransportParent::Create( [self = RefPtr{this}, uri = std::move(uri), dedicated = true /* aDedicated, see BUG 1915735.*/, nsServerCertHashes = std::move(nsServerCertHashes), - principal = RefPtr{aPrincipal}, browsingContextID = aBrowsingContextID, + principal = RefPtr{aPrincipal}, flags = nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_SEC_CONTEXT_IS_NULL, clientInfo = aClientInfo] { LOG(("WebTransport %p AsyncConnect", self.get())); if (NS_FAILED(self->mWebTransport->AsyncConnectWithClient( - uri, dedicated, std::move(nsServerCertHashes), principal, - browsingContextID, flags, self, clientInfo, - nsIWebTransport::HTTPVersion::h3))) { + uri, dedicated, std::move(nsServerCertHashes), principal, flags, + self, clientInfo, nsIWebTransport::HTTPVersion::h3))) { LOG(("AsyncConnect failure; we should get OnSessionClosed")); } }); diff --git a/dom/webtransport/parent/WebTransportParent.h b/dom/webtransport/parent/WebTransportParent.h @@ -34,7 +34,6 @@ class WebTransportParent : public PWebTransportParent, NS_DECL_WEBTRANSPORTSESSIONEVENTLISTENER void Create(const nsAString& aURL, nsIPrincipal* aPrincipal, - const int64_t& aBrowsingContextID, const mozilla::Maybe<IPCClientInfo>& aClientInfo, const bool& aDedicated, const bool& aRequireUnreliable, const uint32_t& aCongestionControl, diff --git a/ipc/glue/BackgroundParentImpl.cpp b/ipc/glue/BackgroundParentImpl.cpp @@ -465,7 +465,6 @@ mozilla::ipc::IPCResult BackgroundParentImpl::RecvCreateFileSystemManagerParent( mozilla::ipc::IPCResult BackgroundParentImpl::RecvCreateWebTransportParent( const nsAString& aURL, nsIPrincipal* aPrincipal, - const uint64_t& aBrowsingContextID, const mozilla::Maybe<IPCClientInfo>& aClientInfo, const bool& aDedicated, const bool& aRequireUnreliable, const uint32_t& aCongestionControl, nsTArray<WebTransportHash>&& aServerCertHashes, @@ -476,10 +475,9 @@ mozilla::ipc::IPCResult BackgroundParentImpl::RecvCreateWebTransportParent( RefPtr<mozilla::dom::WebTransportParent> webt = new mozilla::dom::WebTransportParent(); - webt->Create(aURL, aPrincipal, aBrowsingContextID, aClientInfo, aDedicated, - aRequireUnreliable, aCongestionControl, - std::move(aServerCertHashes), std::move(aParentEndpoint), - std::move(aResolver)); + webt->Create(aURL, aPrincipal, aClientInfo, aDedicated, aRequireUnreliable, + aCongestionControl, std::move(aServerCertHashes), + std::move(aParentEndpoint), std::move(aResolver)); return IPC_OK(); } diff --git a/ipc/glue/BackgroundParentImpl.h b/ipc/glue/BackgroundParentImpl.h @@ -123,7 +123,6 @@ class BackgroundParentImpl : public PBackgroundParent { mozilla::ipc::IPCResult RecvCreateWebTransportParent( const nsAString& aURL, nsIPrincipal* aPrincipal, - const uint64_t& aBrowsingContextID, const mozilla::Maybe<IPCClientInfo>& aClientInfo, const bool& aDedicated, const bool& aRequireUnreliable, const uint32_t& aCongestionControl, nsTArray<WebTransportHash>&& aServerCertHashes, diff --git a/ipc/glue/PBackground.ipdl b/ipc/glue/PBackground.ipdl @@ -179,7 +179,6 @@ parent: async CreateWebTransportParent( nsString aURL, nullable nsIPrincipal aPrincipal, - uint64_t aBrowsingContextID, IPCClientInfo? aClientInfo, bool aDedicated, bool aRequireUnreliable, diff --git a/netwerk/base/LoadInfo.h b/netwerk/base/LoadInfo.h @@ -42,7 +42,6 @@ namespace net { class EarlyHintPreloader; class LoadInfoArgs; class LoadInfo; -class WebTransportSessionProxy; } // namespace net namespace ipc { @@ -458,12 +457,10 @@ class LoadInfo final : public nsILoadInfo { void SetIncludeCookiesSecFlag(); friend class mozilla::dom::XMLHttpRequestMainThread; - // nsDocShell::OpenInitializedChannel, EarlyHintPreloader::OpenChannel and - // WebTransportSessionProxy::AsyncConnectWithClient need to update the - // loadInfo with the correct browsingContext. + // nsDocShell::OpenInitializedChannel and EarlyHintPreloader::OpenChannel + // needs to update the loadInfo with the correct browsingContext. friend class ::nsDocShell; friend class mozilla::net::EarlyHintPreloader; - friend class mozilla::net::WebTransportSessionProxy; void UpdateBrowsingContextID(uint64_t aBrowsingContextID) { mBrowsingContextID = aBrowsingContextID; } diff --git a/netwerk/protocol/webtransport/WebTransportSessionProxy.cpp b/netwerk/protocol/webtransport/WebTransportSessionProxy.cpp @@ -18,12 +18,10 @@ #include "nsIX509Cert.h" #include "nsNetUtil.h" #include "nsProxyRelease.h" -#include "nsILoadInfo.h" #include "nsSocketTransportService2.h" #include "mozilla/Logging.h" #include "mozilla/ScopeExit.h" #include "mozilla/StaticPrefs_network.h" -#include "mozilla/LoadInfo.h" namespace mozilla::net { @@ -70,19 +68,19 @@ WebTransportSessionProxy::~WebTransportSessionProxy() { nsresult WebTransportSessionProxy::AsyncConnect( nsIURI* aURI, bool aDedicated, const nsTArray<RefPtr<nsIWebTransportHash>>& aServerCertHashes, - nsIPrincipal* aPrincipal, int64_t aBrowsingContextID, - uint32_t aSecurityFlags, WebTransportSessionEventListener* aListener, + nsIPrincipal* aPrincipal, uint32_t aSecurityFlags, + WebTransportSessionEventListener* aListener, nsIWebTransport::HTTPVersion aVersion) { return AsyncConnectWithClient(aURI, aDedicated, std::move(aServerCertHashes), - aPrincipal, aBrowsingContextID, aSecurityFlags, - aListener, Maybe<dom::ClientInfo>(), aVersion); + aPrincipal, aSecurityFlags, aListener, + Maybe<dom::ClientInfo>(), aVersion); } nsresult WebTransportSessionProxy::AsyncConnectWithClient( nsIURI* aURI, bool aDedicated, const nsTArray<RefPtr<nsIWebTransportHash>>& aServerCertHashes, - nsIPrincipal* aPrincipal, int64_t aBrowsingContextID, - uint32_t aSecurityFlags, WebTransportSessionEventListener* aListener, + nsIPrincipal* aPrincipal, uint32_t aSecurityFlags, + WebTransportSessionEventListener* aListener, const Maybe<dom::ClientInfo>& aClientInfo, nsIWebTransport::HTTPVersion aVersion) { MOZ_ASSERT(NS_IsMainThread()); @@ -187,16 +185,6 @@ nsresult WebTransportSessionProxy::AsyncConnectWithClient( mHttpChannelID = httpChannel->ChannelId(); - // Setting the BrowsingContextID here to let WebTransport requests show up in - // devtools. Normally that would automatically happen if we would pass the - // nsILoadGroup in ns_NewChannel above, but the nsILoadGroup is inaccessible - // here in the ParentProcess. The nsILoadGroup only exists in ContentProcess - // as part of the document and nsDocShell. It is also not yet determined which - // ContentProcess this load belongs to. - nsCOMPtr<nsILoadInfo> loadInfo = mChannel->LoadInfo(); - static_cast<LoadInfo*>(loadInfo.get()) - ->UpdateBrowsingContextID(aBrowsingContextID); - return rv; } diff --git a/netwerk/protocol/webtransport/nsIWebTransport.idl b/netwerk/protocol/webtransport/nsIWebTransport.idl @@ -46,7 +46,6 @@ interface nsIWebTransport : nsISupports { in boolean aDedicated, in Array<nsIWebTransportHash> aServerCertHashes, in nsIPrincipal aLoadingPrincipal, - in int64_t aBrowsingContextID, in unsigned long aSecurityFlags, in WebTransportSessionEventListener aListener, [optional] in nsIWebTransport_HTTPVersion aVersion); @@ -56,7 +55,6 @@ interface nsIWebTransport : nsISupports { in boolean aDedicated, in Array<nsIWebTransportHash> aServerCertHashes, in nsIPrincipal aLoadingPrincipal, - in int64_t aBrowsingContextID, in unsigned long aSecurityFlags, in WebTransportSessionEventListener aListener, in const_MaybeClientInfoRef aClientInfo,