Bug 1680771: Use a real LoadInfo for WebrtcTCPSocket, ensure we use that LoadInfo's CookieJarSettings for our DNS/proxy lookup, and remove a flag that was breaking http proxy support for webrtc. r=timhuang,mjf

Differential Revision: https://phabricator.services.mozilla.com/D99362
This commit is contained in:
Byron Campen [:bwc] 2021-01-05 12:59:41 +00:00
parent d9b7eb8e14
commit 0c10fa6898
3 changed files with 19 additions and 5 deletions

View File

@ -870,10 +870,16 @@ std::unique_ptr<NrSocketProxyConfig> PeerConnectionMedia::GetProxyConfig()
return nullptr;
}
Document* doc = mParent->GetWindow()->GetExtantDoc();
if (NS_WARN_IF(!doc)) {
NS_WARNING("Unable to get document from window");
return nullptr;
}
TabId id = browserChild->GetTabId();
nsCOMPtr<nsILoadInfo> loadInfo =
new net::LoadInfo(nsContentUtils::GetSystemPrincipal(), nullptr, nullptr,
0, nsIContentPolicy::TYPE_INVALID);
new net::LoadInfo(doc->NodePrincipal(), doc->NodePrincipal(), doc, 0,
nsIContentPolicy::TYPE_INVALID);
Maybe<net::LoadInfoArgs> loadInfoArgs;
MOZ_ALWAYS_SUCCEEDS(

View File

@ -14,6 +14,7 @@
#include "nsILoadInfo.h"
#include "nsIProtocolProxyService.h"
#include "nsIURIMutator.h"
#include "nsICookieJarSettings.h"
#include "nsProxyRelease.h"
#include "nsString.h"
#include "mozilla/dom/ContentProcessManager.h"
@ -386,7 +387,7 @@ nsresult WebrtcTCPSocket::OpenWithHttpProxy() {
// Proxy flags are overridden by SetConnectOnly()
0, loadInfo->LoadingNode(), loadInfo->GetLoadingPrincipal(),
loadInfo->TriggeringPrincipal(),
nsILoadInfo::SEC_DONT_FOLLOW_REDIRECTS | nsILoadInfo::SEC_COOKIES_OMIT |
nsILoadInfo::SEC_COOKIES_OMIT |
// We need this flag to allow loads from any origin since this channel
// is being used to CONNECT to an HTTP proxy.
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_SEC_CONTEXT_IS_NULL,
@ -396,6 +397,11 @@ nsresult WebrtcTCPSocket::OpenWithHttpProxy() {
return rv;
}
nsCOMPtr<nsILoadInfo> channelLoadInfo = localChannel->LoadInfo();
nsCOMPtr<nsICookieJarSettings> cookieJarSettings;
loadInfo->GetCookieJarSettings(getter_AddRefs(cookieJarSettings));
channelLoadInfo->SetCookieJarSettings(cookieJarSettings);
RefPtr<nsHttpChannel> httpChannel;
CallQueryInterface(localChannel, httpChannel.StartAssignment());

View File

@ -271,7 +271,7 @@ int nr_ice_peer_peer_rflx_candidate_create(nr_ice_ctx *ctx,char *label, nr_ice_c
static void nr_ice_candidate_mark_done(nr_ice_candidate *cand, int state)
{
if (!cand || !cand->done_cb) {
if (!cand) {
assert(0);
return;
}
@ -294,7 +294,9 @@ static void nr_ice_candidate_mark_done(nr_ice_candidate *cand, int state)
cand->done_cb=0;
cand->state=state;
/* This might destroy cand! */
done_cb(0,0,cand->cb_arg);
if (done_cb) {
done_cb(0,0,cand->cb_arg);
}
}
int nr_ice_candidate_destroy(nr_ice_candidate **candp)