Merge mozilla-central to autoland.

This commit is contained in:
Cosmin Sabou 2019-02-21 05:43:34 +02:00
commit 9f8b29287b
145 changed files with 686 additions and 1063 deletions

View File

@ -63,13 +63,10 @@ COMPILE_FLAGS['OS_CXXFLAGS'] = (
)
COMPILE_FLAGS['OS_CFLAGS'] = (
[f for f in COMPILE_FLAGS.get('OS_CFLAGS', []) if not f.startswith('-W')] +
['-fsyntax-only', '-Xclang', '-verify', '-ferror-limit=0', '-std=c11',
['-fsyntax-only', '-Xclang', '-verify', '-ferror-limit=0', '-Xclang', '-std=c11',
'-Wno-invalid-noreturn']
)
# Don't reflect WARNINGS_CFLAGS into CFLAGS, as the warnings flags should be
# as specified in OS_CFLAGS above.
DisableCompilerWarnings()
if CONFIG['ENABLE_CLANG_PLUGIN'] and CONFIG['CC_TYPE'] == 'clang-cl':
AllowCompilerWarnings() # workaround for bug 1090497

View File

@ -253,9 +253,9 @@ static void InheritAndSetCSPOnPrincipalIfNeeded(nsIChannel* aChannel,
return;
}
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
if (!loadInfo || loadInfo->GetExternalContentPolicyType() !=
nsIContentPolicy::TYPE_SUBDOCUMENT) {
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
if (loadInfo->GetExternalContentPolicyType() !=
nsIContentPolicy::TYPE_SUBDOCUMENT) {
return;
}
@ -302,8 +302,8 @@ nsresult nsScriptSecurityManager::GetChannelResultPrincipal(
MOZ_ASSERT(aChannel, "Must have channel!");
// Check whether we have an nsILoadInfo that says what we should do.
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
if (loadInfo && loadInfo->GetForceInheritPrincipalOverruleOwner()) {
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
if (loadInfo->GetForceInheritPrincipalOverruleOwner()) {
nsCOMPtr<nsIPrincipal> principalToInherit =
loadInfo->FindPrincipalToInherit(aChannel);
principalToInherit.forget(aPrincipal);
@ -319,53 +319,51 @@ nsresult nsScriptSecurityManager::GetChannelResultPrincipal(
}
}
if (loadInfo) {
if (!aIgnoreSandboxing && loadInfo->GetLoadingSandboxed()) {
nsCOMPtr<nsIPrincipal> sandboxedLoadingPrincipal =
loadInfo->GetSandboxedLoadingPrincipal();
MOZ_ASSERT(sandboxedLoadingPrincipal);
InheritAndSetCSPOnPrincipalIfNeeded(aChannel, sandboxedLoadingPrincipal);
sandboxedLoadingPrincipal.forget(aPrincipal);
return NS_OK;
}
if (!aIgnoreSandboxing && loadInfo->GetLoadingSandboxed()) {
nsCOMPtr<nsIPrincipal> sandboxedLoadingPrincipal =
loadInfo->GetSandboxedLoadingPrincipal();
MOZ_ASSERT(sandboxedLoadingPrincipal);
InheritAndSetCSPOnPrincipalIfNeeded(aChannel, sandboxedLoadingPrincipal);
sandboxedLoadingPrincipal.forget(aPrincipal);
return NS_OK;
}
bool forceInherit = loadInfo->GetForceInheritPrincipal();
if (aIgnoreSandboxing && !forceInherit) {
// Check if SEC_FORCE_INHERIT_PRINCIPAL was dropped because of
// sandboxing:
if (loadInfo->GetLoadingSandboxed() &&
loadInfo->GetForceInheritPrincipalDropped()) {
forceInherit = true;
}
bool forceInherit = loadInfo->GetForceInheritPrincipal();
if (aIgnoreSandboxing && !forceInherit) {
// Check if SEC_FORCE_INHERIT_PRINCIPAL was dropped because of
// sandboxing:
if (loadInfo->GetLoadingSandboxed() &&
loadInfo->GetForceInheritPrincipalDropped()) {
forceInherit = true;
}
if (forceInherit) {
nsCOMPtr<nsIPrincipal> principalToInherit =
loadInfo->FindPrincipalToInherit(aChannel);
}
if (forceInherit) {
nsCOMPtr<nsIPrincipal> principalToInherit =
loadInfo->FindPrincipalToInherit(aChannel);
principalToInherit.forget(aPrincipal);
return NS_OK;
}
auto securityMode = loadInfo->GetSecurityMode();
// The data: inheritance flags should only apply to the initial load,
// not to loads that it might have redirected to.
if (loadInfo->RedirectChain().IsEmpty() &&
(securityMode == nsILoadInfo::SEC_REQUIRE_SAME_ORIGIN_DATA_INHERITS ||
securityMode == nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_INHERITS ||
securityMode == nsILoadInfo::SEC_REQUIRE_CORS_DATA_INHERITS)) {
nsCOMPtr<nsIURI> uri;
nsresult rv = NS_GetFinalChannelURI(aChannel, getter_AddRefs(uri));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIPrincipal> principalToInherit =
loadInfo->FindPrincipalToInherit(aChannel);
bool inheritForAboutBlank = loadInfo->GetAboutBlankInherits();
if (nsContentUtils::ChannelShouldInheritPrincipal(
principalToInherit, uri, inheritForAboutBlank, false)) {
principalToInherit.forget(aPrincipal);
return NS_OK;
}
auto securityMode = loadInfo->GetSecurityMode();
// The data: inheritance flags should only apply to the initial load,
// not to loads that it might have redirected to.
if (loadInfo->RedirectChain().IsEmpty() &&
(securityMode == nsILoadInfo::SEC_REQUIRE_SAME_ORIGIN_DATA_INHERITS ||
securityMode == nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_INHERITS ||
securityMode == nsILoadInfo::SEC_REQUIRE_CORS_DATA_INHERITS)) {
nsCOMPtr<nsIURI> uri;
nsresult rv = NS_GetFinalChannelURI(aChannel, getter_AddRefs(uri));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIPrincipal> principalToInherit =
loadInfo->FindPrincipalToInherit(aChannel);
bool inheritForAboutBlank = loadInfo->GetAboutBlankInherits();
if (nsContentUtils::ChannelShouldInheritPrincipal(
principalToInherit, uri, inheritForAboutBlank, false)) {
principalToInherit.forget(aPrincipal);
return NS_OK;
}
}
}
nsresult rv = GetChannelURIPrincipal(aChannel, aPrincipal);
NS_ENSURE_SUCCESS(rv, rv);
@ -395,20 +393,14 @@ nsScriptSecurityManager::GetChannelURIPrincipal(nsIChannel* aChannel,
nsresult rv = NS_GetFinalChannelURI(aChannel, getter_AddRefs(uri));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsILoadInfo> loadInfo;
aChannel->GetLoadInfo(getter_AddRefs(loadInfo));
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
// Inherit the origin attributes from loadInfo.
// If this is a top-level document load, the origin attributes of the
// loadInfo will be set from nsDocShell::DoURILoad.
// For subresource loading, the origin attributes of the loadInfo is from
// its loadingPrincipal.
OriginAttributes attrs;
// For addons loadInfo might be null.
if (loadInfo) {
attrs = loadInfo->GetOriginAttributes();
}
OriginAttributes attrs = loadInfo->GetOriginAttributes();
nsCOMPtr<nsIPrincipal> prin =
BasePrincipal::CreateCodebasePrincipal(uri, attrs);

View File

@ -92,8 +92,8 @@ nsChromeProtocolHandler::NewURI(const nsACString &aSpec, const char *aCharset,
}
NS_IMETHODIMP
nsChromeProtocolHandler::NewChannel2(nsIURI *aURI, nsILoadInfo *aLoadInfo,
nsIChannel **aResult) {
nsChromeProtocolHandler::NewChannel(nsIURI *aURI, nsILoadInfo *aLoadInfo,
nsIChannel **aResult) {
nsresult rv;
NS_ENSURE_ARG_POINTER(aURI);
@ -191,9 +191,4 @@ nsChromeProtocolHandler::NewChannel2(nsIURI *aURI, nsILoadInfo *aLoadInfo,
return NS_OK;
}
NS_IMETHODIMP
nsChromeProtocolHandler::NewChannel(nsIURI *aURI, nsIChannel **aResult) {
return NewChannel2(aURI, nullptr, aResult);
}
////////////////////////////////////////////////////////////////////////////////

View File

@ -30,7 +30,6 @@ ProtocolHandler.prototype =
}
return mutator.finalize();
},
newChannel2() { throw Cr.NS_ERROR_NOT_IMPLEMENTED; },
newChannel() { throw Cr.NS_ERROR_NOT_IMPLEMENTED; },
QueryInterface: ChromeUtils.generateQI([
Ci.nsIProtocolHandler,

View File

@ -4576,10 +4576,8 @@ nsDocShell::Reload(uint32_t aReloadFlags) {
httpChan->GetOriginalURI(getter_AddRefs(originalURI));
}
nsCOMPtr<nsILoadInfo> loadInfo = chan->GetLoadInfo();
if (loadInfo) {
loadInfo->GetResultPrincipalURI(getter_AddRefs(resultPrincipalURI));
}
nsCOMPtr<nsILoadInfo> loadInfo = chan->LoadInfo();
loadInfo->GetResultPrincipalURI(getter_AddRefs(resultPrincipalURI));
}
MOZ_ASSERT(triggeringPrincipal, "Need a valid triggeringPrincipal");
@ -6850,7 +6848,7 @@ nsresult nsDocShell::EndPageLoad(nsIWebProgress* aProgress,
// can increment counts from the search engine
MaybeNotifyKeywordSearchLoading(keywordProviderName, keywordAsSent);
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
MOZ_ASSERT(loadInfo, "loadInfo is required on all channels");
nsCOMPtr<nsIPrincipal> triggeringPrincipal =
loadInfo->TriggeringPrincipal();
@ -6902,10 +6900,8 @@ nsresult nsDocShell::EndPageLoad(nsIWebProgress* aProgress,
}
} else if (url && NS_SUCCEEDED(aStatus)) {
// If we have a host
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
if (loadInfo) {
PredictorLearnRedirect(url, aChannel, loadInfo->GetOriginAttributes());
}
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
PredictorLearnRedirect(url, aChannel, loadInfo->GetOriginAttributes());
}
return NS_OK;
@ -9829,8 +9825,7 @@ nsresult nsDocShell::DoURILoad(nsDocShellLoadState* aLoadState,
GetIsMozBrowser());
if (isTopLevelDoc && GetDocument() && GetDocument()->GetChannel()) {
nsCOMPtr<nsILoadInfo> oldLoadInfo =
GetDocument()->GetChannel()->GetLoadInfo();
nsCOMPtr<nsILoadInfo> oldLoadInfo = GetDocument()->GetChannel()->LoadInfo();
loadInfo->SetOpenerPolicy(oldLoadInfo->GetOpenerPolicy());
}
@ -11293,29 +11288,27 @@ nsresult nsDocShell::AddToSessionHistory(nsIURI* aURI, nsIChannel* aChannel,
discardLayoutState = ShouldDiscardLayoutState(httpChannel);
}
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
if (loadInfo) {
if (!triggeringPrincipal) {
triggeringPrincipal = loadInfo->TriggeringPrincipal();
}
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
if (!triggeringPrincipal) {
triggeringPrincipal = loadInfo->TriggeringPrincipal();
}
loadInfo->GetResultPrincipalURI(getter_AddRefs(resultPrincipalURI));
loadInfo->GetResultPrincipalURI(getter_AddRefs(resultPrincipalURI));
// For now keep storing just the principal in the SHEntry.
if (!principalToInherit) {
if (loadInfo->GetLoadingSandboxed()) {
if (loadInfo->LoadingPrincipal()) {
principalToInherit = NullPrincipal::CreateWithInheritedAttributes(
loadInfo->LoadingPrincipal());
} else {
// get the OriginAttributes
OriginAttributes attrs;
loadInfo->GetOriginAttributes(&attrs);
principalToInherit = NullPrincipal::Create(attrs);
}
// For now keep storing just the principal in the SHEntry.
if (!principalToInherit) {
if (loadInfo->GetLoadingSandboxed()) {
if (loadInfo->LoadingPrincipal()) {
principalToInherit = NullPrincipal::CreateWithInheritedAttributes(
loadInfo->LoadingPrincipal());
} else {
principalToInherit = loadInfo->PrincipalToInherit();
// get the OriginAttributes
OriginAttributes attrs;
loadInfo->GetOriginAttributes(&attrs);
principalToInherit = NullPrincipal::Create(attrs);
}
} else {
principalToInherit = loadInfo->PrincipalToInherit();
}
}
}

View File

@ -93,10 +93,7 @@ nsresult nsDocShellLoadState::CreateFromPendingChannel(
}
loadState->SetOriginalURI(originalUri);
nsCOMPtr<nsILoadInfo> loadInfo = channel->GetLoadInfo();
if (NS_WARN_IF(!loadInfo)) {
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsILoadInfo> loadInfo = channel->LoadInfo();
loadState->SetTriggeringPrincipal(loadInfo->TriggeringPrincipal());
// Return the newly created loadState.

View File

@ -2419,7 +2419,7 @@ static void WarnIfSandboxIneffective(nsIDocShell* aDocShell,
}
bool Document::IsSynthesized() {
nsCOMPtr<nsILoadInfo> loadInfo = mChannel ? mChannel->GetLoadInfo() : nullptr;
nsCOMPtr<nsILoadInfo> loadInfo = mChannel ? mChannel->LoadInfo() : nullptr;
return loadInfo && loadInfo->GetServiceWorkerTaintingSynthesized();
}
@ -2519,8 +2519,8 @@ nsresult Document::StartDocumentLoad(const char* aCommand, nsIChannel* aChannel,
nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(aContainer);
// If this is an error page, don't inherit sandbox flags from docshell
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
if (docShell && !(loadInfo && loadInfo->GetLoadErrorPage())) {
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
if (docShell && !loadInfo->GetLoadErrorPage()) {
nsresult rv = docShell->GetSandboxFlags(&mSandboxFlags);
NS_ENSURE_SUCCESS(rv, rv);
WarnIfSandboxIneffective(docShell, mSandboxFlags, GetChannel());
@ -2667,8 +2667,8 @@ nsresult Document::InitCSP(nsIChannel* aChannel) {
// Check if this is a signed content to apply default CSP.
bool applySignedContentCSP = false;
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
if (loadInfo && loadInfo->GetVerifySignedContent()) {
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
if (loadInfo->GetVerifySignedContent()) {
applySignedContentCSP = true;
}
@ -7423,13 +7423,10 @@ bool Document::CanSavePresentation(nsIRequest* aNewRequest) {
// Favicon loads don't need to block caching.
nsCOMPtr<nsIChannel> channel = do_QueryInterface(request);
if (channel) {
nsCOMPtr<nsILoadInfo> li;
channel->GetLoadInfo(getter_AddRefs(li));
if (li) {
if (li->InternalContentPolicyType() ==
nsIContentPolicy::TYPE_INTERNAL_IMAGE_FAVICON) {
continue;
}
nsCOMPtr<nsILoadInfo> li = channel->LoadInfo();
if (li->InternalContentPolicyType() ==
nsIContentPolicy::TYPE_INTERNAL_IMAGE_FAVICON) {
continue;
}
}
#ifdef DEBUG_PAGE_CACHE
@ -11721,8 +11718,8 @@ void Document::SetUserHasInteracted() {
mUserHasInteracted = true;
nsCOMPtr<nsILoadInfo> loadInfo = mChannel ? mChannel->GetLoadInfo() : nullptr;
if (loadInfo) {
if (mChannel) {
nsCOMPtr<nsILoadInfo> loadInfo = mChannel->LoadInfo();
loadInfo->SetDocumentHasUserInteracted(true);
}

View File

@ -240,7 +240,7 @@ ThirdPartyUtil::IsThirdPartyChannel(nsIChannel* aChannel, nsIURI* aURI,
if (NS_FAILED(rv)) return rv;
if (!doForce) {
if (nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo()) {
if (nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo()) {
parentIsThird = loadInfo->GetIsInThirdPartyContext();
if (!parentIsThird && loadInfo->GetExternalContentPolicyType() !=
nsIContentPolicy::TYPE_DOCUMENT) {

View File

@ -8122,10 +8122,7 @@ bool nsContentUtils::IsNonSubresourceRequest(nsIChannel* aChannel) {
return true;
}
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
if (!loadInfo) {
return false;
}
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
nsContentPolicyType type = loadInfo->InternalContentPolicyType();
return IsNonSubresourceInternalPolicyType(type);
}
@ -9810,10 +9807,7 @@ nsContentUtils::LookupCustomElementDefinition(Document* aDoc, nsAtom* aNameAtom,
rv = aChannel->GetReferrer(getter_AddRefs(referrer));
NS_ENSURE_SUCCESS(rv, false);
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
if (!loadInfo) {
return false;
}
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
nsCOMPtr<nsIPrincipal> triggeringPrincipal = loadInfo->TriggeringPrincipal();
// Get the channel's load flags, and use them to generate nsIWebNavigation

View File

@ -1718,7 +1718,7 @@ nsresult nsGlobalWindowInner::EnsureClientSource() {
}
if (!ignoreLoadInfo) {
loadInfo = channel->GetLoadInfo();
loadInfo = channel->LoadInfo();
}
}

View File

@ -5516,11 +5516,10 @@ void nsGlobalWindowOuter::NotifyContentBlockingEvent(unsigned aEvent,
// static
bool nsGlobalWindowOuter::SameLoadingURI(Document* aDoc, nsIChannel* aChannel) {
nsCOMPtr<nsIURI> docURI = aDoc->GetDocumentURI();
nsCOMPtr<nsILoadInfo> channelLoadInfo = aChannel->GetLoadInfo();
if (!channelLoadInfo || !docURI) {
if (!docURI) {
return false;
}
nsCOMPtr<nsILoadInfo> channelLoadInfo = aChannel->LoadInfo();
nsCOMPtr<nsIPrincipal> channelLoadingPrincipal =
channelLoadInfo->LoadingPrincipal();
if (!channelLoadingPrincipal) {

View File

@ -331,7 +331,7 @@ bool nsNodeInfoManager::InternalSVGEnabled() {
nsCOMPtr<nsIChannel> channel = mDocument->GetChannel();
// We don't have a channel for SVGs constructed inside a SVG script
if (channel) {
loadInfo = channel->GetLoadInfo();
loadInfo = channel->LoadInfo();
}
}
bool conclusion =

View File

@ -2412,8 +2412,7 @@ nsresult nsObjectLoadingContent::OpenChannel() {
nsIRequest::LOAD_HTML_OBJECT_DATA);
NS_ENSURE_SUCCESS(rv, rv);
if (inherit) {
nsCOMPtr<nsILoadInfo> loadinfo = chan->GetLoadInfo();
NS_ENSURE_STATE(loadinfo);
nsCOMPtr<nsILoadInfo> loadinfo = chan->LoadInfo();
loadinfo->SetPrincipalToInherit(thisContent->NodePrincipal());
}

View File

@ -135,14 +135,12 @@ nsresult nsSyncLoader::LoadDocument(nsIChannel *aChannel, bool aChannelIsSync,
"text/xml,application/xml,application/xhtml+xml,*/*;q=0.1"),
false);
MOZ_ASSERT(NS_SUCCEEDED(rv));
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
if (loadInfo) {
nsCOMPtr<nsIURI> loaderUri;
loadInfo->TriggeringPrincipal()->GetURI(getter_AddRefs(loaderUri));
if (loaderUri) {
rv = http->SetReferrerWithPolicy(loaderUri, aReferrerPolicy);
MOZ_ASSERT(NS_SUCCEEDED(rv));
}
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
nsCOMPtr<nsIURI> loaderUri;
loadInfo->TriggeringPrincipal()->GetURI(getter_AddRefs(loaderUri));
if (loaderUri) {
rv = http->SetReferrerWithPolicy(loaderUri, aReferrerPolicy);
MOZ_ASSERT(NS_SUCCEEDED(rv));
}
}

View File

@ -114,12 +114,9 @@ CustomProtocol.prototype = {
.setSpec(spec)
.finalize();
},
newChannel2: function newChannel2(URI, loadInfo) {
newChannel: function newChannel2(URI, loadInfo) {
return new CustomChannel(URI, loadInfo);
},
newChannel: function newChannel(URI) {
return this.newChannel2(URI);
},
QueryInterface: ChromeUtils.generateQI([Ci.nsISupportsWeakReference, Ci.nsIProtocolHandler]),
};

View File

@ -55,19 +55,14 @@ class ClientChannelHelper final : public nsIInterfaceRequestor,
nsIAsyncVerifyRedirectCallback* aCallback) override {
MOZ_ASSERT(NS_IsMainThread());
nsCOMPtr<nsILoadInfo> oldLoadInfo;
nsresult rv = aOldChannel->GetLoadInfo(getter_AddRefs(oldLoadInfo));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsILoadInfo> newLoadInfo;
rv = aNewChannel->GetLoadInfo(getter_AddRefs(newLoadInfo));
NS_ENSURE_SUCCESS(rv, rv);
rv = nsContentUtils::CheckSameOrigin(aOldChannel, aNewChannel);
nsresult rv = nsContentUtils::CheckSameOrigin(aOldChannel, aNewChannel);
if (NS_WARN_IF(NS_FAILED(rv) && rv != NS_ERROR_DOM_BAD_URI)) {
return rv;
}
nsCOMPtr<nsILoadInfo> oldLoadInfo = aOldChannel->LoadInfo();
nsCOMPtr<nsILoadInfo> newLoadInfo = aNewChannel->LoadInfo();
UniquePtr<ClientSource> reservedClient =
oldLoadInfo->TakeReservedClientSource();
@ -181,8 +176,7 @@ nsresult AddClientChannelHelper(nsIChannel* aChannel,
MOZ_DIAGNOSTIC_ASSERT(reservedClientInfo.isNothing() ||
initialClientInfo.isNothing());
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
NS_ENSURE_TRUE(loadInfo, NS_ERROR_FAILURE);
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager();
NS_ENSURE_TRUE(ssm, NS_ERROR_FAILURE);

View File

@ -532,11 +532,7 @@ nsresult FetchDriver::HttpFetch(
NS_ENSURE_SUCCESS(rv, rv);
if (mCSPEventListener) {
nsCOMPtr<nsILoadInfo> loadInfo = chan->GetLoadInfo();
if (NS_WARN_IF(!loadInfo)) {
return NS_ERROR_UNEXPECTED;
}
nsCOMPtr<nsILoadInfo> loadInfo = chan->LoadInfo();
rv = loadInfo->SetCspEventListener(mCSPEventListener);
NS_ENSURE_SUCCESS(rv, rv);
}
@ -589,7 +585,7 @@ nsresult FetchDriver::HttpFetch(
// If requests referrer policy is the empty string,
// then set requests referrer policy to the user-set default policy.
if (mRequest->ReferrerPolicy_() == ReferrerPolicy::_empty) {
nsCOMPtr<nsILoadInfo> loadInfo = httpChan->GetLoadInfo();
nsCOMPtr<nsILoadInfo> loadInfo = httpChan->LoadInfo();
bool isPrivate = loadInfo->GetOriginAttributes().mPrivateBrowsingId > 0;
net::ReferrerPolicy referrerPolicy = static_cast<net::ReferrerPolicy>(
NS_GetDefaultReferrerPolicy(isPrivate));
@ -674,10 +670,8 @@ nsresult FetchDriver::HttpFetch(
if (mRequest->Mode() == RequestMode::Cors) {
AutoTArray<nsCString, 5> unsafeHeaders;
mRequest->Headers()->GetUnsafeHeaders(unsafeHeaders);
nsCOMPtr<nsILoadInfo> loadInfo = chan->GetLoadInfo();
if (loadInfo) {
loadInfo->SetCorsPreflightInfo(unsafeHeaders, false);
}
nsCOMPtr<nsILoadInfo> loadInfo = chan->LoadInfo();
loadInfo->SetCorsPreflightInfo(unsafeHeaders, false);
}
if (mIsTrackingFetch && nsContentUtils::IsTailingEnabled() && cos) {
@ -1020,13 +1014,7 @@ FetchDriver::OnStartRequest(nsIRequest* aRequest, nsISupports* aContext) {
return rv;
}
nsCOMPtr<nsILoadInfo> loadInfo;
rv = channel->GetLoadInfo(getter_AddRefs(loadInfo));
if (NS_WARN_IF(NS_FAILED(rv))) {
FailWithNetworkError(rv);
return rv;
}
nsCOMPtr<nsILoadInfo> loadInfo = channel->LoadInfo();
// Propagate any tainting from the channel back to our response here. This
// step is not reflected in the spec because the spec is written such that
// FetchEvent.respondWith() just passes the already-tainted Response back to

View File

@ -765,8 +765,8 @@ BlobURLProtocolHandler::NewURI(const nsACString& aSpec, const char* aCharset,
}
NS_IMETHODIMP
BlobURLProtocolHandler::NewChannel2(nsIURI* aURI, nsILoadInfo* aLoadInfo,
nsIChannel** aResult) {
BlobURLProtocolHandler::NewChannel(nsIURI* aURI, nsILoadInfo* aLoadInfo,
nsIChannel** aResult) {
RefPtr<BlobURLChannel> channel = new BlobURLChannel(aURI, aLoadInfo);
auto raii = MakeScopeExit([&] {
@ -814,11 +814,6 @@ BlobURLProtocolHandler::NewChannel2(nsIURI* aURI, nsILoadInfo* aLoadInfo,
return NS_OK;
}
NS_IMETHODIMP
BlobURLProtocolHandler::NewChannel(nsIURI* uri, nsIChannel** result) {
return NewChannel2(uri, nullptr, result);
}
NS_IMETHODIMP
BlobURLProtocolHandler::AllowPort(int32_t port, const char* scheme,
bool* _retval) {

View File

@ -58,13 +58,8 @@ FontTableURIProtocolHandler::GetFlagsForURI(nsIURI *aURI, uint32_t *aResult) {
}
NS_IMETHODIMP
FontTableURIProtocolHandler::NewChannel2(nsIURI *uri, nsILoadInfo *aLoadInfo,
nsIChannel **result) {
return NS_ERROR_DOM_BAD_URI;
}
NS_IMETHODIMP
FontTableURIProtocolHandler::NewChannel(nsIURI *uri, nsIChannel **result) {
FontTableURIProtocolHandler::NewChannel(nsIURI *uri, nsILoadInfo *aLoadInfo,
nsIChannel **result) {
return NS_ERROR_DOM_BAD_URI;
}

View File

@ -1293,12 +1293,10 @@ class HTMLMediaElement::ChannelLoader final {
}
if (setAttrs) {
nsCOMPtr<nsILoadInfo> loadInfo = channel->GetLoadInfo();
if (loadInfo) {
// The function simply returns NS_OK, so we ignore the return value.
Unused << loadInfo->SetOriginAttributes(
triggeringPrincipal->OriginAttributesRef());
}
nsCOMPtr<nsILoadInfo> loadInfo = channel->LoadInfo();
// The function simply returns NS_OK, so we ignore the return value.
Unused << loadInfo->SetOriginAttributes(
triggeringPrincipal->OriginAttributesRef());
}
nsCOMPtr<nsIClassOfService> cos(do_QueryInterface(channel));

View File

@ -87,7 +87,7 @@ ImageListener::OnStartRequest(nsIRequest* request, nsISupports* ctxt) {
nsAutoCString mimeType;
channel->GetContentType(mimeType);
nsCOMPtr<nsILoadInfo> loadInfo = channel->GetLoadInfo();
nsCOMPtr<nsILoadInfo> loadInfo = channel->LoadInfo();
// query the corresponding arguments for the channel loadinfo and pass
// it on to the temporary loadinfo used for content policy checks.
nsCOMPtr<nsINode> requestingNode = domWindow->GetFrameElementInternal();
@ -100,8 +100,8 @@ ImageListener::OnStartRequest(nsIRequest* request, nsISupports* ctxt) {
}
nsCOMPtr<nsILoadInfo> secCheckLoadInfo = new net::LoadInfo(
loadingPrincipal, loadInfo ? loadInfo->TriggeringPrincipal() : nullptr,
requestingNode, nsILoadInfo::SEC_ONLY_FOR_EXPLICIT_CONTENTSEC_CHECK,
loadingPrincipal, loadInfo->TriggeringPrincipal(), requestingNode,
nsILoadInfo::SEC_ONLY_FOR_EXPLICIT_CONTENTSEC_CHECK,
nsIContentPolicy::TYPE_INTERNAL_IMAGE);
int16_t decision = nsIContentPolicy::ACCEPT;

View File

@ -1923,8 +1923,7 @@ nsresult nsHTMLDocument::CreateAndAddWyciwygChannel(void) {
nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL,
nsIContentPolicy::TYPE_OTHER);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsILoadInfo> loadInfo = channel->GetLoadInfo();
NS_ENSURE_STATE(loadInfo);
nsCOMPtr<nsILoadInfo> loadInfo = channel->LoadInfo();
loadInfo->SetPrincipalToInherit(NodePrincipal());
mWyciwygChannel = do_QueryInterface(channel);

View File

@ -144,9 +144,8 @@ nsresult nsJSThunk::EvaluateScript(
aChannel->GetOwner(getter_AddRefs(owner));
nsCOMPtr<nsIPrincipal> principal = do_QueryInterface(owner);
if (!principal) {
nsCOMPtr<nsILoadInfo> loadInfo;
aChannel->GetLoadInfo(getter_AddRefs(loadInfo));
if (loadInfo && loadInfo->GetForceInheritPrincipal()) {
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
if (loadInfo->GetForceInheritPrincipal()) {
principal = loadInfo->FindPrincipalToInherit(aChannel);
} else {
// No execution without a principal!
@ -509,7 +508,7 @@ nsJSChannel::AsyncOpen(nsIStreamListener* aListener) {
#ifdef DEBUG
{
nsCOMPtr<nsILoadInfo> loadInfo = nsIChannel::GetLoadInfo();
nsCOMPtr<nsILoadInfo> loadInfo = nsIChannel::LoadInfo();
MOZ_ASSERT(!loadInfo || loadInfo->GetSecurityMode() == 0 ||
loadInfo->GetInitialSecurityCheckDone(),
"security flags in loadInfo but asyncOpen() not called");
@ -1123,8 +1122,8 @@ nsJSProtocolHandler::NewURI(const nsACString& aSpec, const char* aCharset,
}
NS_IMETHODIMP
nsJSProtocolHandler::NewChannel2(nsIURI* uri, nsILoadInfo* aLoadInfo,
nsIChannel** result) {
nsJSProtocolHandler::NewChannel(nsIURI* uri, nsILoadInfo* aLoadInfo,
nsIChannel** result) {
nsresult rv;
NS_ENSURE_ARG_POINTER(uri);
@ -1142,11 +1141,6 @@ nsJSProtocolHandler::NewChannel2(nsIURI* uri, nsILoadInfo* aLoadInfo,
return rv;
}
NS_IMETHODIMP
nsJSProtocolHandler::NewChannel(nsIURI* uri, nsIChannel** result) {
return NewChannel2(uri, nullptr, result);
}
NS_IMETHODIMP
nsJSProtocolHandler::AllowPort(int32_t port, const char* scheme,
bool* _retval) {

View File

@ -765,12 +765,10 @@ nsresult ChannelMediaResource::RecreateChannel() {
NS_ENSURE_SUCCESS(rv, rv);
if (setAttrs) {
nsCOMPtr<nsILoadInfo> loadInfo = mChannel->GetLoadInfo();
if (loadInfo) {
// The function simply returns NS_OK, so we ignore the return value.
Unused << loadInfo->SetOriginAttributes(
triggeringPrincipal->OriginAttributesRef());
}
nsCOMPtr<nsILoadInfo> loadInfo = mChannel->LoadInfo();
// The function simply returns NS_OK, so we ignore the return value.
Unused << loadInfo->SetOriginAttributes(
triggeringPrincipal->OriginAttributesRef());
}
nsCOMPtr<nsIClassOfService> cos(do_QueryInterface(mChannel));

View File

@ -267,11 +267,7 @@ bool PerformanceTimingData::CheckAllowedOrigin(nsIHttpChannel* aResourceChannel,
}
// Check that the current document passes the ckeck.
nsCOMPtr<nsILoadInfo> loadInfo;
aResourceChannel->GetLoadInfo(getter_AddRefs(loadInfo));
if (!loadInfo) {
return false;
}
nsCOMPtr<nsILoadInfo> loadInfo = aResourceChannel->LoadInfo();
// TYPE_DOCUMENT loads have no loadingPrincipal.
if (loadInfo->GetExternalContentPolicyType() ==

View File

@ -92,6 +92,3 @@ CXXFLAGS += CONFIG['TK_CFLAGS']
if CONFIG['CC_TYPE'] in ('clang', 'gcc'):
CXXFLAGS += ['-Wno-error=shadow']
if CONFIG['CC_TYPE'] == 'clang-cl':
AllowCompilerWarnings() # workaround for bug 1090497

View File

@ -167,7 +167,7 @@ nsPluginStreamListenerPeer::OnStartRequest(nsIRequest* request,
if (NS_FAILED(rv)) return rv;
// Check ShouldProcess with content policy
nsCOMPtr<nsILoadInfo> loadInfo = channel->GetLoadInfo();
nsCOMPtr<nsILoadInfo> loadInfo = channel->LoadInfo();
int16_t shouldLoad = nsIContentPolicy::ACCEPT;
rv = NS_CheckContentProcessPolicy(mURL, loadInfo, contentType, &shouldLoad);

View File

@ -44,7 +44,9 @@ struct nsPluginInfo {
* details.
*/
class nsPluginFile {
#ifndef XP_WIN
PRLibrary* pLibrary;
#endif
nsCOMPtr<nsIFile> mPlugin;
public:

View File

@ -1275,7 +1275,7 @@ nsresult ScriptLoader::StartLoad(ScriptLoadRequest* aRequest) {
if (element && element->IsHTMLElement()) {
nsAutoString cspNonce;
element->GetAttribute(NS_LITERAL_STRING("nonce"), cspNonce);
nsCOMPtr<nsILoadInfo> loadInfo = channel->GetLoadInfo();
nsCOMPtr<nsILoadInfo> loadInfo = channel->LoadInfo();
loadInfo->SetCspNonce(cspNonce);
}
}
@ -3208,9 +3208,9 @@ nsresult ScriptLoader::VerifySRI(ScriptLoadRequest* aRequest,
rv = NS_ERROR_SRI_CORRUPT;
}
} else {
nsCOMPtr<nsILoadInfo> loadInfo = channel->GetLoadInfo();
nsCOMPtr<nsILoadInfo> loadInfo = channel->LoadInfo();
if (loadInfo && loadInfo->GetEnforceSRI()) {
if (loadInfo->GetEnforceSRI()) {
MOZ_LOG(SRILogHelper::GetSriLog(), mozilla::LogLevel::Debug,
("ScriptLoader::OnStreamComplete, required SRI not found"));
nsCOMPtr<nsIContentSecurityPolicy> csp;

View File

@ -184,10 +184,9 @@ static bool ShouldIgnoreFrameOptions(nsIChannel* aChannel,
}
// log warning to console that xfo is ignored because of CSP
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
uint64_t innerWindowID = loadInfo ? loadInfo->GetInnerWindowID() : 0;
bool privateWindow =
loadInfo ? !!loadInfo->GetOriginAttributes().mPrivateBrowsingId : false;
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
uint64_t innerWindowID = loadInfo->GetInnerWindowID();
bool privateWindow = !!loadInfo->GetOriginAttributes().mPrivateBrowsingId;
const char16_t* params[] = {u"x-frame-options", u"frame-ancestors"};
CSP_LogLocalizedStr("IgnoringSrcBecauseOfDirective", params,
ArrayLength(params),
@ -252,9 +251,7 @@ static bool ShouldIgnoreFrameOptions(nsIChannel* aChannel,
if (aDocShell) {
nsCOMPtr<nsIWebNavigation> webNav(do_QueryObject(aDocShell));
if (webNav) {
nsCOMPtr<nsILoadInfo> loadInfo = httpChannel->GetLoadInfo();
MOZ_ASSERT(loadInfo);
nsCOMPtr<nsILoadInfo> loadInfo = httpChannel->LoadInfo();
RefPtr<NullPrincipal> principal =
NullPrincipal::CreateWithInheritedAttributes(
loadInfo->TriggeringPrincipal());

View File

@ -327,8 +327,7 @@ nsresult SRICheckDataVerifier::Verify(const SRIMetadata& aMetadata,
nsresult rv = Finish();
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
NS_ENSURE_TRUE(loadInfo, NS_ERROR_FAILURE);
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
LoadTainting tainting = loadInfo->GetTainting();
if (NS_FAILED(IsEligible(aChannel, tainting, aSourceFileURI, aReporter))) {

View File

@ -260,13 +260,7 @@ CSPService::AsyncOnChannelRedirect(nsIChannel *oldChannel,
nsresult rv = newChannel->GetURI(getter_AddRefs(newUri));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsILoadInfo> loadInfo = oldChannel->GetLoadInfo();
// if no loadInfo on the channel, nothing for us to do
if (!loadInfo) {
return NS_OK;
}
nsCOMPtr<nsILoadInfo> loadInfo = oldChannel->LoadInfo();
nsCOMPtr<nsICSPEventListener> cspEventListener;
rv = loadInfo->GetCspEventListener(getter_AddRefs(cspEventListener));
NS_ENSURE_SUCCESS(rv, rv);

View File

@ -45,10 +45,7 @@ static mozilla::LazyLogModule sCSMLog("CSMLog");
if (!mozilla::net::nsIOService::BlockToplevelDataUriNavigations()) {
return true;
}
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
if (!loadInfo) {
return true;
}
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
if (loadInfo->GetExternalContentPolicyType() !=
nsIContentPolicy::TYPE_DOCUMENT) {
return true;
@ -115,10 +112,7 @@ static mozilla::LazyLogModule sCSMLog("CSMLog");
/* static */ bool nsContentSecurityManager::AllowInsecureRedirectToDataURI(
nsIChannel* aNewChannel) {
nsCOMPtr<nsILoadInfo> loadInfo = aNewChannel->GetLoadInfo();
if (!loadInfo) {
return true;
}
nsCOMPtr<nsILoadInfo> loadInfo = aNewChannel->LoadInfo();
if (loadInfo->GetExternalContentPolicyType() !=
nsIContentPolicy::TYPE_SCRIPT) {
return true;
@ -170,11 +164,7 @@ static mozilla::LazyLogModule sCSMLog("CSMLog");
return NS_OK;
}
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
if (!loadInfo) {
return NS_OK;
}
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
nsContentPolicyType type = loadInfo->GetExternalContentPolicyType();
// Allow top-level FTP documents and save-as download of FTP files on
@ -793,14 +783,7 @@ static void DebugDoContentSecurityCheck(nsIChannel* aChannel,
nsresult nsContentSecurityManager::doContentSecurityCheck(
nsIChannel* aChannel, nsCOMPtr<nsIStreamListener>& aInAndOutListener) {
NS_ENSURE_ARG(aChannel);
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
if (!loadInfo) {
MOZ_ASSERT(false,
"channel needs to have loadInfo to perform security checks");
return NS_ERROR_UNEXPECTED;
}
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
if (MOZ_UNLIKELY(MOZ_LOG_TEST(sCSMLog, LogLevel::Debug))) {
DebugDoContentSecurityCheck(aChannel, loadInfo);
}
@ -844,16 +827,14 @@ NS_IMETHODIMP
nsContentSecurityManager::AsyncOnChannelRedirect(
nsIChannel* aOldChannel, nsIChannel* aNewChannel, uint32_t aRedirFlags,
nsIAsyncVerifyRedirectCallback* aCb) {
nsCOMPtr<nsILoadInfo> loadInfo = aOldChannel->GetLoadInfo();
if (loadInfo) {
nsresult rv = CheckChannel(aNewChannel);
if (NS_SUCCEEDED(rv)) {
rv = CheckFTPSubresourceLoad(aNewChannel);
}
if (NS_FAILED(rv)) {
aOldChannel->Cancel(rv);
return rv;
}
nsCOMPtr<nsILoadInfo> loadInfo = aOldChannel->LoadInfo();
nsresult rv = CheckChannel(aNewChannel);
if (NS_SUCCEEDED(rv)) {
rv = CheckFTPSubresourceLoad(aNewChannel);
}
if (NS_FAILED(rv)) {
aOldChannel->Cancel(rv);
return rv;
}
// Also verify that the redirecting server is allowed to redirect to the
@ -876,7 +857,7 @@ nsContentSecurityManager::AsyncOnChannelRedirect(
const uint32_t flags =
nsIScriptSecurityManager::LOAD_IS_AUTOMATIC_DOCUMENT_REPLACEMENT |
nsIScriptSecurityManager::DISALLOW_SCRIPT;
nsresult rv = nsContentUtils::GetSecurityManager()->CheckLoadURIWithPrincipal(
rv = nsContentUtils::GetSecurityManager()->CheckLoadURIWithPrincipal(
oldPrincipal, newURI, flags);
NS_ENSURE_SUCCESS(rv, rv);
@ -896,9 +877,7 @@ static void AddLoadFlags(nsIRequest* aRequest, nsLoadFlags aNewFlags) {
* if this requesst should not be permitted.
*/
nsresult nsContentSecurityManager::CheckChannel(nsIChannel* aChannel) {
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
MOZ_ASSERT(loadInfo);
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
nsCOMPtr<nsIURI> uri;
nsresult rv = NS_GetFinalChannelURI(aChannel, getter_AddRefs(uri));
NS_ENSURE_SUCCESS(rv, rv);

View File

@ -301,7 +301,7 @@ nsMixedContentBlocker::AsyncOnChannelRedirect(
NS_ENSURE_SUCCESS(rv, rv);
// Get the loading Info from the old channel
nsCOMPtr<nsILoadInfo> loadInfo = aOldChannel->GetLoadInfo();
nsCOMPtr<nsILoadInfo> loadInfo = aOldChannel->LoadInfo();
nsCOMPtr<nsIPrincipal> requestingPrincipal = loadInfo->LoadingPrincipal();
// Since we are calling shouldLoad() directly on redirects, we don't go

View File

@ -273,9 +273,9 @@ class StartResponse final : public Runnable {
nsresult rv = mChannel->GetChannel(getter_AddRefs(underlyingChannel));
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(underlyingChannel, NS_ERROR_UNEXPECTED);
nsCOMPtr<nsILoadInfo> loadInfo = underlyingChannel->GetLoadInfo();
nsCOMPtr<nsILoadInfo> loadInfo = underlyingChannel->LoadInfo();
if (!loadInfo || !CSPPermitsResponse(loadInfo)) {
if (!CSPPermitsResponse(loadInfo)) {
mChannel->CancelInterception(NS_ERROR_CONTENT_BLOCKED);
return NS_OK;
}

View File

@ -22,10 +22,7 @@ ServiceWorkerInterceptController::ShouldPrepareForIntercept(
nsIURI* aURI, nsIChannel* aChannel, bool* aShouldIntercept) {
*aShouldIntercept = false;
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
if (!loadInfo) {
return NS_OK;
}
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
// For subresource requests we base our decision solely on the client's
// controller value. Any settings that would have blocked service worker

View File

@ -1873,38 +1873,36 @@ class ContinueDispatchFetchEventRunnable : public Runnable {
nsString clientId;
nsString resultingClientId;
nsCOMPtr<nsILoadInfo> loadInfo = channel->GetLoadInfo();
if (loadInfo) {
char buf[NSID_LENGTH];
Maybe<ClientInfo> clientInfo = loadInfo->GetClientInfo();
if (clientInfo.isSome()) {
clientInfo.ref().Id().ToProvidedString(buf);
NS_ConvertASCIItoUTF16 uuid(buf);
nsCOMPtr<nsILoadInfo> loadInfo = channel->LoadInfo();
char buf[NSID_LENGTH];
Maybe<ClientInfo> clientInfo = loadInfo->GetClientInfo();
if (clientInfo.isSome()) {
clientInfo.ref().Id().ToProvidedString(buf);
NS_ConvertASCIItoUTF16 uuid(buf);
// Remove {} and the null terminator
clientId.Assign(Substring(uuid, 1, NSID_LENGTH - 3));
}
// Remove {} and the null terminator
clientId.Assign(Substring(uuid, 1, NSID_LENGTH - 3));
}
// Having an initial or reserved client are mutually exclusive events:
// either an initial client is used upon navigating an about:blank
// iframe, or a new, reserved environment/client is created (e.g.
// upon a top-level navigation). See step 4 of
// https://html.spec.whatwg.org/#process-a-navigate-fetch as well as
// https://github.com/w3c/ServiceWorker/issues/1228#issuecomment-345132444
Maybe<ClientInfo> resulting = loadInfo->GetInitialClientInfo();
// Having an initial or reserved client are mutually exclusive events:
// either an initial client is used upon navigating an about:blank
// iframe, or a new, reserved environment/client is created (e.g.
// upon a top-level navigation). See step 4 of
// https://html.spec.whatwg.org/#process-a-navigate-fetch as well as
// https://github.com/w3c/ServiceWorker/issues/1228#issuecomment-345132444
Maybe<ClientInfo> resulting = loadInfo->GetInitialClientInfo();
if (resulting.isNothing()) {
resulting = loadInfo->GetReservedClientInfo();
} else {
MOZ_ASSERT(loadInfo->GetReservedClientInfo().isNothing());
}
if (resulting.isNothing()) {
resulting = loadInfo->GetReservedClientInfo();
} else {
MOZ_ASSERT(loadInfo->GetReservedClientInfo().isNothing());
}
if (resulting.isSome()) {
resulting.ref().Id().ToProvidedString(buf);
NS_ConvertASCIItoUTF16 uuid(buf);
if (resulting.isSome()) {
resulting.ref().Id().ToProvidedString(buf);
NS_ConvertASCIItoUTF16 uuid(buf);
resultingClientId.Assign(Substring(uuid, 1, NSID_LENGTH - 3));
}
resultingClientId.Assign(Substring(uuid, 1, NSID_LENGTH - 3));
}
rv = mServiceWorkerPrivate->SendFetchEvent(mChannel, mLoadGroup, clientId,
@ -1936,12 +1934,7 @@ void ServiceWorkerManager::DispatchFetchEvent(nsIInterceptedChannel* aChannel,
return;
}
nsCOMPtr<nsILoadInfo> loadInfo = internalChannel->GetLoadInfo();
if (NS_WARN_IF(!loadInfo)) {
aRv.Throw(NS_ERROR_UNEXPECTED);
return;
}
nsCOMPtr<nsILoadInfo> loadInfo = internalChannel->LoadInfo();
RefPtr<ServiceWorkerInfo> serviceWorker;
if (!nsContentUtils::IsNonSubresourceRequest(internalChannel)) {

View File

@ -247,11 +247,7 @@ nsresult ChannelFromScriptURL(nsIPrincipal* principal, Document* parentDoc,
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_SECURITY_ERR);
if (cspEventListener) {
nsCOMPtr<nsILoadInfo> loadInfo = channel->GetLoadInfo();
if (NS_WARN_IF(!loadInfo)) {
return NS_ERROR_UNEXPECTED;
}
nsCOMPtr<nsILoadInfo> loadInfo = channel->LoadInfo();
rv = loadInfo->SetCspEventListener(cspEventListener);
NS_ENSURE_SUCCESS(rv, rv);
}
@ -1156,8 +1152,8 @@ class ScriptLoaderRunnable final : public nsIRunnable, public nsINamed {
aLoadInfo.mURL.Assign(NS_ConvertUTF8toUTF16(filename));
}
nsCOMPtr<nsILoadInfo> chanLoadInfo = channel->GetLoadInfo();
if (chanLoadInfo && chanLoadInfo->GetEnforceSRI()) {
nsCOMPtr<nsILoadInfo> chanLoadInfo = channel->LoadInfo();
if (chanLoadInfo->GetEnforceSRI()) {
// importScripts() and the Worker constructor do not support integrity
// metadata
// (or any fetch options). Until then, we can just block.

View File

@ -747,13 +747,7 @@ bool XMLHttpRequestMainThread::IsCrossSiteCORSRequest() const {
return false;
}
nsCOMPtr<nsILoadInfo> loadInfo = mChannel->GetLoadInfo();
MOZ_ASSERT(loadInfo);
if (!loadInfo) {
return false;
}
nsCOMPtr<nsILoadInfo> loadInfo = mChannel->LoadInfo();
return loadInfo->GetTainting() == LoadTainting::CORS;
}
@ -1478,11 +1472,8 @@ void XMLHttpRequestMainThread::SetOriginAttributes(
OriginAttributes attrs(aAttrs);
nsCOMPtr<nsILoadInfo> loadInfo = mChannel->GetLoadInfo();
MOZ_ASSERT(loadInfo);
if (loadInfo) {
loadInfo->SetOriginAttributes(attrs);
}
nsCOMPtr<nsILoadInfo> loadInfo = mChannel->LoadInfo();
loadInfo->SetOriginAttributes(attrs);
}
/*
@ -1989,12 +1980,9 @@ XMLHttpRequestMainThread::OnStartRequest(nsIRequest* request,
mResponseXML->ForceEnableXULXBL();
}
nsCOMPtr<nsILoadInfo> loadInfo = mChannel->GetLoadInfo();
MOZ_ASSERT(loadInfo);
nsCOMPtr<nsILoadInfo> loadInfo = mChannel->LoadInfo();
bool isCrossSite = false;
if (loadInfo) {
isCrossSite = loadInfo->GetTainting() != LoadTainting::Basic;
}
isCrossSite = loadInfo->GetTainting() != LoadTainting::Basic;
if (isCrossSite) {
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(mResponseXML);
@ -2365,11 +2353,7 @@ nsresult XMLHttpRequestMainThread::CreateChannel() {
NS_ENSURE_SUCCESS(rv, rv);
if (mCSPEventListener) {
nsCOMPtr<nsILoadInfo> loadInfo = mChannel->GetLoadInfo();
if (NS_WARN_IF(!loadInfo)) {
return NS_ERROR_UNEXPECTED;
}
nsCOMPtr<nsILoadInfo> loadInfo = mChannel->LoadInfo();
rv = loadInfo->SetCspEventListener(mCSPEventListener);
NS_ENSURE_SUCCESS(rv, rv);
}
@ -2525,10 +2509,8 @@ nsresult XMLHttpRequestMainThread::InitiateFetch(
// .withCredentials can be called after open() is called.
// Not doing this for privileged system XHRs since those don't use CORS.
if (!IsSystemXHR() && !mIsAnon && mFlagACwithCredentials) {
nsCOMPtr<nsILoadInfo> loadInfo = mChannel->GetLoadInfo();
if (loadInfo) {
static_cast<net::LoadInfo*>(loadInfo.get())->SetIncludeCookiesSecFlag();
}
nsCOMPtr<nsILoadInfo> loadInfo = mChannel->LoadInfo();
static_cast<net::LoadInfo*>(loadInfo.get())->SetIncludeCookiesSecFlag();
}
// We never let XHR be blocked by head CSS/JS loads to avoid potential
@ -2591,11 +2573,9 @@ nsresult XMLHttpRequestMainThread::InitiateFetch(
if (!IsSystemXHR()) {
nsTArray<nsCString> CORSUnsafeHeaders;
mAuthorRequestHeaders.GetCORSUnsafeHeaders(CORSUnsafeHeaders);
nsCOMPtr<nsILoadInfo> loadInfo = mChannel->GetLoadInfo();
if (loadInfo) {
loadInfo->SetCorsPreflightInfo(CORSUnsafeHeaders,
mFlagHadUploadListenersOnSend);
}
nsCOMPtr<nsILoadInfo> loadInfo = mChannel->LoadInfo();
loadInfo->SetCorsPreflightInfo(CORSUnsafeHeaders,
mFlagHadUploadListenersOnSend);
}
// Hook us up to listen to redirects and the like. Only do this very late

View File

@ -45,7 +45,6 @@
# include "NativeFontResourceDWrite.h"
# include <d3d10_1.h>
# include "HelpersD2D.h"
# include "HelpersWinFonts.h"
#endif
#include "DrawTargetCapture.h"

View File

@ -260,6 +260,3 @@ if CONFIG['MOZ_ENABLE_SKIA_GPU']:
LOCAL_INCLUDES += [
'/gfx/skia/skia/src/gpu',
]
if CONFIG['CC_TYPE'] == 'clang-cl':
AllowCompilerWarnings() # workaround for bug 1090497

View File

@ -102,8 +102,7 @@ bool DeviceManagerDx::LoadD3D11() {
}
bool DeviceManagerDx::LoadDcomp() {
FeatureState& d3d11 = gfxConfig::GetFeature(Feature::D3D11_COMPOSITING);
MOZ_ASSERT(d3d11.IsEnabled());
MOZ_ASSERT(gfxConfig::GetFeature(Feature::D3D11_COMPOSITING).IsEnabled());
MOZ_ASSERT(gfxVars::UseWebRender());
MOZ_ASSERT(gfxVars::UseWebRenderANGLE());
MOZ_ASSERT(gfxVars::UseWebRenderDCompWin());
@ -168,11 +167,13 @@ nsTArray<DXGI_OUTPUT_DESC1> DeviceManagerDx::EnumerateOutputs() {
return outputs;
}
#ifdef DEBUG
static inline bool ProcessOwnsCompositor() {
return XRE_GetProcessType() == GeckoProcessType_GPU ||
XRE_GetProcessType() == GeckoProcessType_VR ||
(XRE_IsParentProcess() && !gfxConfig::IsEnabled(Feature::GPU_PROCESS));
}
#endif
bool DeviceManagerDx::CreateCompositorDevices() {
MOZ_ASSERT(ProcessOwnsCompositor());

View File

@ -281,6 +281,3 @@ DEFINES['GRAPHITE2_STATIC'] = True
if CONFIG['CC_TYPE'] == 'clang':
# Suppress warnings from Skia header files.
SOURCES['gfxPlatform.cpp'].flags += ['-Wno-implicit-fallthrough']
if CONFIG['CC_TYPE'] == 'clang-cl':
AllowCompilerWarnings() # workaround for bug 1090497

View File

@ -64,8 +64,8 @@ nsIconProtocolHandler::NewURI(const nsACString& aSpec,
}
NS_IMETHODIMP
nsIconProtocolHandler::NewChannel2(nsIURI* url, nsILoadInfo* aLoadInfo,
nsIChannel** result) {
nsIconProtocolHandler::NewChannel(nsIURI* url, nsILoadInfo* aLoadInfo,
nsIChannel** result) {
NS_ENSURE_ARG_POINTER(url);
nsIconChannel* channel = new nsIconChannel;
if (!channel) {
@ -90,9 +90,4 @@ nsIconProtocolHandler::NewChannel2(nsIURI* url, nsILoadInfo* aLoadInfo,
return NS_OK;
}
NS_IMETHODIMP
nsIconProtocolHandler::NewChannel(nsIURI* url, nsIChannel** result) {
return NewChannel2(url, nullptr, result);
}
////////////////////////////////////////////////////////////////////////////////

View File

@ -825,11 +825,9 @@ static nsresult NewImageChannel(
// triggeringPrincipal as the channel's originAttributes. This allows the
// favicon loading from XUL will use the correct originAttributes.
nsCOMPtr<nsILoadInfo> loadInfo = (*aResult)->GetLoadInfo();
if (loadInfo) {
rv = loadInfo->SetOriginAttributes(
aTriggeringPrincipal->OriginAttributesRef());
}
nsCOMPtr<nsILoadInfo> loadInfo = (*aResult)->LoadInfo();
rv = loadInfo->SetOriginAttributes(
aTriggeringPrincipal->OriginAttributesRef());
}
} else {
// either we are loading something inside a document, in which case
@ -858,10 +856,8 @@ static nsresult NewImageChannel(
}
attrs.mPrivateBrowsingId = aRespectPrivacy ? 1 : 0;
nsCOMPtr<nsILoadInfo> loadInfo = (*aResult)->GetLoadInfo();
if (loadInfo) {
rv = loadInfo->SetOriginAttributes(attrs);
}
nsCOMPtr<nsILoadInfo> loadInfo = (*aResult)->LoadInfo();
rv = loadInfo->SetOriginAttributes(attrs);
}
if (NS_FAILED(rv)) {
@ -2374,12 +2370,9 @@ nsresult imgLoader::LoadImageWithChannel(nsIChannel* channel,
nsCOMPtr<Document> doc = do_QueryInterface(aCX);
NS_ENSURE_TRUE(channel, NS_ERROR_FAILURE);
nsCOMPtr<nsILoadInfo> loadInfo = channel->GetLoadInfo();
nsCOMPtr<nsILoadInfo> loadInfo = channel->LoadInfo();
OriginAttributes attrs;
if (loadInfo) {
attrs = loadInfo->GetOriginAttributes();
}
OriginAttributes attrs = loadInfo->GetOriginAttributes();
nsresult rv;
ImageCacheKey key(uri, attrs, doc, rv);
@ -2420,12 +2413,10 @@ nsresult imgLoader::LoadImageWithChannel(nsIChannel* channel,
// Since aCanMakeNewChannel == false, we don't need to pass content policy
// type/principal/etc
nsCOMPtr<nsILoadInfo> loadInfo = channel->GetLoadInfo();
nsCOMPtr<nsILoadInfo> loadInfo = channel->LoadInfo();
// if there is a loadInfo, use the right contentType, otherwise
// default to the internal image type
nsContentPolicyType policyType =
loadInfo ? loadInfo->InternalContentPolicyType()
: nsIContentPolicy::TYPE_INTERNAL_IMAGE;
nsContentPolicyType policyType = loadInfo->InternalContentPolicyType();
if (ValidateEntry(entry, uri, nullptr, nullptr, RP_Unset, nullptr,
aObserver, aCX, doc, requestFlags, policyType, false,

View File

@ -1200,7 +1200,7 @@ imgRequest::OnRedirectVerifyCallback(nsresult result) {
// to upgrade all requests from http to https before any data is fetched
// from the network. Do not pollute mHadInsecureRedirect in case of such an
// internal redirect.
nsCOMPtr<nsILoadInfo> loadInfo = mChannel->GetLoadInfo();
nsCOMPtr<nsILoadInfo> loadInfo = mChannel->LoadInfo();
bool upgradeInsecureRequests =
loadInfo ? loadInfo->GetUpgradeInsecureRequests() ||
loadInfo->GetBrowserUpgradeInsecureRequests()

View File

@ -131,6 +131,3 @@ if CONFIG['CC_TYPE'] in ('clang', 'gcc'):
# Add libFuzzer configuration directives
include('/tools/fuzzing/libfuzzer-config.mozbuild')
if CONFIG['CC_TYPE'] == 'clang-cl':
AllowCompilerWarnings() # workaround for bug 1090497

View File

@ -13,17 +13,6 @@
namespace {
// The information on how to set the thread name comes from
// a MSDN article: http://msdn2.microsoft.com/en-us/library/xcb2z8hs.aspx
const DWORD kVCThreadNameException = 0x406D1388;
typedef struct tagTHREADNAME_INFO {
DWORD dwType; // Must be 0x1000.
LPCSTR szName; // Pointer to name (in user addr space).
DWORD dwThreadID; // Thread ID (-1=caller thread).
DWORD dwFlags; // Reserved for future use, must be zero.
} THREADNAME_INFO;
DWORD __stdcall ThreadFunc(void* closure) {
PlatformThread::Delegate* delegate =
static_cast<PlatformThread::Delegate*>(closure);

View File

@ -22,12 +22,6 @@
namespace {
// System pagesize. This value remains constant on x86/64 architectures.
const int PAGESIZE_KB = 4;
// HeapSetInformation function pointer.
typedef BOOL(WINAPI* HeapSetFn)(HANDLE, HEAP_INFORMATION_CLASS, PVOID, SIZE_T);
typedef BOOL(WINAPI* InitializeProcThreadAttributeListFn)(
LPPROC_THREAD_ATTRIBUTE_LIST lpAttributeList, DWORD dwAttributeCount,
DWORD dwFlags, PSIZE_T lpSize);

View File

@ -20,14 +20,6 @@ namespace base {
// for interaction with APIs that require it.
inline char* strdup(const char* str) { return _strdup(str); }
inline int strcasecmp(const char* s1, const char* s2) {
return _stricmp(s1, s2);
}
inline int strncasecmp(const char* s1, const char* s2, size_t count) {
return _strnicmp(s1, s2, count);
}
inline int vsnprintf(char* buffer, size_t size, const char* format,
va_list arguments) {
int length = vsnprintf_s(buffer, size, size - 1, format, arguments);

View File

@ -16,10 +16,10 @@ namespace win_util {
std::wstring FormatMessage(unsigned messageid) {
wchar_t* string_buffer = NULL;
unsigned string_length = ::FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, messageid, 0, reinterpret_cast<wchar_t*>(&string_buffer), 0, NULL);
::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, messageid, 0,
reinterpret_cast<wchar_t*>(&string_buffer), 0, NULL);
std::wstring formatted_string;
if (string_buffer) {

View File

@ -52,6 +52,9 @@ GeckoProfilerEntryMarker::GeckoProfilerEntryMarker(
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
if (MOZ_LIKELY(!profiler_->infraInstalled())) {
profiler_ = nullptr;
#ifdef DEBUG
spBefore_ = 0;
#endif
return;
}
#ifdef DEBUG
@ -85,6 +88,9 @@ AutoGeckoProfilerEntry::AutoGeckoProfilerEntry(
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
if (MOZ_LIKELY(!profiler_->infraInstalled())) {
profiler_ = nullptr;
#ifdef DEBUG
spBefore_ = 0;
#endif
return;
}
#ifdef DEBUG

View File

@ -6450,80 +6450,27 @@ class BaseCompiler final : public BaseCompilerInterface {
void emitPreBarrier(RegPtr valueAddr) {
Label skipBarrier;
MOZ_ASSERT(valueAddr == PreBarrierReg);
ScratchPtr scratch(*this);
// If no incremental GC has started, we don't need the barrier.
masm.loadWasmTlsRegFromFrame(scratch);
masm.loadPtr(
Address(scratch, offsetof(TlsData, addressOfNeedsIncrementalBarrier)),
scratch);
masm.branchTest32(Assembler::Zero, Address(scratch, 0), Imm32(0x1),
&skipBarrier);
EmitWasmPreBarrierGuard(masm, scratch, scratch, valueAddr, &skipBarrier);
// If the previous value is null, we don't need the barrier.
masm.loadPtr(Address(valueAddr, 0), scratch);
masm.branchTestPtr(Assembler::Zero, scratch, scratch, &skipBarrier);
// Call the barrier. This assumes PreBarrierReg contains the address of
// the stored value.
//
// PreBarrierReg is volatile and is preserved by the barrier.
masm.loadWasmTlsRegFromFrame(scratch);
masm.loadPtr(Address(scratch, offsetof(TlsData, instance)), scratch);
masm.loadPtr(Address(scratch, Instance::offsetOfPreBarrierCode()), scratch);
#ifdef JS_CODEGEN_ARM64
// The prebarrier stub assumes the PseudoStackPointer is set up. We do
// not need to save and restore x28 because it is not yet allocatable.
// The prebarrier stub assumes the PseudoStackPointer is set up. It is OK
// to just move the sp to x28 here because x28 is not being used by the
// baseline compiler and need not be saved or restored.
MOZ_ASSERT(!GeneralRegisterSet::All().hasRegisterIndex(x28.asUnsized()));
masm.Mov(x28, sp);
#endif
masm.call(scratch);
EmitWasmPreBarrierCall(masm, scratch, scratch, valueAddr);
masm.bind(&skipBarrier);
}
// Emit a GC post-write barrier. The barrier is needed to ensure that the
// GC is aware of slots of tenured things containing references to nursery
// values.
//
// The barrier has five easy steps:
//
// Label skipBarrier;
// sync();
// emitPostBarrierGuard(..., &skipBarrier);
// emitPostBarrier(...);
// bind(&skipBarrier);
//
// These are divided up to allow other actions to be placed between them,
// such as saving and restoring live registers. postBarrier() will make a
// call to C++ and will kill all live registers. The initial sync() is
// required to make sure all paths sync the same amount.
// Pass None for `object` when the field's owner object is known to be
// tenured or heap-allocated.
void emitPostBarrierGuard(const Maybe<RegPtr>& object, RegPtr otherScratch,
RegPtr setValue, Label* skipBarrier) {
// If the pointer being stored is null, no barrier.
masm.branchTestPtr(Assembler::Zero, setValue, setValue, skipBarrier);
// If there is a containing object and it is in the nursery, no barrier.
if (object) {
masm.branchPtrInNurseryChunk(Assembler::Equal, *object, otherScratch,
skipBarrier);
}
// If the pointer being stored is to a tenured object, no barrier.
masm.branchPtrInNurseryChunk(Assembler::NotEqual, setValue, otherScratch,
skipBarrier);
}
// This frees the register `valueAddr`.
MOZ_MUST_USE bool emitPostBarrier(RegPtr valueAddr) {
MOZ_MUST_USE bool emitPostBarrierCall(RegPtr valueAddr) {
uint32_t bytecodeOffset = iter_.lastOpcodeOffset();
// The `valueAddr` is a raw pointer to the cell within some GC object or
@ -6561,10 +6508,10 @@ class BaseCompiler final : public BaseCompilerInterface {
sync();
RegPtr otherScratch = needRef();
emitPostBarrierGuard(object, otherScratch, value, &skipBarrier);
EmitWasmPostBarrierGuard(masm, object, otherScratch, value, &skipBarrier);
freeRef(otherScratch);
if (!emitPostBarrier(valueAddr)) {
if (!emitPostBarrierCall(valueAddr)) {
return false;
}
masm.bind(&skipBarrier);
@ -10575,7 +10522,7 @@ bool BaseCompiler::emitStructNew() {
}
RegPtr otherScratch = needRef();
emitPostBarrierGuard(Some(rowner), otherScratch, value, &skipBarrier);
EmitWasmPostBarrierGuard(masm, Some(rowner), otherScratch, value, &skipBarrier);
freeRef(otherScratch);
if (!structType.isInline_) {
@ -10591,7 +10538,7 @@ bool BaseCompiler::emitStructNew() {
pushRef(rp); // Save rp across the call
RegPtr valueAddr = needRef();
masm.computeEffectiveAddress(Address(rdata, offs), valueAddr);
if (!emitPostBarrier(valueAddr)) { // Consumes valueAddr
if (!emitPostBarrierCall(valueAddr)) { // Consumes valueAddr
return false;
}
popRef(rp); // Restore rp

View File

@ -17,7 +17,60 @@
*/
#include "wasm/WasmGC.h"
#include "wasm/WasmInstance.h"
#include "jit/MacroAssembler-inl.h"
namespace js {
namespace wasm {} // namespace wasm
namespace wasm {
void EmitWasmPreBarrierGuard(MacroAssembler& masm, Register tls,
Register scratch, Register valueAddr,
Label* skipBarrier) {
// If no incremental GC has started, we don't need the barrier.
masm.loadPtr(
Address(tls, offsetof(TlsData, addressOfNeedsIncrementalBarrier)),
scratch);
masm.branchTest32(Assembler::Zero, Address(scratch, 0), Imm32(0x1),
skipBarrier);
// If the previous value is null, we don't need the barrier.
masm.loadPtr(Address(valueAddr, 0), scratch);
masm.branchTestPtr(Assembler::Zero, scratch, scratch, skipBarrier);
}
void EmitWasmPreBarrierCall(MacroAssembler& masm, Register tls,
Register scratch, Register valueAddr) {
MOZ_ASSERT(valueAddr == PreBarrierReg);
masm.loadPtr(Address(tls, offsetof(TlsData, instance)), scratch);
masm.loadPtr(Address(scratch, Instance::offsetOfPreBarrierCode()), scratch);
#if defined(DEBUG) && defined(JS_CODEGEN_ARM64)
// The prebarrier assumes that x28 == sp.
Label ok;
masm.Cmp(sp, vixl::Operand(x28));
masm.B(&ok, Assembler::Equal);
masm.breakpoint();
masm.bind(&ok);
#endif
masm.call(scratch);
}
void EmitWasmPostBarrierGuard(MacroAssembler& masm, const Maybe<Register>& object,
Register otherScratch, Register setValue,
Label* skipBarrier) {
// If the pointer being stored is null, no barrier.
masm.branchTestPtr(Assembler::Zero, setValue, setValue, skipBarrier);
// If there is a containing object and it is in the nursery, no barrier.
if (object) {
masm.branchPtrInNurseryChunk(Assembler::Equal, *object, otherScratch,
skipBarrier);
}
// If the pointer being stored is to a tenured object, no barrier.
masm.branchPtrInNurseryChunk(Assembler::NotEqual, setValue, otherScratch,
skipBarrier);
}
} // namespace wasm
} // namespace js

View File

@ -56,6 +56,60 @@ static inline size_t StackArgAreaSizeAligned(const T& argTypes) {
return AlignStackArgAreaSize(StackArgAreaSizeUnaligned(argTypes));
}
// Shared write barrier code.
//
// A barriered store looks like this:
//
// Label skipPreBarrier;
// EmitWasmPreBarrierGuard(..., &skipPreBarrier);
// <COMPILER-SPECIFIC ACTIONS HERE>
// EmitWasmPreBarrierCall(...);
// bind(&skipPreBarrier);
//
// <STORE THE VALUE IN MEMORY HERE>
//
// Label skipPostBarrier;
// <COMPILER-SPECIFIC ACTIONS HERE>
// EmitWasmPostBarrierGuard(..., &skipPostBarrier);
// <CALL POST-BARRIER HERE IN A COMPILER-SPECIFIC WAY>
// bind(&skipPostBarrier);
//
// The actions are divided up to allow other actions to be placed between them,
// such as saving and restoring live registers. The postbarrier call invokes
// C++ and will kill all live registers.
// Before storing a GC pointer value in memory, skip to `skipBarrier` if the
// prebarrier is not needed. Will clobber `scratch`.
//
// It is OK for `tls` and `scratch` to be the same register.
void EmitWasmPreBarrierGuard(MacroAssembler& masm, Register tls,
Register scratch, Register valueAddr,
Label* skipBarrier);
// Before storing a GC pointer value in memory, call out-of-line prebarrier
// code. This assumes `PreBarrierReg` contains the address that will be updated.
// On ARM64 it also assums that x28 (the PseudoStackPointer) has the same value
// as SP. `PreBarrierReg` is preserved by the barrier function. Will clobber
// `scratch`.
//
// It is OK for `tls` and `scratch` to be the same register.
void EmitWasmPreBarrierCall(MacroAssembler& masm, Register tls,
Register scratch, Register valueAddr);
// After storing a GC pointer value in memory, skip to `skipBarrier` if a
// postbarrier is not needed. If the location being set is in an heap-allocated
// object then `object` must reference that object; otherwise it should be None.
// The value that was stored is `setValue`. Will clobber `otherScratch` and
// will use other available scratch registers.
//
// `otherScratch` cannot be a designated scratch register.
void EmitWasmPostBarrierGuard(MacroAssembler& masm, const Maybe<Register>& object,
Register otherScratch, Register setValue,
Label* skipBarrier);
} // namespace wasm
} // namespace js

View File

@ -743,8 +743,8 @@ nsresult SheetLoadData::VerifySheetReadyToParse(nsresult aStatus,
SRIMetadata sriMetadata;
mSheet->GetIntegrity(sriMetadata);
if (sriMetadata.IsEmpty()) {
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
if (loadInfo && loadInfo->GetEnforceSRI()) {
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
if (loadInfo->GetEnforceSRI()) {
LOG((" Load was blocked by SRI"));
MOZ_LOG(gSriPRLog, mozilla::LogLevel::Debug,
("css::Loader::OnStreamComplete, required SRI not found"));
@ -1326,7 +1326,7 @@ nsresult Loader::LoadSheet(SheetLoadData* aLoadData,
if (element && element->IsHTMLElement()) {
nsAutoString cspNonce;
element->GetAttribute(NS_LITERAL_STRING("nonce"), cspNonce);
nsCOMPtr<nsILoadInfo> loadInfo = channel->GetLoadInfo();
nsCOMPtr<nsILoadInfo> loadInfo = channel->LoadInfo();
loadInfo->SetCspNonce(cspNonce);
}
}
@ -1465,7 +1465,7 @@ nsresult Loader::LoadSheet(SheetLoadData* aLoadData,
if (element && element->IsHTMLElement()) {
nsAutoString cspNonce;
element->GetAttribute(NS_LITERAL_STRING("nonce"), cspNonce);
nsCOMPtr<nsILoadInfo> loadInfo = channel->GetLoadInfo();
nsCOMPtr<nsILoadInfo> loadInfo = channel->LoadInfo();
loadInfo->SetCspNonce(cspNonce);
}
}

View File

@ -95,6 +95,3 @@ DEFINES['R_DEFINED_UINT8'] = 'uint64_t'
if CONFIG['CC_TYPE'] in ('clang', 'gcc'):
CXXFLAGS += ['-Wno-error=shadow']
if CONFIG['CC_TYPE'] == 'clang-cl':
AllowCompilerWarnings() # workaround for bug 1090497

View File

@ -4351,13 +4351,14 @@ inline void MozJemalloc::moz_dispose_arena(arena_id_t aArenaId) {
// End non-standard functions.
// ***************************************************************************
#ifndef XP_WIN
// Begin library-private functions, used by threading libraries for protection
// of malloc during fork(). These functions are only called if the program is
// running in threaded mode, so there is no need to check whether the program
// is threaded here.
#ifndef XP_DARWIN
# ifndef XP_DARWIN
static
#endif
# endif
void
_malloc_prefork(void) {
// Acquire all mutexes in a safe order.
@ -4372,9 +4373,9 @@ static
huge_mtx.Lock();
}
#ifndef XP_DARWIN
# ifndef XP_DARWIN
static
#endif
# endif
void
_malloc_postfork_parent(void) {
// Release all mutexes, now that fork() has completed.
@ -4389,9 +4390,9 @@ static
gArenas.mLock.Unlock();
}
#ifndef XP_DARWIN
# ifndef XP_DARWIN
static
#endif
# endif
void
_malloc_postfork_child(void) {
// Reinitialize all mutexes, now that fork() has completed.
@ -4405,6 +4406,7 @@ static
gArenas.mLock.Init();
}
#endif // XP_WIN
// End library-private functions.
// ***************************************************************************

View File

@ -1351,6 +1351,7 @@ const char* Options::ModeString() const {
// DMD start-up
//---------------------------------------------------------------------------
#ifndef XP_WIN
static void prefork() {
if (gStateLock) {
gStateLock->Lock();
@ -1362,6 +1363,7 @@ static void postfork() {
gStateLock->Unlock();
}
}
#endif
// WARNING: this function runs *very* early -- before all static initializers
// have run. For this reason, non-scalar globals such as gStateLock and

View File

@ -36,6 +36,3 @@ if CONFIG['OS_ARCH'] == 'WINNT':
]
TEST_DIRS += ['test']
if CONFIG['CC_TYPE'] == 'clang-cl':
AllowCompilerWarnings() # workaround for bug 1090497

View File

@ -27,9 +27,11 @@ static bool sStdoutOrStderr = false;
static Mutex sMutex;
#ifndef _WIN32
static void prefork() { sMutex.Lock(); }
static void postfork() { sMutex.Unlock(); }
#endif
static size_t GetPid() { return size_t(getpid()); }

View File

@ -28,6 +28,3 @@ if CONFIG['OS_TARGET'] == 'Android' and FORCE_SHARED_LIB:
DIRS += [
'replay',
]
if CONFIG['CC_TYPE'] == 'clang-cl':
AllowCompilerWarnings() # workaround for bug 1090497

View File

@ -18,6 +18,3 @@ DIRS += [
if CONFIG['MOZ_DMD']:
DIRS += ['dmd']
if CONFIG['MOZ_DEBUG'] and CONFIG['CC_TYPE'] == 'clang-cl':
AllowCompilerWarnings() # workaround for bug 1090497

View File

@ -6486,7 +6486,9 @@ var ExternalApps = {
buttons: [
Strings.browser.GetStringFromName("openInApp.ok"),
Strings.browser.GetStringFromName("openInApp.cancel")
]
],
// Support double tapping to launch an app
doubleTapButton: 0
}, (result) => {
if (result.button != 0) {
if (wasPlaying) {

View File

@ -106,8 +106,8 @@ nsJARProtocolHandler::NewURI(const nsACString &aSpec, const char *aCharset,
}
NS_IMETHODIMP
nsJARProtocolHandler::NewChannel2(nsIURI *uri, nsILoadInfo *aLoadInfo,
nsIChannel **result) {
nsJARProtocolHandler::NewChannel(nsIURI *uri, nsILoadInfo *aLoadInfo,
nsIChannel **result) {
nsJARChannel *chan = new nsJARChannel();
if (!chan) return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(chan);
@ -129,11 +129,6 @@ nsJARProtocolHandler::NewChannel2(nsIURI *uri, nsILoadInfo *aLoadInfo,
return NS_OK;
}
NS_IMETHODIMP
nsJARProtocolHandler::NewChannel(nsIURI *uri, nsIChannel **result) {
return NewChannel2(uri, nullptr, result);
}
NS_IMETHODIMP
nsJARProtocolHandler::AllowPort(int32_t port, const char *scheme,
bool *_retval) {

View File

@ -11,7 +11,7 @@
// See mozmemory_wrap.h for more details. This file is part of libmozglue, so
// it needs to use _impl suffixes.
# define MALLOC_DECL(name, return_type, ...) \
extern "C" MOZ_MEMORY_API return_type name##_impl(__VA_ARGS__);
MOZ_MEMORY_API return_type name##_impl(__VA_ARGS__);
# include "malloc_decls.h"
# include "mozilla/mozalloc.h"
#endif

View File

@ -134,6 +134,3 @@ if CONFIG['MOZ_LINKER'] and CONFIG['CPU_ARCH'] == 'arm':
LDFLAGS += ['-Wl,-version-script,%s/arm-eabi-filter' % SRCDIR]
DIST_INSTALL = True
if CONFIG['CC_TYPE'] == 'clang-cl':
AllowCompilerWarnings() # workaround for bug 1090497

View File

@ -269,10 +269,8 @@ LoadInfo::LoadInfo(
// if owner doc has content signature, we enforce SRI
nsCOMPtr<nsIChannel> channel = aLoadingContext->OwnerDoc()->GetChannel();
if (channel) {
nsCOMPtr<nsILoadInfo> loadInfo = channel->GetLoadInfo();
if (loadInfo) {
mEnforceSRI = loadInfo->GetVerifySignedContent();
}
nsCOMPtr<nsILoadInfo> loadInfo = channel->LoadInfo();
mEnforceSRI = loadInfo->GetVerifySignedContent();
}
}

View File

@ -1255,10 +1255,8 @@ nsresult Predictor::Prefetch(nsIURI *uri, nsIURI *referrer,
return rv;
}
nsCOMPtr<nsILoadInfo> loadInfo = channel->GetLoadInfo();
if (loadInfo) {
rv = loadInfo->SetOriginAttributes(originAttributes);
}
nsCOMPtr<nsILoadInfo> loadInfo = channel->LoadInfo();
rv = loadInfo->SetOriginAttributes(originAttributes);
if (NS_FAILED(rv)) {
PREDICTOR_LOG(

View File

@ -74,8 +74,8 @@ nsresult nsAsyncRedirectVerifyHelper::Init(
if (!(flags & (nsIChannelEventSink::REDIRECT_INTERNAL |
nsIChannelEventSink::REDIRECT_STS_UPGRADE))) {
nsCOMPtr<nsILoadInfo> loadInfo = oldChan->GetLoadInfo();
if (loadInfo && loadInfo->GetDontFollowRedirects()) {
nsCOMPtr<nsILoadInfo> loadInfo = oldChan->LoadInfo();
if (loadInfo->GetDontFollowRedirects()) {
ExplicitCallback(NS_BINDING_ABORTED);
return NS_OK;
}

View File

@ -83,55 +83,48 @@ nsresult nsBaseChannel::Redirect(nsIChannel *newChannel, uint32_t redirectFlags,
// make a copy of the loadinfo, append to the redirectchain
// and set it on the new channel
if (mLoadInfo) {
nsSecurityFlags secFlags = mLoadInfo->GetSecurityFlags() &
~nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL;
nsCOMPtr<nsILoadInfo> newLoadInfo =
static_cast<mozilla::net::LoadInfo *>(mLoadInfo.get())
->CloneWithNewSecFlags(secFlags);
nsSecurityFlags secFlags =
mLoadInfo->GetSecurityFlags() & ~nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL;
nsCOMPtr<nsILoadInfo> newLoadInfo =
static_cast<mozilla::net::LoadInfo *>(mLoadInfo.get())
->CloneWithNewSecFlags(secFlags);
nsCOMPtr<nsIPrincipal> uriPrincipal;
nsIScriptSecurityManager *sm = nsContentUtils::GetSecurityManager();
sm->GetChannelURIPrincipal(this, getter_AddRefs(uriPrincipal));
bool isInternalRedirect =
(redirectFlags & (nsIChannelEventSink::REDIRECT_INTERNAL |
nsIChannelEventSink::REDIRECT_STS_UPGRADE));
nsCOMPtr<nsIPrincipal> uriPrincipal;
nsIScriptSecurityManager *sm = nsContentUtils::GetSecurityManager();
sm->GetChannelURIPrincipal(this, getter_AddRefs(uriPrincipal));
bool isInternalRedirect =
(redirectFlags & (nsIChannelEventSink::REDIRECT_INTERNAL |
nsIChannelEventSink::REDIRECT_STS_UPGRADE));
// nsBaseChannel hst no thing to do with HttpBaseChannel, we would not care
// about referrer and remote address in this case
nsCOMPtr<nsIRedirectHistoryEntry> entry =
new nsRedirectHistoryEntry(uriPrincipal, nullptr, EmptyCString());
// nsBaseChannel hst no thing to do with HttpBaseChannel, we would not care
// about referrer and remote address in this case
nsCOMPtr<nsIRedirectHistoryEntry> entry =
new nsRedirectHistoryEntry(uriPrincipal, nullptr, EmptyCString());
newLoadInfo->AppendRedirectHistoryEntry(entry, isInternalRedirect);
newLoadInfo->AppendRedirectHistoryEntry(entry, isInternalRedirect);
// Ensure the channel's loadInfo's result principal URI so that it's
// either non-null or updated to the redirect target URI.
// We must do this because in case the loadInfo's result principal URI
// is null, it would be taken from OriginalURI of the channel. But we
// overwrite it with the whole redirect chain first URI before opening
// the target channel, hence the information would be lost.
// If the protocol handler that created the channel wants to use
// the originalURI of the channel as the principal URI, it has left
// the result principal URI on the load info null.
nsCOMPtr<nsIURI> resultPrincipalURI;
// Ensure the channel's loadInfo's result principal URI so that it's
// either non-null or updated to the redirect target URI.
// We must do this because in case the loadInfo's result principal URI
// is null, it would be taken from OriginalURI of the channel. But we
// overwrite it with the whole redirect chain first URI before opening
// the target channel, hence the information would be lost.
// If the protocol handler that created the channel wants to use
// the originalURI of the channel as the principal URI, it has left
// the result principal URI on the load info null.
nsCOMPtr<nsIURI> resultPrincipalURI;
nsCOMPtr<nsILoadInfo> existingLoadInfo = newChannel->GetLoadInfo();
if (existingLoadInfo) {
existingLoadInfo->GetResultPrincipalURI(
getter_AddRefs(resultPrincipalURI));
}
if (!resultPrincipalURI) {
newChannel->GetOriginalURI(getter_AddRefs(resultPrincipalURI));
}
newLoadInfo->SetResultPrincipalURI(resultPrincipalURI);
newChannel->SetLoadInfo(newLoadInfo);
} else {
// the newChannel was created with a dummy loadInfo, we should clear
// it in case the original channel does not have a loadInfo
newChannel->SetLoadInfo(nullptr);
nsCOMPtr<nsILoadInfo> existingLoadInfo = newChannel->LoadInfo();
if (existingLoadInfo) {
existingLoadInfo->GetResultPrincipalURI(getter_AddRefs(resultPrincipalURI));
}
if (!resultPrincipalURI) {
newChannel->GetOriginalURI(getter_AddRefs(resultPrincipalURI));
}
newLoadInfo->SetResultPrincipalURI(resultPrincipalURI);
newChannel->SetLoadInfo(newLoadInfo);
// Preserve the privacy bit if it has been overridden
if (mPrivateBrowsingOverriden) {

View File

@ -356,11 +356,11 @@ interface nsIChannel : nsIRequest
return false;
}
inline already_AddRefed<nsILoadInfo> GetLoadInfo()
inline already_AddRefed<nsILoadInfo> LoadInfo()
{
nsCOMPtr<nsILoadInfo> result;
mozilla::DebugOnly<nsresult> rv = GetLoadInfo(getter_AddRefs(result));
MOZ_ASSERT(NS_SUCCEEDED(rv) || !result);
MOZ_ASSERT(NS_SUCCEEDED(rv) && result);
return result.forget();
}
%}

View File

@ -192,35 +192,33 @@ interface nsIInterceptedChannel : nsISupports
GetSubresourceTimeStampKey(nsIChannel* aChannel, nsACString& aKey)
{
if (!nsContentUtils::IsNonSubresourceRequest(aChannel)) {
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
if (loadInfo) {
switch(loadInfo->InternalContentPolicyType()) {
case nsIContentPolicy::TYPE_SCRIPT:
case nsIContentPolicy::TYPE_INTERNAL_SCRIPT:
case nsIContentPolicy::TYPE_INTERNAL_SCRIPT_PRELOAD:
case nsIContentPolicy::TYPE_INTERNAL_MODULE:
case nsIContentPolicy::TYPE_INTERNAL_MODULE_PRELOAD:
case nsIContentPolicy::TYPE_INTERNAL_WORKER_IMPORT_SCRIPTS: {
aKey = NS_LITERAL_CSTRING("subresource-script");
break;
}
case nsIContentPolicy::TYPE_IMAGE:
case nsIContentPolicy::TYPE_INTERNAL_IMAGE:
case nsIContentPolicy::TYPE_INTERNAL_IMAGE_PRELOAD:
case nsIContentPolicy::TYPE_INTERNAL_IMAGE_FAVICON: {
aKey = NS_LITERAL_CSTRING("subresource-image");
break;
}
case nsIContentPolicy::TYPE_STYLESHEET:
case nsIContentPolicy::TYPE_INTERNAL_STYLESHEET:
case nsIContentPolicy::TYPE_INTERNAL_STYLESHEET_PRELOAD: {
aKey = NS_LITERAL_CSTRING("subresource-stylesheet");
break;
}
default: {
aKey = NS_LITERAL_CSTRING("subresource-other");
break;
}
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
switch(loadInfo->InternalContentPolicyType()) {
case nsIContentPolicy::TYPE_SCRIPT:
case nsIContentPolicy::TYPE_INTERNAL_SCRIPT:
case nsIContentPolicy::TYPE_INTERNAL_SCRIPT_PRELOAD:
case nsIContentPolicy::TYPE_INTERNAL_MODULE:
case nsIContentPolicy::TYPE_INTERNAL_MODULE_PRELOAD:
case nsIContentPolicy::TYPE_INTERNAL_WORKER_IMPORT_SCRIPTS: {
aKey = NS_LITERAL_CSTRING("subresource-script");
break;
}
case nsIContentPolicy::TYPE_IMAGE:
case nsIContentPolicy::TYPE_INTERNAL_IMAGE:
case nsIContentPolicy::TYPE_INTERNAL_IMAGE_PRELOAD:
case nsIContentPolicy::TYPE_INTERNAL_IMAGE_FAVICON: {
aKey = NS_LITERAL_CSTRING("subresource-image");
break;
}
case nsIContentPolicy::TYPE_STYLESHEET:
case nsIContentPolicy::TYPE_INTERNAL_STYLESHEET:
case nsIContentPolicy::TYPE_INTERNAL_STYLESHEET_PRELOAD: {
aKey = NS_LITERAL_CSTRING("subresource-stylesheet");
break;
}
default: {
aKey = NS_LITERAL_CSTRING("subresource-other");
break;
}
}
}

View File

@ -898,7 +898,7 @@ nsresult nsIOService::NewChannelFromURIWithProxyFlagsInternal(
aLoadingNode, aSecurityFlags, aContentPolicyType,
aLoadingClientInfo, aController);
}
NS_ASSERTION(loadInfo, "Please pass security info when creating a channel");
MOZ_ASSERT(loadInfo, "Please pass security info when creating a channel");
return NewChannelFromURIWithProxyFlagsInternal(aURI, aProxyURI, aProxyFlags,
loadInfo, result);
}
@ -921,21 +921,13 @@ nsresult nsIOService::NewChannelFromURIWithProxyFlagsInternal(
rv = handler->DoGetProtocolFlags(aURI, &protoFlags);
if (NS_FAILED(rv)) return rv;
// Ideally we are creating new channels by calling NewChannel2
// (NewProxiedChannel2). Keep in mind that Addons can implement their own
// Protocolhandlers, hence NewChannel2() might *not* be implemented. We do not
// want to break those addons, therefore we first try to create a channel
// calling NewChannel2(); if that fails:
// * we fall back to creating a channel by calling NewChannel()
// * wrap the addon channel
// * and attach the loadInfo to the channel wrapper
nsCOMPtr<nsIChannel> channel;
nsCOMPtr<nsIProxiedProtocolHandler> pph = do_QueryInterface(handler);
if (pph) {
rv = pph->NewProxiedChannel2(aURI, nullptr, aProxyFlags, aProxyURI,
aLoadInfo, getter_AddRefs(channel));
} else {
rv = handler->NewChannel2(aURI, aLoadInfo, getter_AddRefs(channel));
rv = handler->NewChannel(aURI, aLoadInfo, getter_AddRefs(channel));
}
NS_ENSURE_SUCCESS(rv, rv);
@ -943,7 +935,7 @@ nsresult nsIOService::NewChannelFromURIWithProxyFlagsInternal(
if (aLoadInfo) {
// make sure we have the same instance of loadInfo on the newly created
// channel
nsCOMPtr<nsILoadInfo> loadInfo = channel->GetLoadInfo();
nsCOMPtr<nsILoadInfo> loadInfo = channel->LoadInfo();
if (aLoadInfo != loadInfo) {
MOZ_ASSERT(false, "newly created channel must have a loadinfo attached");
return NS_ERROR_UNEXPECTED;
@ -1717,11 +1709,8 @@ IOServiceProxyCallback::OnProxyAvailable(nsICancelable *request,
do_QueryInterface(handler);
if (!speculativeHandler) return NS_OK;
nsCOMPtr<nsILoadInfo> loadInfo = channel->GetLoadInfo();
nsCOMPtr<nsIPrincipal> principal;
if (loadInfo) {
principal = loadInfo->LoadingPrincipal();
}
nsCOMPtr<nsILoadInfo> loadInfo = channel->LoadInfo();
nsCOMPtr<nsIPrincipal> principal = loadInfo->LoadingPrincipal();
nsLoadFlags loadFlags = 0;
channel->GetLoadFlags(&loadFlags);

View File

@ -113,12 +113,7 @@ interface nsIProtocolHandler : nsISupports
* Constructs a new channel from the given URI for this protocol handler and
* sets the loadInfo for the constructed channel.
*/
nsIChannel newChannel2(in nsIURI aURI, in nsILoadInfo aLoadinfo);
/**
* Constructs a new channel from the given URI for this protocol handler.
*/
nsIChannel newChannel(in nsIURI aURI);
nsIChannel newChannel(in nsIURI aURI, in nsILoadInfo aLoadinfo);
/**
* Allows a protocol to override blacklisted ports.

View File

@ -232,10 +232,7 @@ nsresult NS_NewChannelInternal(
}
if (aPerformanceStorage) {
nsCOMPtr<nsILoadInfo> loadInfo;
rv = channel->GetLoadInfo(getter_AddRefs(loadInfo));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsILoadInfo> loadInfo = channel->LoadInfo();
loadInfo->SetPerformanceStorage(aPerformanceStorage);
}
@ -387,10 +384,7 @@ nsresult NS_NewChannelInternal(
}
if (aPerformanceStorage) {
nsCOMPtr<nsILoadInfo> loadInfo;
rv = channel->GetLoadInfo(getter_AddRefs(loadInfo));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsILoadInfo> loadInfo = channel->LoadInfo();
loadInfo->SetPerformanceStorage(aPerformanceStorage);
}
@ -646,6 +640,7 @@ nsresult NS_NewInputStreamChannelInternal(
NS_ENSURE_SUCCESS(rv, rv);
}
MOZ_ASSERT(aLoadInfo, "need a loadinfo to create a inputstreamchannel");
channel->SetLoadInfo(aLoadInfo);
// If we're sandboxed, make sure to clear any owner the channel
@ -1703,12 +1698,8 @@ bool NS_UsePrivateBrowsing(nsIChannel *channel) {
bool NS_GetOriginAttributes(nsIChannel *aChannel,
mozilla::OriginAttributes &aAttributes) {
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
// For some channels, they might not have loadInfo, like
// ExternalHelperAppParent..
if (loadInfo) {
loadInfo->GetOriginAttributes(&aAttributes);
}
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
loadInfo->GetOriginAttributes(&aAttributes);
bool isPrivate = false;
nsCOMPtr<nsIPrivateBrowsingChannel> pbChannel = do_QueryInterface(aChannel);
@ -1726,15 +1717,7 @@ bool NS_GetOriginAttributes(nsIChannel *aChannel,
}
bool NS_HasBeenCrossOrigin(nsIChannel *aChannel, bool aReport) {
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
MOZ_RELEASE_ASSERT(
loadInfo,
"Origin tracking only works for channels created with a loadinfo");
if (!loadInfo) {
return false;
}
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
// TYPE_DOCUMENT loads have a null LoadingPrincipal and can not be cross
// origin.
if (!loadInfo->LoadingPrincipal()) {
@ -1795,10 +1778,7 @@ bool NS_IsSafeTopLevelNav(nsIChannel *aChannel) {
if (!aChannel) {
return false;
}
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
if (!loadInfo) {
return false;
}
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
if (loadInfo->GetExternalContentPolicyType() !=
nsIContentPolicy::TYPE_DOCUMENT) {
return false;
@ -1818,11 +1798,7 @@ bool NS_IsSameSiteForeign(nsIChannel *aChannel, nsIURI *aHostURI) {
if (!aChannel) {
return false;
}
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
if (!loadInfo) {
return false;
}
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
// Do not treat loads triggered by web extensions as foreign
nsCOMPtr<nsIURI> channelURI;
NS_GetFinalChannelURI(aChannel, getter_AddRefs(channelURI));
@ -2024,16 +2000,13 @@ already_AddRefed<nsIURI> NS_GetInnermostURI(nsIURI *aURI) {
nsresult NS_GetFinalChannelURI(nsIChannel *channel, nsIURI **uri) {
*uri = nullptr;
nsCOMPtr<nsILoadInfo> loadInfo = channel->GetLoadInfo();
if (loadInfo) {
nsCOMPtr<nsIURI> resultPrincipalURI;
loadInfo->GetResultPrincipalURI(getter_AddRefs(resultPrincipalURI));
if (resultPrincipalURI) {
resultPrincipalURI.forget(uri);
return NS_OK;
}
nsCOMPtr<nsILoadInfo> loadInfo = channel->LoadInfo();
nsCOMPtr<nsIURI> resultPrincipalURI;
loadInfo->GetResultPrincipalURI(getter_AddRefs(resultPrincipalURI));
if (resultPrincipalURI) {
resultPrincipalURI.forget(uri);
return NS_OK;
}
return channel->GetOriginalURI(uri);
}
@ -2359,13 +2332,13 @@ nsresult NS_LinkRedirectChannels(uint32_t channelId,
nsresult NS_MaybeOpenChannelUsingOpen(nsIChannel *aChannel,
nsIInputStream **aStream) {
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
return aChannel->Open(aStream);
}
nsresult NS_MaybeOpenChannelUsingAsyncOpen(nsIChannel *aChannel,
nsIStreamListener *aListener) {
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
return aChannel->AsyncOpen(aListener);
}
@ -2688,12 +2661,11 @@ nsresult NS_GetSecureUpgradedURI(nsIURI *aURI, nsIURI **aUpgradedURI) {
}
nsresult NS_CompareLoadInfoAndLoadContext(nsIChannel *aChannel) {
nsCOMPtr<nsILoadInfo> loadInfo;
aChannel->GetLoadInfo(getter_AddRefs(loadInfo));
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
nsCOMPtr<nsILoadContext> loadContext;
NS_QueryNotificationCallbacks(aChannel, loadContext);
if (!loadInfo || !loadContext) {
if (!loadContext) {
return NS_OK;
}

View File

@ -176,11 +176,8 @@ void CookieServiceChild::TrackCookieLoad(nsIChannel *aChannel) {
rejectedReason);
}
}
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
mozilla::OriginAttributes attrs;
if (loadInfo) {
attrs = loadInfo->GetOriginAttributes();
}
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
mozilla::OriginAttributes attrs = loadInfo->GetOriginAttributes();
URIParams uriParams;
SerializeURI(uri, uriParams);
bool isSafeTopLevelNav = NS_IsSafeTopLevelNav(aChannel);
@ -484,10 +481,8 @@ nsresult CookieServiceChild::GetCookieStringInternal(nsIURI *aHostURI,
nsCOMPtr<nsILoadInfo> loadInfo;
mozilla::OriginAttributes attrs;
if (aChannel) {
loadInfo = aChannel->GetLoadInfo();
if (loadInfo) {
attrs = loadInfo->GetOriginAttributes();
}
loadInfo = aChannel->LoadInfo();
attrs = loadInfo->GetOriginAttributes();
}
// Asynchronously call the parent.
@ -569,10 +564,8 @@ nsresult CookieServiceChild::SetCookieStringInternal(nsIURI *aHostURI,
aChannel->GetURI(getter_AddRefs(channelURI));
SerializeURI(channelURI, channelURIParams);
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
if (loadInfo) {
attrs = loadInfo->GetOriginAttributes();
}
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
attrs = loadInfo->GetOriginAttributes();
} else {
SerializeURI(nullptr, channelURIParams);
}

View File

@ -132,11 +132,8 @@ void CookieServiceParent::TrackCookieLoad(nsIChannel *aChannel) {
nsCOMPtr<nsIURI> uri;
aChannel->GetURI(getter_AddRefs(uri));
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
mozilla::OriginAttributes attrs;
if (loadInfo) {
attrs = loadInfo->GetOriginAttributes();
}
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
mozilla::OriginAttributes attrs = loadInfo->GetOriginAttributes();
bool isSafeTopLevelNav = NS_IsSafeTopLevelNav(aChannel);
bool aIsSameSiteForeign = NS_IsSameSiteForeign(aChannel, uri);

View File

@ -3390,10 +3390,9 @@ bool nsCookieService::CanSetCookie(nsIURI *aHostURI, const nsCookieKey &aKey,
if (aChannel) {
nsCOMPtr<nsIURI> channelURI;
NS_GetFinalChannelURI(aChannel, getter_AddRefs(channelURI));
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
addonAllowsLoad =
loadInfo && BasePrincipal::Cast(loadInfo->TriggeringPrincipal())
->AddonAllowsLoad(channelURI);
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
addonAllowsLoad = BasePrincipal::Cast(loadInfo->TriggeringPrincipal())
->AddonAllowsLoad(channelURI);
}
if (!addonAllowsLoad) {

View File

@ -186,11 +186,7 @@ bool ChannelEventQueue::MaybeSuspendIfEventsAreSuppressed() {
return false;
}
nsCOMPtr<nsILoadInfo> loadInfo = channel->GetLoadInfo();
if (!loadInfo) {
return false;
}
nsCOMPtr<nsILoadInfo> loadInfo = channel->LoadInfo();
// Figure out if this is for an XHR, if we haven't done so already.
if (!mHasCheckedForXMLHttpRequest) {
nsContentPolicyType contentType = loadInfo->InternalContentPolicyType();

View File

@ -159,8 +159,8 @@ nsAboutProtocolHandler::NewURI(const nsACString &aSpec,
}
NS_IMETHODIMP
nsAboutProtocolHandler::NewChannel2(nsIURI *uri, nsILoadInfo *aLoadInfo,
nsIChannel **result) {
nsAboutProtocolHandler::NewChannel(nsIURI *uri, nsILoadInfo *aLoadInfo,
nsIChannel **result) {
NS_ENSURE_ARG_POINTER(uri);
// about:what you ask?
@ -204,22 +204,20 @@ nsAboutProtocolHandler::NewChannel2(nsIURI *uri, nsILoadInfo *aLoadInfo,
// set the LoadInfo on the newly created channel yet, as
// an interim solution we set the LoadInfo here if not
// available on the channel. Bug 1087720
nsCOMPtr<nsILoadInfo> loadInfo = (*result)->GetLoadInfo();
nsCOMPtr<nsILoadInfo> loadInfo = (*result)->LoadInfo();
if (aLoadInfo != loadInfo) {
if (loadInfo) {
NS_ASSERTION(false,
"nsIAboutModule->newChannel(aURI, aLoadInfo) needs to "
"set LoadInfo");
const char16_t *params[] = {
u"nsIAboutModule->newChannel(aURI)",
u"nsIAboutModule->newChannel(aURI, aLoadInfo)"};
nsContentUtils::ReportToConsole(
nsIScriptError::warningFlag,
NS_LITERAL_CSTRING("Security by Default"),
nullptr, // aDocument
nsContentUtils::eNECKO_PROPERTIES, "APIDeprecationWarning",
params, mozilla::ArrayLength(params));
}
NS_ASSERTION(false,
"nsIAboutModule->newChannel(aURI, aLoadInfo) needs to "
"set LoadInfo");
const char16_t *params[] = {
u"nsIAboutModule->newChannel(aURI)",
u"nsIAboutModule->newChannel(aURI, aLoadInfo)"};
nsContentUtils::ReportToConsole(
nsIScriptError::warningFlag,
NS_LITERAL_CSTRING("Security by Default"),
nullptr, // aDocument
nsContentUtils::eNECKO_PROPERTIES, "APIDeprecationWarning", params,
mozilla::ArrayLength(params));
(*result)->SetLoadInfo(aLoadInfo);
}
@ -261,11 +259,6 @@ nsAboutProtocolHandler::NewChannel2(nsIURI *uri, nsILoadInfo *aLoadInfo,
return rv;
}
NS_IMETHODIMP
nsAboutProtocolHandler::NewChannel(nsIURI *uri, nsIChannel **result) {
return NewChannel2(uri, nullptr, result);
}
NS_IMETHODIMP
nsAboutProtocolHandler::AllowPort(int32_t port, const char *scheme,
bool *_retval) {
@ -315,14 +308,8 @@ nsSafeAboutProtocolHandler::NewURI(const nsACString &aSpec,
}
NS_IMETHODIMP
nsSafeAboutProtocolHandler::NewChannel2(nsIURI *uri, nsILoadInfo *aLoadInfo,
nsIChannel **result) {
*result = nullptr;
return NS_ERROR_NOT_AVAILABLE;
}
NS_IMETHODIMP
nsSafeAboutProtocolHandler::NewChannel(nsIURI *uri, nsIChannel **result) {
nsSafeAboutProtocolHandler::NewChannel(nsIURI *uri, nsILoadInfo *aLoadInfo,
nsIChannel **result) {
*result = nullptr;
return NS_ERROR_NOT_AVAILABLE;
}

View File

@ -94,8 +94,8 @@ nsDataHandler::NewURI(const nsACString& aSpec,
}
NS_IMETHODIMP
nsDataHandler::NewChannel2(nsIURI* uri, nsILoadInfo* aLoadInfo,
nsIChannel** result) {
nsDataHandler::NewChannel(nsIURI* uri, nsILoadInfo* aLoadInfo,
nsIChannel** result) {
NS_ENSURE_ARG_POINTER(uri);
nsDataChannel* channel;
if (XRE_IsParentProcess()) {
@ -122,11 +122,6 @@ nsDataHandler::NewChannel2(nsIURI* uri, nsILoadInfo* aLoadInfo,
return NS_OK;
}
NS_IMETHODIMP
nsDataHandler::NewChannel(nsIURI* uri, nsIChannel** result) {
return NewChannel2(uri, nullptr, result);
}
NS_IMETHODIMP
nsDataHandler::AllowPort(int32_t port, const char* scheme, bool* _retval) {
// don't override anything.

View File

@ -164,8 +164,8 @@ nsFileProtocolHandler::NewURI(const nsACString &spec, const char *charset,
}
NS_IMETHODIMP
nsFileProtocolHandler::NewChannel2(nsIURI *uri, nsILoadInfo *aLoadInfo,
nsIChannel **result) {
nsFileProtocolHandler::NewChannel(nsIURI *uri, nsILoadInfo *aLoadInfo,
nsIChannel **result) {
nsresult rv;
nsFileChannel *chan;
@ -196,11 +196,6 @@ nsFileProtocolHandler::NewChannel2(nsIURI *uri, nsILoadInfo *aLoadInfo,
return NS_OK;
}
NS_IMETHODIMP
nsFileProtocolHandler::NewChannel(nsIURI *uri, nsIChannel **result) {
return NewChannel2(uri, nullptr, result);
}
NS_IMETHODIMP
nsFileProtocolHandler::AllowPort(int32_t port, const char *scheme,
bool *result) {

View File

@ -171,16 +171,11 @@ nsFtpProtocolHandler::NewURI(const nsACString &aSpec, const char *aCharset,
}
NS_IMETHODIMP
nsFtpProtocolHandler::NewChannel2(nsIURI *url, nsILoadInfo *aLoadInfo,
nsIChannel **result) {
nsFtpProtocolHandler::NewChannel(nsIURI *url, nsILoadInfo *aLoadInfo,
nsIChannel **result) {
return NewProxiedChannel2(url, nullptr, 0, nullptr, aLoadInfo, result);
}
NS_IMETHODIMP
nsFtpProtocolHandler::NewChannel(nsIURI *url, nsIChannel **result) {
return NewChannel2(url, nullptr, result);
}
NS_IMETHODIMP
nsFtpProtocolHandler::NewProxiedChannel2(nsIURI *uri, nsIProxyInfo *proxyInfo,
uint32_t proxyResolveFlags,

View File

@ -965,8 +965,8 @@ nsGIOProtocolHandler::NewURI(const nsACString &aSpec,
}
NS_IMETHODIMP
nsGIOProtocolHandler::NewChannel2(nsIURI *aURI, nsILoadInfo *aLoadInfo,
nsIChannel **aResult) {
nsGIOProtocolHandler::NewChannel(nsIURI *aURI, nsILoadInfo *aLoadInfo,
nsIChannel **aResult) {
NS_ENSURE_ARG_POINTER(aURI);
nsresult rv;
@ -991,11 +991,6 @@ nsGIOProtocolHandler::NewChannel2(nsIURI *aURI, nsILoadInfo *aLoadInfo,
return rv;
}
NS_IMETHODIMP
nsGIOProtocolHandler::NewChannel(nsIURI *aURI, nsIChannel **aResult) {
return NewChannel2(aURI, nullptr, aResult);
}
NS_IMETHODIMP
nsGIOProtocolHandler::AllowPort(int32_t aPort, const char *aScheme,
bool *aResult) {

View File

@ -2581,9 +2581,6 @@ nsresult HttpBaseChannel::AddSecurityMessage(
nsCOMPtr<nsILoadInfo> loadInfo;
GetLoadInfo(getter_AddRefs(loadInfo));
if (!loadInfo) {
return NS_ERROR_FAILURE;
}
auto innerWindowID = loadInfo->GetInnerWindowID();
@ -3440,16 +3437,13 @@ nsresult HttpBaseChannel::SetupReplacementChannel(nsIURI* newURI,
// If the protocol handler that created the channel wants to use
// the originalURI of the channel as the principal URI, this fulfills
// that request - newURI is the original URI of the channel.
nsCOMPtr<nsILoadInfo> newLoadInfo = newChannel->GetLoadInfo();
if (newLoadInfo) {
nsCOMPtr<nsIURI> resultPrincipalURI;
rv = newLoadInfo->GetResultPrincipalURI(getter_AddRefs(resultPrincipalURI));
nsCOMPtr<nsILoadInfo> newLoadInfo = newChannel->LoadInfo();
nsCOMPtr<nsIURI> resultPrincipalURI;
rv = newLoadInfo->GetResultPrincipalURI(getter_AddRefs(resultPrincipalURI));
NS_ENSURE_SUCCESS(rv, rv);
if (!resultPrincipalURI) {
rv = newLoadInfo->SetResultPrincipalURI(newURI);
NS_ENSURE_SUCCESS(rv, rv);
if (!resultPrincipalURI) {
rv = newLoadInfo->SetResultPrincipalURI(newURI);
NS_ENSURE_SUCCESS(rv, rv);
}
}
uint32_t newLoadFlags = mLoadFlags | LOAD_REPLACE;

View File

@ -445,10 +445,6 @@ bool HttpChannelParent::DoAsyncOpen(
return SendFailedAsyncOpen(rv);
}
if (!loadInfo) {
return SendFailedAsyncOpen(NS_ERROR_UNEXPECTED);
}
nsCOMPtr<nsIChannel> channel;
rv = NS_NewChannelInternal(getter_AddRefs(channel), uri, loadInfo, nullptr,
nullptr, nullptr, aLoadFlags, ios);

View File

@ -32,11 +32,7 @@ namespace net {
nsresult topWindowURIResult =
httpChannelInternal->GetTopWindowURI(getter_AddRefs(topWindowURI));
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
if (!loadInfo) {
return false;
}
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
OptionalLoadInfoArgs loadInfoArgs;
mozilla::ipc::LoadInfoToLoadInfoArgs(loadInfo, &loadInfoArgs);

View File

@ -532,8 +532,8 @@ nsresult nsCORSListenerProxy::CheckRequestApproved(nsIRequest* aRequest) {
return NS_ERROR_DOM_BAD_URI;
}
nsCOMPtr<nsILoadInfo> loadInfo = http->GetLoadInfo();
if (loadInfo && loadInfo->GetServiceWorkerTaintingSynthesized()) {
nsCOMPtr<nsILoadInfo> loadInfo = http->LoadInfo();
if (loadInfo->GetServiceWorkerTaintingSynthesized()) {
// For synthesized responses, we don't need to perform any checks.
// Note: This would be unsafe if we ever changed our behavior to allow
// service workers to intercept CORS preflights.
@ -842,14 +842,7 @@ bool CheckUpgradeInsecureRequestsPreventsCORS(
return false;
}
nsCOMPtr<nsILoadInfo> loadInfo;
rv = aChannel->GetLoadInfo(getter_AddRefs(loadInfo));
NS_ENSURE_SUCCESS(rv, false);
if (!loadInfo) {
return false;
}
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
// lets see if the loadInfo indicates that the request will
// be upgraded before fetching any data from the netwerk.
return loadInfo->GetUpgradeInsecureRequests() ||
@ -865,7 +858,7 @@ nsresult nsCORSListenerProxy::UpdateChannel(nsIChannel* aChannel,
rv = aChannel->GetOriginalURI(getter_AddRefs(originalURI));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
// exempt data URIs from the same origin check.
if (aAllowDataURI == DataURIHandling::Allow && originalURI == uri) {
@ -875,7 +868,7 @@ nsresult nsCORSListenerProxy::UpdateChannel(nsIChannel* aChannel,
if (dataScheme) {
return NS_OK;
}
if (loadInfo && loadInfo->GetAboutBlankInherits() && NS_IsAboutBlank(uri)) {
if (loadInfo->GetAboutBlankInherits() && NS_IsAboutBlank(uri)) {
return NS_OK;
}
}
@ -1001,9 +994,8 @@ nsresult nsCORSListenerProxy::CheckPreflightNeeded(nsIChannel* aChannel,
UpdateType aUpdateType) {
// If this caller isn't using AsyncOpen, or if this *is* a preflight channel,
// then we shouldn't initiate preflight for this channel.
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
if (!loadInfo ||
loadInfo->GetSecurityMode() !=
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
if (loadInfo->GetSecurityMode() !=
nsILoadInfo::SEC_REQUIRE_CORS_DATA_INHERITS ||
loadInfo->GetIsPreflight()) {
return NS_OK;
@ -1223,7 +1215,7 @@ nsCORSPreflightListener::OnStartRequest(nsIRequest* aRequest,
#ifdef DEBUG
{
nsCOMPtr<nsIChannel> channel = do_QueryInterface(aRequest);
nsCOMPtr<nsILoadInfo> loadInfo = channel ? channel->GetLoadInfo() : nullptr;
nsCOMPtr<nsILoadInfo> loadInfo = channel ? channel->LoadInfo() : nullptr;
MOZ_ASSERT(!loadInfo || !loadInfo->GetServiceWorkerTaintingSynthesized());
}
#endif
@ -1398,13 +1390,7 @@ nsresult nsCORSListenerProxy::StartCORSPreflight(
nsresult rv = NS_GetFinalChannelURI(aRequestChannel, getter_AddRefs(uri));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsILoadInfo> originalLoadInfo = aRequestChannel->GetLoadInfo();
MOZ_ASSERT(originalLoadInfo,
"can not perform CORS preflight without a loadInfo");
if (!originalLoadInfo) {
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsILoadInfo> originalLoadInfo = aRequestChannel->LoadInfo();
MOZ_ASSERT(originalLoadInfo->GetSecurityMode() ==
nsILoadInfo::SEC_REQUIRE_CORS_DATA_INHERITS,
"how did we end up here?");

View File

@ -3668,7 +3668,7 @@ nsresult nsHttpChannel::ProcessFallback(bool *waitingForRedirectCallback) {
// Create a new channel to load the fallback entry.
RefPtr<nsIChannel> newChannel;
rv = gHttpHandler->NewChannel2(mURI, mLoadInfo, getter_AddRefs(newChannel));
rv = gHttpHandler->NewChannel(mURI, mLoadInfo, getter_AddRefs(newChannel));
NS_ENSURE_SUCCESS(rv, rv);
uint32_t redirectFlags = nsIChannelEventSink::REDIRECT_INTERNAL;

View File

@ -899,47 +899,44 @@ bool nsHttpChannelAuthProvider::BlockPrompt(bool proxyAuth) {
}
nsCOMPtr<nsIChannel> chan = do_QueryInterface(mAuthChannel);
nsCOMPtr<nsILoadInfo> loadInfo;
chan->GetLoadInfo(getter_AddRefs(loadInfo));
nsCOMPtr<nsILoadInfo> loadInfo = chan->LoadInfo();
// We will treat loads w/o loadInfo as a top level document.
bool topDoc = true;
bool xhr = false;
bool nonWebContent = false;
if (loadInfo) {
if (loadInfo->GetExternalContentPolicyType() !=
nsIContentPolicy::TYPE_DOCUMENT) {
topDoc = false;
}
if (loadInfo->GetExternalContentPolicyType() !=
nsIContentPolicy::TYPE_DOCUMENT) {
topDoc = false;
}
if (!topDoc) {
nsCOMPtr<nsIPrincipal> triggeringPrinc = loadInfo->TriggeringPrincipal();
if (nsContentUtils::IsSystemPrincipal(triggeringPrinc)) {
nonWebContent = true;
if (!topDoc) {
nsCOMPtr<nsIPrincipal> triggeringPrinc = loadInfo->TriggeringPrincipal();
if (nsContentUtils::IsSystemPrincipal(triggeringPrinc)) {
nonWebContent = true;
}
}
if (loadInfo->GetExternalContentPolicyType() ==
nsIContentPolicy::TYPE_XMLHTTPREQUEST) {
xhr = true;
}
if (!topDoc && !xhr) {
nsCOMPtr<nsIURI> topURI;
Unused << chanInternal->GetTopWindowURI(getter_AddRefs(topURI));
if (!topURI) {
// If we do not have topURI try the loadingPrincipal.
nsCOMPtr<nsIPrincipal> loadingPrinc = loadInfo->LoadingPrincipal();
if (loadingPrinc) {
loadingPrinc->GetURI(getter_AddRefs(topURI));
}
}
if (loadInfo->GetExternalContentPolicyType() ==
nsIContentPolicy::TYPE_XMLHTTPREQUEST) {
xhr = true;
}
if (!topDoc && !xhr) {
nsCOMPtr<nsIURI> topURI;
Unused << chanInternal->GetTopWindowURI(getter_AddRefs(topURI));
if (!topURI) {
// If we do not have topURI try the loadingPrincipal.
nsCOMPtr<nsIPrincipal> loadingPrinc = loadInfo->LoadingPrincipal();
if (loadingPrinc) {
loadingPrinc->GetURI(getter_AddRefs(topURI));
}
}
if (!NS_SecurityCompareURIs(topURI, mURI, true)) {
mCrossOrigin = true;
}
if (!NS_SecurityCompareURIs(topURI, mURI, true)) {
mCrossOrigin = true;
}
}

View File

@ -2026,8 +2026,8 @@ nsHttpHandler::NewURI(const nsACString &aSpec, const char *aCharset,
}
NS_IMETHODIMP
nsHttpHandler::NewChannel2(nsIURI *uri, nsILoadInfo *aLoadInfo,
nsIChannel **result) {
nsHttpHandler::NewChannel(nsIURI *uri, nsILoadInfo *aLoadInfo,
nsIChannel **result) {
LOG(("nsHttpHandler::NewChannel\n"));
NS_ENSURE_ARG_POINTER(uri);
@ -2050,11 +2050,6 @@ nsHttpHandler::NewChannel2(nsIURI *uri, nsILoadInfo *aLoadInfo,
return NewProxiedChannel2(uri, nullptr, 0, nullptr, aLoadInfo, result);
}
NS_IMETHODIMP
nsHttpHandler::NewChannel(nsIURI *uri, nsIChannel **result) {
return NewChannel2(uri, nullptr, result);
}
NS_IMETHODIMP
nsHttpHandler::AllowPort(int32_t port, const char *scheme, bool *_retval) {
// don't override anything.
@ -2563,16 +2558,11 @@ nsHttpsHandler::NewURI(const nsACString &aSpec, const char *aOriginCharset,
}
NS_IMETHODIMP
nsHttpsHandler::NewChannel2(nsIURI *aURI, nsILoadInfo *aLoadInfo,
nsIChannel **_retval) {
nsHttpsHandler::NewChannel(nsIURI *aURI, nsILoadInfo *aLoadInfo,
nsIChannel **_retval) {
MOZ_ASSERT(gHttpHandler);
if (!gHttpHandler) return NS_ERROR_UNEXPECTED;
return gHttpHandler->NewChannel2(aURI, aLoadInfo, _retval);
}
NS_IMETHODIMP
nsHttpsHandler::NewChannel(nsIURI *aURI, nsIChannel **_retval) {
return NewChannel2(aURI, nullptr, _retval);
return gHttpHandler->NewChannel(aURI, aLoadInfo, _retval);
}
NS_IMETHODIMP

View File

@ -226,9 +226,9 @@ nsresult SubstitutingProtocolHandler::NewURI(const nsACString& aSpec,
.Finalize(result);
}
nsresult SubstitutingProtocolHandler::NewChannel2(nsIURI* uri,
nsILoadInfo* aLoadInfo,
nsIChannel** result) {
nsresult SubstitutingProtocolHandler::NewChannel(nsIURI* uri,
nsILoadInfo* aLoadInfo,
nsIChannel** result) {
NS_ENSURE_ARG_POINTER(uri);
NS_ENSURE_ARG_POINTER(aLoadInfo);
@ -259,11 +259,6 @@ nsresult SubstitutingProtocolHandler::NewChannel2(nsIURI* uri,
return SubstituteChannel(uri, aLoadInfo, result);
}
nsresult SubstitutingProtocolHandler::NewChannel(nsIURI* uri,
nsIChannel** result) {
return NewChannel2(uri, nullptr, result);
}
nsresult SubstitutingProtocolHandler::AllowPort(int32_t port,
const char* scheme,
bool* _retval) {

View File

@ -136,11 +136,7 @@ nsresult nsViewSourceChannel::UpdateLoadInfoResultPrincipalURI() {
MOZ_ASSERT(mChannel);
nsCOMPtr<nsILoadInfo> channelLoadInfo = mChannel->GetLoadInfo();
if (!channelLoadInfo) {
return NS_OK;
}
nsCOMPtr<nsILoadInfo> channelLoadInfo = mChannel->LoadInfo();
nsCOMPtr<nsIURI> channelResultPrincipalURI;
rv = channelLoadInfo->GetResultPrincipalURI(
getter_AddRefs(channelResultPrincipalURI));
@ -290,21 +286,11 @@ nsViewSourceChannel::GetURI(nsIURI **aURI) {
NS_IMETHODIMP
nsViewSourceChannel::Open(nsIInputStream **aStream) {
NS_ENSURE_TRUE(mChannel, NS_ERROR_FAILURE);
nsCOMPtr<nsILoadInfo> loadInfo = mChannel->GetLoadInfo();
if (!loadInfo) {
MOZ_ASSERT(loadInfo, "can not enforce security without loadInfo");
return NS_ERROR_UNEXPECTED;
}
return Open(aStream);
}
NS_IMETHODIMP
nsViewSourceChannel::AsyncOpen(nsIStreamListener *aListener) {
nsCOMPtr<nsILoadInfo> loadInfo = mChannel->GetLoadInfo();
if (!loadInfo) {
MOZ_ASSERT(loadInfo, "can not enforce security without loadInfo");
return NS_ERROR_UNEXPECTED;
}
// We can't ensure GetInitialSecurityCheckDone here
NS_ENSURE_TRUE(mChannel, NS_ERROR_FAILURE);

View File

@ -102,8 +102,8 @@ nsViewSourceHandler::NewURI(const nsACString &aSpec, const char *aCharset,
}
NS_IMETHODIMP
nsViewSourceHandler::NewChannel2(nsIURI *uri, nsILoadInfo *aLoadInfo,
nsIChannel **result) {
nsViewSourceHandler::NewChannel(nsIURI *uri, nsILoadInfo *aLoadInfo,
nsIChannel **result) {
NS_ENSURE_ARG_POINTER(uri);
nsViewSourceChannel *channel = new nsViewSourceChannel();
if (!channel) return NS_ERROR_OUT_OF_MEMORY;
@ -126,11 +126,6 @@ nsViewSourceHandler::NewChannel2(nsIURI *uri, nsILoadInfo *aLoadInfo,
return NS_OK;
}
NS_IMETHODIMP
nsViewSourceHandler::NewChannel(nsIURI *uri, nsIChannel **result) {
return NewChannel2(uri, nullptr, result);
}
nsresult nsViewSourceHandler::NewSrcdocChannel(nsIURI *aURI, nsIURI *aBaseURI,
const nsAString &aSrcdoc,
nsILoadInfo *aLoadInfo,

View File

@ -293,14 +293,8 @@ BaseWebSocketChannel::NewURI(const nsACString &aSpec,
}
NS_IMETHODIMP
BaseWebSocketChannel::NewChannel2(nsIURI *aURI, nsILoadInfo *aLoadInfo,
nsIChannel **outChannel) {
LOG(("BaseWebSocketChannel::NewChannel2() %p\n", this));
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
BaseWebSocketChannel::NewChannel(nsIURI *aURI, nsIChannel **_retval) {
BaseWebSocketChannel::NewChannel(nsIURI *aURI, nsILoadInfo *aLoadInfo,
nsIChannel **outChannel) {
LOG(("BaseWebSocketChannel::NewChannel() %p\n", this));
return NS_ERROR_NOT_IMPLEMENTED;
}

View File

@ -111,10 +111,8 @@ mozilla::ipc::IPCResult WyciwygChannelParent::RecvInit(
return IPC_OK();
}
nsCOMPtr<nsILoadInfo> loadInfo = chan->GetLoadInfo();
if (loadInfo) {
rv = loadInfo->SetPrincipalToInherit(principalToInherit);
}
nsCOMPtr<nsILoadInfo> loadInfo = chan->LoadInfo();
rv = loadInfo->SetPrincipalToInherit(principalToInherit);
if (NS_FAILED(rv)) {
if (!SendCancelEarly(rv)) {
return IPC_FAIL_NO_REASON(this);
@ -212,7 +210,7 @@ mozilla::ipc::IPCResult WyciwygChannelParent::RecvAsyncOpen(
return IPC_OK();
}
nsCOMPtr<nsILoadInfo> loadInfo = mChannel->GetLoadInfo();
nsCOMPtr<nsILoadInfo> loadInfo = mChannel->LoadInfo();
rv = mChannel->AsyncOpen(this);
if (NS_FAILED(rv)) {

View File

@ -66,8 +66,8 @@ nsWyciwygProtocolHandler::NewURI(const nsACString &aSpec,
}
NS_IMETHODIMP
nsWyciwygProtocolHandler::NewChannel2(nsIURI *url, nsILoadInfo *aLoadInfo,
nsIChannel **result) {
nsWyciwygProtocolHandler::NewChannel(nsIURI *url, nsILoadInfo *aLoadInfo,
nsIChannel **result) {
if (mozilla::net::IsNeckoChild()) mozilla::net::NeckoChild::InitNeckoChild();
NS_ENSURE_ARG_POINTER(url);
@ -120,11 +120,6 @@ nsWyciwygProtocolHandler::NewChannel2(nsIURI *url, nsILoadInfo *aLoadInfo,
return NS_OK;
}
NS_IMETHODIMP
nsWyciwygProtocolHandler::NewChannel(nsIURI *url, nsIChannel **result) {
return NewChannel2(url, nullptr, result);
}
NS_IMETHODIMP
nsWyciwygProtocolHandler::GetProtocolFlags(uint32_t *result) {
// Should this be an an nsINestedURI? We don't really want random webpages

View File

@ -37,12 +37,9 @@ CustomProtocolHandler.prototype = {
.setSpec(aSpec)
.finalize()
},
newChannel2: function(aURI, aLoadInfo) {
newChannel: function(aURI, aLoadInfo) {
return new CustomChannel(aURI, aLoadInfo);
},
newChannel: function(aURI) {
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
},
allowPort: function(port, scheme) {
return port != -1;
},

View File

@ -34,13 +34,10 @@ ProtocolHandler.prototype = {
newURI: function(aSpec, aOriginCharset, aBaseURI) {
return this.uri;
},
newChannel2: function(aURI, aLoadInfo) {
newChannel: function(aURI, aLoadInfo) {
this.loadInfo = aLoadInfo;
return this;
},
newChannel: function(aURI) {
return this;
},
allowPort: function(port, scheme) {
return port != -1;
},

Some files were not shown because too many files have changed in this diff Show More