diff --git a/build/clang-plugin/tests/moz.build b/build/clang-plugin/tests/moz.build index b0c72132f79a..98bc24f61a45 100644 --- a/build/clang-plugin/tests/moz.build +++ b/build/clang-plugin/tests/moz.build @@ -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 diff --git a/caps/nsScriptSecurityManager.cpp b/caps/nsScriptSecurityManager.cpp index 2b91c73cccfd..078b87df059c 100644 --- a/caps/nsScriptSecurityManager.cpp +++ b/caps/nsScriptSecurityManager.cpp @@ -253,9 +253,9 @@ static void InheritAndSetCSPOnPrincipalIfNeeded(nsIChannel* aChannel, return; } - nsCOMPtr loadInfo = aChannel->GetLoadInfo(); - if (!loadInfo || loadInfo->GetExternalContentPolicyType() != - nsIContentPolicy::TYPE_SUBDOCUMENT) { + nsCOMPtr 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 loadInfo = aChannel->GetLoadInfo(); - if (loadInfo && loadInfo->GetForceInheritPrincipalOverruleOwner()) { + nsCOMPtr loadInfo = aChannel->LoadInfo(); + if (loadInfo->GetForceInheritPrincipalOverruleOwner()) { nsCOMPtr principalToInherit = loadInfo->FindPrincipalToInherit(aChannel); principalToInherit.forget(aPrincipal); @@ -319,53 +319,51 @@ nsresult nsScriptSecurityManager::GetChannelResultPrincipal( } } - if (loadInfo) { - if (!aIgnoreSandboxing && loadInfo->GetLoadingSandboxed()) { - nsCOMPtr sandboxedLoadingPrincipal = - loadInfo->GetSandboxedLoadingPrincipal(); - MOZ_ASSERT(sandboxedLoadingPrincipal); - InheritAndSetCSPOnPrincipalIfNeeded(aChannel, sandboxedLoadingPrincipal); - sandboxedLoadingPrincipal.forget(aPrincipal); - return NS_OK; - } + if (!aIgnoreSandboxing && loadInfo->GetLoadingSandboxed()) { + nsCOMPtr 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 principalToInherit = - loadInfo->FindPrincipalToInherit(aChannel); + } + if (forceInherit) { + nsCOMPtr 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 uri; + nsresult rv = NS_GetFinalChannelURI(aChannel, getter_AddRefs(uri)); + NS_ENSURE_SUCCESS(rv, rv); + + nsCOMPtr 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 uri; - nsresult rv = NS_GetFinalChannelURI(aChannel, getter_AddRefs(uri)); - NS_ENSURE_SUCCESS(rv, rv); - - nsCOMPtr 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 loadInfo; - aChannel->GetLoadInfo(getter_AddRefs(loadInfo)); + nsCOMPtr 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 prin = BasePrincipal::CreateCodebasePrincipal(uri, attrs); diff --git a/chrome/nsChromeProtocolHandler.cpp b/chrome/nsChromeProtocolHandler.cpp index 4b564140334c..a1d3b353f185 100644 --- a/chrome/nsChromeProtocolHandler.cpp +++ b/chrome/nsChromeProtocolHandler.cpp @@ -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); -} - //////////////////////////////////////////////////////////////////////////////// diff --git a/chrome/test/unit/test_no_remote_registration.js b/chrome/test/unit/test_no_remote_registration.js index 78838c091783..d8c0bcd4ed7b 100644 --- a/chrome/test/unit/test_no_remote_registration.js +++ b/chrome/test/unit/test_no_remote_registration.js @@ -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, diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 80ca6d6951b5..0399ee6822d1 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -4576,10 +4576,8 @@ nsDocShell::Reload(uint32_t aReloadFlags) { httpChan->GetOriginalURI(getter_AddRefs(originalURI)); } - nsCOMPtr loadInfo = chan->GetLoadInfo(); - if (loadInfo) { - loadInfo->GetResultPrincipalURI(getter_AddRefs(resultPrincipalURI)); - } + nsCOMPtr 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 loadInfo = aChannel->GetLoadInfo(); + nsCOMPtr loadInfo = aChannel->LoadInfo(); MOZ_ASSERT(loadInfo, "loadInfo is required on all channels"); nsCOMPtr triggeringPrincipal = loadInfo->TriggeringPrincipal(); @@ -6902,10 +6900,8 @@ nsresult nsDocShell::EndPageLoad(nsIWebProgress* aProgress, } } else if (url && NS_SUCCEEDED(aStatus)) { // If we have a host - nsCOMPtr loadInfo = aChannel->GetLoadInfo(); - if (loadInfo) { - PredictorLearnRedirect(url, aChannel, loadInfo->GetOriginAttributes()); - } + nsCOMPtr 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 oldLoadInfo = - GetDocument()->GetChannel()->GetLoadInfo(); + nsCOMPtr oldLoadInfo = GetDocument()->GetChannel()->LoadInfo(); loadInfo->SetOpenerPolicy(oldLoadInfo->GetOpenerPolicy()); } @@ -11293,29 +11288,27 @@ nsresult nsDocShell::AddToSessionHistory(nsIURI* aURI, nsIChannel* aChannel, discardLayoutState = ShouldDiscardLayoutState(httpChannel); } - nsCOMPtr loadInfo = aChannel->GetLoadInfo(); - if (loadInfo) { - if (!triggeringPrincipal) { - triggeringPrincipal = loadInfo->TriggeringPrincipal(); - } + nsCOMPtr 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(); } } } diff --git a/docshell/base/nsDocShellLoadState.cpp b/docshell/base/nsDocShellLoadState.cpp index 657e3bd12408..e3ec88aff8e6 100644 --- a/docshell/base/nsDocShellLoadState.cpp +++ b/docshell/base/nsDocShellLoadState.cpp @@ -93,10 +93,7 @@ nsresult nsDocShellLoadState::CreateFromPendingChannel( } loadState->SetOriginalURI(originalUri); - nsCOMPtr loadInfo = channel->GetLoadInfo(); - if (NS_WARN_IF(!loadInfo)) { - return NS_ERROR_FAILURE; - } + nsCOMPtr loadInfo = channel->LoadInfo(); loadState->SetTriggeringPrincipal(loadInfo->TriggeringPrincipal()); // Return the newly created loadState. diff --git a/dom/base/Document.cpp b/dom/base/Document.cpp index 20b2b35d0197..697abce72215 100644 --- a/dom/base/Document.cpp +++ b/dom/base/Document.cpp @@ -2419,7 +2419,7 @@ static void WarnIfSandboxIneffective(nsIDocShell* aDocShell, } bool Document::IsSynthesized() { - nsCOMPtr loadInfo = mChannel ? mChannel->GetLoadInfo() : nullptr; + nsCOMPtr loadInfo = mChannel ? mChannel->LoadInfo() : nullptr; return loadInfo && loadInfo->GetServiceWorkerTaintingSynthesized(); } @@ -2519,8 +2519,8 @@ nsresult Document::StartDocumentLoad(const char* aCommand, nsIChannel* aChannel, nsCOMPtr docShell = do_QueryInterface(aContainer); // If this is an error page, don't inherit sandbox flags from docshell - nsCOMPtr loadInfo = aChannel->GetLoadInfo(); - if (docShell && !(loadInfo && loadInfo->GetLoadErrorPage())) { + nsCOMPtr 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 loadInfo = aChannel->GetLoadInfo(); - if (loadInfo && loadInfo->GetVerifySignedContent()) { + nsCOMPtr 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 channel = do_QueryInterface(request); if (channel) { - nsCOMPtr li; - channel->GetLoadInfo(getter_AddRefs(li)); - if (li) { - if (li->InternalContentPolicyType() == - nsIContentPolicy::TYPE_INTERNAL_IMAGE_FAVICON) { - continue; - } + nsCOMPtr 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 loadInfo = mChannel ? mChannel->GetLoadInfo() : nullptr; - if (loadInfo) { + if (mChannel) { + nsCOMPtr loadInfo = mChannel->LoadInfo(); loadInfo->SetDocumentHasUserInteracted(true); } diff --git a/dom/base/ThirdPartyUtil.cpp b/dom/base/ThirdPartyUtil.cpp index d376672afb5f..2b53e15aaf93 100644 --- a/dom/base/ThirdPartyUtil.cpp +++ b/dom/base/ThirdPartyUtil.cpp @@ -240,7 +240,7 @@ ThirdPartyUtil::IsThirdPartyChannel(nsIChannel* aChannel, nsIURI* aURI, if (NS_FAILED(rv)) return rv; if (!doForce) { - if (nsCOMPtr loadInfo = aChannel->GetLoadInfo()) { + if (nsCOMPtr loadInfo = aChannel->LoadInfo()) { parentIsThird = loadInfo->GetIsInThirdPartyContext(); if (!parentIsThird && loadInfo->GetExternalContentPolicyType() != nsIContentPolicy::TYPE_DOCUMENT) { diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index ce3371bd7c18..0565561e8f66 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -8122,10 +8122,7 @@ bool nsContentUtils::IsNonSubresourceRequest(nsIChannel* aChannel) { return true; } - nsCOMPtr loadInfo = aChannel->GetLoadInfo(); - if (!loadInfo) { - return false; - } + nsCOMPtr 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 loadInfo = aChannel->GetLoadInfo(); - if (!loadInfo) { - return false; - } + nsCOMPtr loadInfo = aChannel->LoadInfo(); nsCOMPtr triggeringPrincipal = loadInfo->TriggeringPrincipal(); // Get the channel's load flags, and use them to generate nsIWebNavigation diff --git a/dom/base/nsGlobalWindowInner.cpp b/dom/base/nsGlobalWindowInner.cpp index 8c59b35f0f2f..2448ffe08e54 100644 --- a/dom/base/nsGlobalWindowInner.cpp +++ b/dom/base/nsGlobalWindowInner.cpp @@ -1718,7 +1718,7 @@ nsresult nsGlobalWindowInner::EnsureClientSource() { } if (!ignoreLoadInfo) { - loadInfo = channel->GetLoadInfo(); + loadInfo = channel->LoadInfo(); } } diff --git a/dom/base/nsGlobalWindowOuter.cpp b/dom/base/nsGlobalWindowOuter.cpp index 93afdeb5ca0b..983019fb9cb7 100644 --- a/dom/base/nsGlobalWindowOuter.cpp +++ b/dom/base/nsGlobalWindowOuter.cpp @@ -5516,11 +5516,10 @@ void nsGlobalWindowOuter::NotifyContentBlockingEvent(unsigned aEvent, // static bool nsGlobalWindowOuter::SameLoadingURI(Document* aDoc, nsIChannel* aChannel) { nsCOMPtr docURI = aDoc->GetDocumentURI(); - nsCOMPtr channelLoadInfo = aChannel->GetLoadInfo(); - if (!channelLoadInfo || !docURI) { + if (!docURI) { return false; } - + nsCOMPtr channelLoadInfo = aChannel->LoadInfo(); nsCOMPtr channelLoadingPrincipal = channelLoadInfo->LoadingPrincipal(); if (!channelLoadingPrincipal) { diff --git a/dom/base/nsNodeInfoManager.cpp b/dom/base/nsNodeInfoManager.cpp index b355f2bdbee9..0402066da3dc 100644 --- a/dom/base/nsNodeInfoManager.cpp +++ b/dom/base/nsNodeInfoManager.cpp @@ -331,7 +331,7 @@ bool nsNodeInfoManager::InternalSVGEnabled() { nsCOMPtr 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 = diff --git a/dom/base/nsObjectLoadingContent.cpp b/dom/base/nsObjectLoadingContent.cpp index b0f09a8e2705..a523b3f5ffdd 100644 --- a/dom/base/nsObjectLoadingContent.cpp +++ b/dom/base/nsObjectLoadingContent.cpp @@ -2412,8 +2412,7 @@ nsresult nsObjectLoadingContent::OpenChannel() { nsIRequest::LOAD_HTML_OBJECT_DATA); NS_ENSURE_SUCCESS(rv, rv); if (inherit) { - nsCOMPtr loadinfo = chan->GetLoadInfo(); - NS_ENSURE_STATE(loadinfo); + nsCOMPtr loadinfo = chan->LoadInfo(); loadinfo->SetPrincipalToInherit(thisContent->NodePrincipal()); } diff --git a/dom/base/nsSyncLoadService.cpp b/dom/base/nsSyncLoadService.cpp index 4c98cbe1cea0..c2d91db39b16 100644 --- a/dom/base/nsSyncLoadService.cpp +++ b/dom/base/nsSyncLoadService.cpp @@ -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 loadInfo = aChannel->GetLoadInfo(); - if (loadInfo) { - nsCOMPtr loaderUri; - loadInfo->TriggeringPrincipal()->GetURI(getter_AddRefs(loaderUri)); - if (loaderUri) { - rv = http->SetReferrerWithPolicy(loaderUri, aReferrerPolicy); - MOZ_ASSERT(NS_SUCCEEDED(rv)); - } + nsCOMPtr loadInfo = aChannel->LoadInfo(); + nsCOMPtr loaderUri; + loadInfo->TriggeringPrincipal()->GetURI(getter_AddRefs(loaderUri)); + if (loaderUri) { + rv = http->SetReferrerWithPolicy(loaderUri, aReferrerPolicy); + MOZ_ASSERT(NS_SUCCEEDED(rv)); } } diff --git a/dom/base/test/chrome/test_bug682305.html b/dom/base/test/chrome/test_bug682305.html index 6288c0718860..250fc9e40928 100644 --- a/dom/base/test/chrome/test_bug682305.html +++ b/dom/base/test/chrome/test_bug682305.html @@ -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]), }; diff --git a/dom/clients/manager/ClientChannelHelper.cpp b/dom/clients/manager/ClientChannelHelper.cpp index 7e6e2422142f..8d2b48b91089 100644 --- a/dom/clients/manager/ClientChannelHelper.cpp +++ b/dom/clients/manager/ClientChannelHelper.cpp @@ -55,19 +55,14 @@ class ClientChannelHelper final : public nsIInterfaceRequestor, nsIAsyncVerifyRedirectCallback* aCallback) override { MOZ_ASSERT(NS_IsMainThread()); - nsCOMPtr oldLoadInfo; - nsresult rv = aOldChannel->GetLoadInfo(getter_AddRefs(oldLoadInfo)); - NS_ENSURE_SUCCESS(rv, rv); - - nsCOMPtr 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 oldLoadInfo = aOldChannel->LoadInfo(); + nsCOMPtr newLoadInfo = aNewChannel->LoadInfo(); + UniquePtr reservedClient = oldLoadInfo->TakeReservedClientSource(); @@ -181,8 +176,7 @@ nsresult AddClientChannelHelper(nsIChannel* aChannel, MOZ_DIAGNOSTIC_ASSERT(reservedClientInfo.isNothing() || initialClientInfo.isNothing()); - nsCOMPtr loadInfo = aChannel->GetLoadInfo(); - NS_ENSURE_TRUE(loadInfo, NS_ERROR_FAILURE); + nsCOMPtr loadInfo = aChannel->LoadInfo(); nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager(); NS_ENSURE_TRUE(ssm, NS_ERROR_FAILURE); diff --git a/dom/fetch/FetchDriver.cpp b/dom/fetch/FetchDriver.cpp index dab3cf5f6271..e31d1a43313c 100644 --- a/dom/fetch/FetchDriver.cpp +++ b/dom/fetch/FetchDriver.cpp @@ -532,11 +532,7 @@ nsresult FetchDriver::HttpFetch( NS_ENSURE_SUCCESS(rv, rv); if (mCSPEventListener) { - nsCOMPtr loadInfo = chan->GetLoadInfo(); - if (NS_WARN_IF(!loadInfo)) { - return NS_ERROR_UNEXPECTED; - } - + nsCOMPtr loadInfo = chan->LoadInfo(); rv = loadInfo->SetCspEventListener(mCSPEventListener); NS_ENSURE_SUCCESS(rv, rv); } @@ -589,7 +585,7 @@ nsresult FetchDriver::HttpFetch( // If request’s referrer policy is the empty string, // then set request’s referrer policy to the user-set default policy. if (mRequest->ReferrerPolicy_() == ReferrerPolicy::_empty) { - nsCOMPtr loadInfo = httpChan->GetLoadInfo(); + nsCOMPtr loadInfo = httpChan->LoadInfo(); bool isPrivate = loadInfo->GetOriginAttributes().mPrivateBrowsingId > 0; net::ReferrerPolicy referrerPolicy = static_cast( NS_GetDefaultReferrerPolicy(isPrivate)); @@ -674,10 +670,8 @@ nsresult FetchDriver::HttpFetch( if (mRequest->Mode() == RequestMode::Cors) { AutoTArray unsafeHeaders; mRequest->Headers()->GetUnsafeHeaders(unsafeHeaders); - nsCOMPtr loadInfo = chan->GetLoadInfo(); - if (loadInfo) { - loadInfo->SetCorsPreflightInfo(unsafeHeaders, false); - } + nsCOMPtr 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 loadInfo; - rv = channel->GetLoadInfo(getter_AddRefs(loadInfo)); - if (NS_WARN_IF(NS_FAILED(rv))) { - FailWithNetworkError(rv); - return rv; - } - + nsCOMPtr 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 diff --git a/dom/file/uri/BlobURLProtocolHandler.cpp b/dom/file/uri/BlobURLProtocolHandler.cpp index b0547b5e185c..1e64fcfb6441 100644 --- a/dom/file/uri/BlobURLProtocolHandler.cpp +++ b/dom/file/uri/BlobURLProtocolHandler.cpp @@ -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 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) { diff --git a/dom/file/uri/FontTableURIProtocolHandler.cpp b/dom/file/uri/FontTableURIProtocolHandler.cpp index 3dd37f1822e8..b401fceb8a0e 100644 --- a/dom/file/uri/FontTableURIProtocolHandler.cpp +++ b/dom/file/uri/FontTableURIProtocolHandler.cpp @@ -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; } diff --git a/dom/html/HTMLMediaElement.cpp b/dom/html/HTMLMediaElement.cpp index b9cbe84bb1e8..0b4e937d7a25 100644 --- a/dom/html/HTMLMediaElement.cpp +++ b/dom/html/HTMLMediaElement.cpp @@ -1293,12 +1293,10 @@ class HTMLMediaElement::ChannelLoader final { } if (setAttrs) { - nsCOMPtr loadInfo = channel->GetLoadInfo(); - if (loadInfo) { - // The function simply returns NS_OK, so we ignore the return value. - Unused << loadInfo->SetOriginAttributes( - triggeringPrincipal->OriginAttributesRef()); - } + nsCOMPtr loadInfo = channel->LoadInfo(); + // The function simply returns NS_OK, so we ignore the return value. + Unused << loadInfo->SetOriginAttributes( + triggeringPrincipal->OriginAttributesRef()); } nsCOMPtr cos(do_QueryInterface(channel)); diff --git a/dom/html/ImageDocument.cpp b/dom/html/ImageDocument.cpp index dbe3967c834c..937c5294993f 100644 --- a/dom/html/ImageDocument.cpp +++ b/dom/html/ImageDocument.cpp @@ -87,7 +87,7 @@ ImageListener::OnStartRequest(nsIRequest* request, nsISupports* ctxt) { nsAutoCString mimeType; channel->GetContentType(mimeType); - nsCOMPtr loadInfo = channel->GetLoadInfo(); + nsCOMPtr 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 requestingNode = domWindow->GetFrameElementInternal(); @@ -100,8 +100,8 @@ ImageListener::OnStartRequest(nsIRequest* request, nsISupports* ctxt) { } nsCOMPtr 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; diff --git a/dom/html/nsHTMLDocument.cpp b/dom/html/nsHTMLDocument.cpp index 31a08c14550d..a47368bc3730 100644 --- a/dom/html/nsHTMLDocument.cpp +++ b/dom/html/nsHTMLDocument.cpp @@ -1923,8 +1923,7 @@ nsresult nsHTMLDocument::CreateAndAddWyciwygChannel(void) { nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL, nsIContentPolicy::TYPE_OTHER); NS_ENSURE_SUCCESS(rv, rv); - nsCOMPtr loadInfo = channel->GetLoadInfo(); - NS_ENSURE_STATE(loadInfo); + nsCOMPtr loadInfo = channel->LoadInfo(); loadInfo->SetPrincipalToInherit(NodePrincipal()); mWyciwygChannel = do_QueryInterface(channel); diff --git a/dom/jsurl/nsJSProtocolHandler.cpp b/dom/jsurl/nsJSProtocolHandler.cpp index 1f62005a6f85..da23eca9d1dc 100644 --- a/dom/jsurl/nsJSProtocolHandler.cpp +++ b/dom/jsurl/nsJSProtocolHandler.cpp @@ -144,9 +144,8 @@ nsresult nsJSThunk::EvaluateScript( aChannel->GetOwner(getter_AddRefs(owner)); nsCOMPtr principal = do_QueryInterface(owner); if (!principal) { - nsCOMPtr loadInfo; - aChannel->GetLoadInfo(getter_AddRefs(loadInfo)); - if (loadInfo && loadInfo->GetForceInheritPrincipal()) { + nsCOMPtr 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 loadInfo = nsIChannel::GetLoadInfo(); + nsCOMPtr 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) { diff --git a/dom/media/ChannelMediaResource.cpp b/dom/media/ChannelMediaResource.cpp index 06b26d1a09b4..98422d04954c 100644 --- a/dom/media/ChannelMediaResource.cpp +++ b/dom/media/ChannelMediaResource.cpp @@ -765,12 +765,10 @@ nsresult ChannelMediaResource::RecreateChannel() { NS_ENSURE_SUCCESS(rv, rv); if (setAttrs) { - nsCOMPtr loadInfo = mChannel->GetLoadInfo(); - if (loadInfo) { - // The function simply returns NS_OK, so we ignore the return value. - Unused << loadInfo->SetOriginAttributes( - triggeringPrincipal->OriginAttributesRef()); - } + nsCOMPtr loadInfo = mChannel->LoadInfo(); + // The function simply returns NS_OK, so we ignore the return value. + Unused << loadInfo->SetOriginAttributes( + triggeringPrincipal->OriginAttributesRef()); } nsCOMPtr cos(do_QueryInterface(mChannel)); diff --git a/dom/performance/PerformanceTiming.cpp b/dom/performance/PerformanceTiming.cpp index 34f62a9a04f0..288287b97bec 100644 --- a/dom/performance/PerformanceTiming.cpp +++ b/dom/performance/PerformanceTiming.cpp @@ -267,11 +267,7 @@ bool PerformanceTimingData::CheckAllowedOrigin(nsIHttpChannel* aResourceChannel, } // Check that the current document passes the ckeck. - nsCOMPtr loadInfo; - aResourceChannel->GetLoadInfo(getter_AddRefs(loadInfo)); - if (!loadInfo) { - return false; - } + nsCOMPtr loadInfo = aResourceChannel->LoadInfo(); // TYPE_DOCUMENT loads have no loadingPrincipal. if (loadInfo->GetExternalContentPolicyType() == diff --git a/dom/plugins/base/moz.build b/dom/plugins/base/moz.build index 57027479efee..7f6161d80a51 100644 --- a/dom/plugins/base/moz.build +++ b/dom/plugins/base/moz.build @@ -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 diff --git a/dom/plugins/base/nsPluginStreamListenerPeer.cpp b/dom/plugins/base/nsPluginStreamListenerPeer.cpp index 52e4c4c360d0..701246248c19 100644 --- a/dom/plugins/base/nsPluginStreamListenerPeer.cpp +++ b/dom/plugins/base/nsPluginStreamListenerPeer.cpp @@ -167,7 +167,7 @@ nsPluginStreamListenerPeer::OnStartRequest(nsIRequest* request, if (NS_FAILED(rv)) return rv; // Check ShouldProcess with content policy - nsCOMPtr loadInfo = channel->GetLoadInfo(); + nsCOMPtr loadInfo = channel->LoadInfo(); int16_t shouldLoad = nsIContentPolicy::ACCEPT; rv = NS_CheckContentProcessPolicy(mURL, loadInfo, contentType, &shouldLoad); diff --git a/dom/plugins/base/nsPluginsDir.h b/dom/plugins/base/nsPluginsDir.h index 6c769f47508a..42a24f8382e6 100644 --- a/dom/plugins/base/nsPluginsDir.h +++ b/dom/plugins/base/nsPluginsDir.h @@ -44,7 +44,9 @@ struct nsPluginInfo { * details. */ class nsPluginFile { +#ifndef XP_WIN PRLibrary* pLibrary; +#endif nsCOMPtr mPlugin; public: diff --git a/dom/script/ScriptLoader.cpp b/dom/script/ScriptLoader.cpp index 7fc771bca294..531d85b77723 100644 --- a/dom/script/ScriptLoader.cpp +++ b/dom/script/ScriptLoader.cpp @@ -1275,7 +1275,7 @@ nsresult ScriptLoader::StartLoad(ScriptLoadRequest* aRequest) { if (element && element->IsHTMLElement()) { nsAutoString cspNonce; element->GetAttribute(NS_LITERAL_STRING("nonce"), cspNonce); - nsCOMPtr loadInfo = channel->GetLoadInfo(); + nsCOMPtr loadInfo = channel->LoadInfo(); loadInfo->SetCspNonce(cspNonce); } } @@ -3208,9 +3208,9 @@ nsresult ScriptLoader::VerifySRI(ScriptLoadRequest* aRequest, rv = NS_ERROR_SRI_CORRUPT; } } else { - nsCOMPtr loadInfo = channel->GetLoadInfo(); + nsCOMPtr loadInfo = channel->LoadInfo(); - if (loadInfo && loadInfo->GetEnforceSRI()) { + if (loadInfo->GetEnforceSRI()) { MOZ_LOG(SRILogHelper::GetSriLog(), mozilla::LogLevel::Debug, ("ScriptLoader::OnStreamComplete, required SRI not found")); nsCOMPtr csp; diff --git a/dom/security/FramingChecker.cpp b/dom/security/FramingChecker.cpp index e68109cc136a..0032a5fa59d0 100644 --- a/dom/security/FramingChecker.cpp +++ b/dom/security/FramingChecker.cpp @@ -184,10 +184,9 @@ static bool ShouldIgnoreFrameOptions(nsIChannel* aChannel, } // log warning to console that xfo is ignored because of CSP - nsCOMPtr loadInfo = aChannel->GetLoadInfo(); - uint64_t innerWindowID = loadInfo ? loadInfo->GetInnerWindowID() : 0; - bool privateWindow = - loadInfo ? !!loadInfo->GetOriginAttributes().mPrivateBrowsingId : false; + nsCOMPtr 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 webNav(do_QueryObject(aDocShell)); if (webNav) { - nsCOMPtr loadInfo = httpChannel->GetLoadInfo(); - MOZ_ASSERT(loadInfo); - + nsCOMPtr loadInfo = httpChannel->LoadInfo(); RefPtr principal = NullPrincipal::CreateWithInheritedAttributes( loadInfo->TriggeringPrincipal()); diff --git a/dom/security/SRICheck.cpp b/dom/security/SRICheck.cpp index 71c5d4ec969d..4e8330ced279 100644 --- a/dom/security/SRICheck.cpp +++ b/dom/security/SRICheck.cpp @@ -327,8 +327,7 @@ nsresult SRICheckDataVerifier::Verify(const SRIMetadata& aMetadata, nsresult rv = Finish(); NS_ENSURE_SUCCESS(rv, rv); - nsCOMPtr loadInfo = aChannel->GetLoadInfo(); - NS_ENSURE_TRUE(loadInfo, NS_ERROR_FAILURE); + nsCOMPtr loadInfo = aChannel->LoadInfo(); LoadTainting tainting = loadInfo->GetTainting(); if (NS_FAILED(IsEligible(aChannel, tainting, aSourceFileURI, aReporter))) { diff --git a/dom/security/nsCSPService.cpp b/dom/security/nsCSPService.cpp index c40dda86ed15..175641a2752d 100644 --- a/dom/security/nsCSPService.cpp +++ b/dom/security/nsCSPService.cpp @@ -260,13 +260,7 @@ CSPService::AsyncOnChannelRedirect(nsIChannel *oldChannel, nsresult rv = newChannel->GetURI(getter_AddRefs(newUri)); NS_ENSURE_SUCCESS(rv, rv); - nsCOMPtr loadInfo = oldChannel->GetLoadInfo(); - - // if no loadInfo on the channel, nothing for us to do - if (!loadInfo) { - return NS_OK; - } - + nsCOMPtr loadInfo = oldChannel->LoadInfo(); nsCOMPtr cspEventListener; rv = loadInfo->GetCspEventListener(getter_AddRefs(cspEventListener)); NS_ENSURE_SUCCESS(rv, rv); diff --git a/dom/security/nsContentSecurityManager.cpp b/dom/security/nsContentSecurityManager.cpp index 24f2d0122be6..a7591b0513b5 100644 --- a/dom/security/nsContentSecurityManager.cpp +++ b/dom/security/nsContentSecurityManager.cpp @@ -45,10 +45,7 @@ static mozilla::LazyLogModule sCSMLog("CSMLog"); if (!mozilla::net::nsIOService::BlockToplevelDataUriNavigations()) { return true; } - nsCOMPtr loadInfo = aChannel->GetLoadInfo(); - if (!loadInfo) { - return true; - } + nsCOMPtr 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 loadInfo = aNewChannel->GetLoadInfo(); - if (!loadInfo) { - return true; - } + nsCOMPtr loadInfo = aNewChannel->LoadInfo(); if (loadInfo->GetExternalContentPolicyType() != nsIContentPolicy::TYPE_SCRIPT) { return true; @@ -170,11 +164,7 @@ static mozilla::LazyLogModule sCSMLog("CSMLog"); return NS_OK; } - nsCOMPtr loadInfo = aChannel->GetLoadInfo(); - if (!loadInfo) { - return NS_OK; - } - + nsCOMPtr 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& aInAndOutListener) { NS_ENSURE_ARG(aChannel); - nsCOMPtr loadInfo = aChannel->GetLoadInfo(); - - if (!loadInfo) { - MOZ_ASSERT(false, - "channel needs to have loadInfo to perform security checks"); - return NS_ERROR_UNEXPECTED; - } - + nsCOMPtr 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 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 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 loadInfo = aChannel->GetLoadInfo(); - MOZ_ASSERT(loadInfo); - + nsCOMPtr loadInfo = aChannel->LoadInfo(); nsCOMPtr uri; nsresult rv = NS_GetFinalChannelURI(aChannel, getter_AddRefs(uri)); NS_ENSURE_SUCCESS(rv, rv); diff --git a/dom/security/nsMixedContentBlocker.cpp b/dom/security/nsMixedContentBlocker.cpp index 462d8298e56f..89501228a888 100644 --- a/dom/security/nsMixedContentBlocker.cpp +++ b/dom/security/nsMixedContentBlocker.cpp @@ -301,7 +301,7 @@ nsMixedContentBlocker::AsyncOnChannelRedirect( NS_ENSURE_SUCCESS(rv, rv); // Get the loading Info from the old channel - nsCOMPtr loadInfo = aOldChannel->GetLoadInfo(); + nsCOMPtr loadInfo = aOldChannel->LoadInfo(); nsCOMPtr requestingPrincipal = loadInfo->LoadingPrincipal(); // Since we are calling shouldLoad() directly on redirects, we don't go diff --git a/dom/serviceworkers/ServiceWorkerEvents.cpp b/dom/serviceworkers/ServiceWorkerEvents.cpp index 5ab615b49f9a..cb07151b7fab 100644 --- a/dom/serviceworkers/ServiceWorkerEvents.cpp +++ b/dom/serviceworkers/ServiceWorkerEvents.cpp @@ -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 loadInfo = underlyingChannel->GetLoadInfo(); + nsCOMPtr loadInfo = underlyingChannel->LoadInfo(); - if (!loadInfo || !CSPPermitsResponse(loadInfo)) { + if (!CSPPermitsResponse(loadInfo)) { mChannel->CancelInterception(NS_ERROR_CONTENT_BLOCKED); return NS_OK; } diff --git a/dom/serviceworkers/ServiceWorkerInterceptController.cpp b/dom/serviceworkers/ServiceWorkerInterceptController.cpp index 6b4726f4cf42..90567fa51792 100644 --- a/dom/serviceworkers/ServiceWorkerInterceptController.cpp +++ b/dom/serviceworkers/ServiceWorkerInterceptController.cpp @@ -22,10 +22,7 @@ ServiceWorkerInterceptController::ShouldPrepareForIntercept( nsIURI* aURI, nsIChannel* aChannel, bool* aShouldIntercept) { *aShouldIntercept = false; - nsCOMPtr loadInfo = aChannel->GetLoadInfo(); - if (!loadInfo) { - return NS_OK; - } + nsCOMPtr 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 diff --git a/dom/serviceworkers/ServiceWorkerManager.cpp b/dom/serviceworkers/ServiceWorkerManager.cpp index 692223b114ac..8fd75092653b 100644 --- a/dom/serviceworkers/ServiceWorkerManager.cpp +++ b/dom/serviceworkers/ServiceWorkerManager.cpp @@ -1873,38 +1873,36 @@ class ContinueDispatchFetchEventRunnable : public Runnable { nsString clientId; nsString resultingClientId; - nsCOMPtr loadInfo = channel->GetLoadInfo(); - if (loadInfo) { - char buf[NSID_LENGTH]; - Maybe clientInfo = loadInfo->GetClientInfo(); - if (clientInfo.isSome()) { - clientInfo.ref().Id().ToProvidedString(buf); - NS_ConvertASCIItoUTF16 uuid(buf); + nsCOMPtr loadInfo = channel->LoadInfo(); + char buf[NSID_LENGTH]; + Maybe 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 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 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 loadInfo = internalChannel->GetLoadInfo(); - if (NS_WARN_IF(!loadInfo)) { - aRv.Throw(NS_ERROR_UNEXPECTED); - return; - } - + nsCOMPtr loadInfo = internalChannel->LoadInfo(); RefPtr serviceWorker; if (!nsContentUtils::IsNonSubresourceRequest(internalChannel)) { diff --git a/dom/workers/ScriptLoader.cpp b/dom/workers/ScriptLoader.cpp index 544da05fbf86..07307751c05c 100644 --- a/dom/workers/ScriptLoader.cpp +++ b/dom/workers/ScriptLoader.cpp @@ -247,11 +247,7 @@ nsresult ChannelFromScriptURL(nsIPrincipal* principal, Document* parentDoc, NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_SECURITY_ERR); if (cspEventListener) { - nsCOMPtr loadInfo = channel->GetLoadInfo(); - if (NS_WARN_IF(!loadInfo)) { - return NS_ERROR_UNEXPECTED; - } - + nsCOMPtr 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 chanLoadInfo = channel->GetLoadInfo(); - if (chanLoadInfo && chanLoadInfo->GetEnforceSRI()) { + nsCOMPtr 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. diff --git a/dom/xhr/XMLHttpRequestMainThread.cpp b/dom/xhr/XMLHttpRequestMainThread.cpp index 060e161c92dd..5e130e3b3f89 100644 --- a/dom/xhr/XMLHttpRequestMainThread.cpp +++ b/dom/xhr/XMLHttpRequestMainThread.cpp @@ -747,13 +747,7 @@ bool XMLHttpRequestMainThread::IsCrossSiteCORSRequest() const { return false; } - nsCOMPtr loadInfo = mChannel->GetLoadInfo(); - MOZ_ASSERT(loadInfo); - - if (!loadInfo) { - return false; - } - + nsCOMPtr loadInfo = mChannel->LoadInfo(); return loadInfo->GetTainting() == LoadTainting::CORS; } @@ -1478,11 +1472,8 @@ void XMLHttpRequestMainThread::SetOriginAttributes( OriginAttributes attrs(aAttrs); - nsCOMPtr loadInfo = mChannel->GetLoadInfo(); - MOZ_ASSERT(loadInfo); - if (loadInfo) { - loadInfo->SetOriginAttributes(attrs); - } + nsCOMPtr loadInfo = mChannel->LoadInfo(); + loadInfo->SetOriginAttributes(attrs); } /* @@ -1989,12 +1980,9 @@ XMLHttpRequestMainThread::OnStartRequest(nsIRequest* request, mResponseXML->ForceEnableXULXBL(); } - nsCOMPtr loadInfo = mChannel->GetLoadInfo(); - MOZ_ASSERT(loadInfo); + nsCOMPtr loadInfo = mChannel->LoadInfo(); bool isCrossSite = false; - if (loadInfo) { - isCrossSite = loadInfo->GetTainting() != LoadTainting::Basic; - } + isCrossSite = loadInfo->GetTainting() != LoadTainting::Basic; if (isCrossSite) { nsCOMPtr htmlDoc = do_QueryInterface(mResponseXML); @@ -2365,11 +2353,7 @@ nsresult XMLHttpRequestMainThread::CreateChannel() { NS_ENSURE_SUCCESS(rv, rv); if (mCSPEventListener) { - nsCOMPtr loadInfo = mChannel->GetLoadInfo(); - if (NS_WARN_IF(!loadInfo)) { - return NS_ERROR_UNEXPECTED; - } - + nsCOMPtr 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 loadInfo = mChannel->GetLoadInfo(); - if (loadInfo) { - static_cast(loadInfo.get())->SetIncludeCookiesSecFlag(); - } + nsCOMPtr loadInfo = mChannel->LoadInfo(); + static_cast(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 CORSUnsafeHeaders; mAuthorRequestHeaders.GetCORSUnsafeHeaders(CORSUnsafeHeaders); - nsCOMPtr loadInfo = mChannel->GetLoadInfo(); - if (loadInfo) { - loadInfo->SetCorsPreflightInfo(CORSUnsafeHeaders, - mFlagHadUploadListenersOnSend); - } + nsCOMPtr loadInfo = mChannel->LoadInfo(); + loadInfo->SetCorsPreflightInfo(CORSUnsafeHeaders, + mFlagHadUploadListenersOnSend); } // Hook us up to listen to redirects and the like. Only do this very late diff --git a/gfx/2d/Factory.cpp b/gfx/2d/Factory.cpp index a79dc655a4b6..d3cd836183f1 100644 --- a/gfx/2d/Factory.cpp +++ b/gfx/2d/Factory.cpp @@ -45,7 +45,6 @@ # include "NativeFontResourceDWrite.h" # include # include "HelpersD2D.h" -# include "HelpersWinFonts.h" #endif #include "DrawTargetCapture.h" diff --git a/gfx/2d/moz.build b/gfx/2d/moz.build index adf937e6f4b9..9ab253305ab9 100644 --- a/gfx/2d/moz.build +++ b/gfx/2d/moz.build @@ -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 diff --git a/gfx/thebes/DeviceManagerDx.cpp b/gfx/thebes/DeviceManagerDx.cpp index 9cd9ae8500e5..244354263c6f 100644 --- a/gfx/thebes/DeviceManagerDx.cpp +++ b/gfx/thebes/DeviceManagerDx.cpp @@ -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 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()); diff --git a/gfx/thebes/moz.build b/gfx/thebes/moz.build index 522162991f50..73340c452da2 100644 --- a/gfx/thebes/moz.build +++ b/gfx/thebes/moz.build @@ -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 diff --git a/image/decoders/icon/nsIconProtocolHandler.cpp b/image/decoders/icon/nsIconProtocolHandler.cpp index 0dcbd8ff9303..ba040c758905 100644 --- a/image/decoders/icon/nsIconProtocolHandler.cpp +++ b/image/decoders/icon/nsIconProtocolHandler.cpp @@ -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); -} - //////////////////////////////////////////////////////////////////////////////// diff --git a/image/imgLoader.cpp b/image/imgLoader.cpp index fe8dba3f6ba3..095a7d2d74ae 100644 --- a/image/imgLoader.cpp +++ b/image/imgLoader.cpp @@ -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 loadInfo = (*aResult)->GetLoadInfo(); - if (loadInfo) { - rv = loadInfo->SetOriginAttributes( - aTriggeringPrincipal->OriginAttributesRef()); - } + nsCOMPtr 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 loadInfo = (*aResult)->GetLoadInfo(); - if (loadInfo) { - rv = loadInfo->SetOriginAttributes(attrs); - } + nsCOMPtr loadInfo = (*aResult)->LoadInfo(); + rv = loadInfo->SetOriginAttributes(attrs); } if (NS_FAILED(rv)) { @@ -2374,12 +2370,9 @@ nsresult imgLoader::LoadImageWithChannel(nsIChannel* channel, nsCOMPtr doc = do_QueryInterface(aCX); NS_ENSURE_TRUE(channel, NS_ERROR_FAILURE); - nsCOMPtr loadInfo = channel->GetLoadInfo(); + nsCOMPtr 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 loadInfo = channel->GetLoadInfo(); + nsCOMPtr 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, diff --git a/image/imgRequest.cpp b/image/imgRequest.cpp index 3fb668d64a93..e4fbd029df74 100644 --- a/image/imgRequest.cpp +++ b/image/imgRequest.cpp @@ -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 loadInfo = mChannel->GetLoadInfo(); + nsCOMPtr loadInfo = mChannel->LoadInfo(); bool upgradeInsecureRequests = loadInfo ? loadInfo->GetUpgradeInsecureRequests() || loadInfo->GetBrowserUpgradeInsecureRequests() diff --git a/ipc/chromium/moz.build b/ipc/chromium/moz.build index 607bee1a601b..3766f259e572 100644 --- a/ipc/chromium/moz.build +++ b/ipc/chromium/moz.build @@ -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 diff --git a/ipc/chromium/src/base/platform_thread_win.cc b/ipc/chromium/src/base/platform_thread_win.cc index 53a7fabeb598..59eb45aff6ab 100644 --- a/ipc/chromium/src/base/platform_thread_win.cc +++ b/ipc/chromium/src/base/platform_thread_win.cc @@ -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(closure); diff --git a/ipc/chromium/src/base/process_util_win.cc b/ipc/chromium/src/base/process_util_win.cc index 9040d1485884..37390f7ecab4 100644 --- a/ipc/chromium/src/base/process_util_win.cc +++ b/ipc/chromium/src/base/process_util_win.cc @@ -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); diff --git a/ipc/chromium/src/base/string_util_win.h b/ipc/chromium/src/base/string_util_win.h index 1863034f0b44..7f8586889b9a 100644 --- a/ipc/chromium/src/base/string_util_win.h +++ b/ipc/chromium/src/base/string_util_win.h @@ -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); diff --git a/ipc/chromium/src/base/win_util.cc b/ipc/chromium/src/base/win_util.cc index ebe5f8ab344a..611603f56eeb 100644 --- a/ipc/chromium/src/base/win_util.cc +++ b/ipc/chromium/src/base/win_util.cc @@ -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(&string_buffer), 0, NULL); + ::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, messageid, 0, + reinterpret_cast(&string_buffer), 0, NULL); std::wstring formatted_string; if (string_buffer) { diff --git a/js/src/vm/GeckoProfiler-inl.h b/js/src/vm/GeckoProfiler-inl.h index 0f396db5dbff..4706b98520e6 100644 --- a/js/src/vm/GeckoProfiler-inl.h +++ b/js/src/vm/GeckoProfiler-inl.h @@ -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 diff --git a/js/src/wasm/WasmBaselineCompile.cpp b/js/src/wasm/WasmBaselineCompile.cpp index 288a20b3b6a3..305822aa07df 100644 --- a/js/src/wasm/WasmBaselineCompile.cpp +++ b/js/src/wasm/WasmBaselineCompile.cpp @@ -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& 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 diff --git a/js/src/wasm/WasmGC.cpp b/js/src/wasm/WasmGC.cpp index c63faa49b269..4a97777254c2 100644 --- a/js/src/wasm/WasmGC.cpp +++ b/js/src/wasm/WasmGC.cpp @@ -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& 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 diff --git a/js/src/wasm/WasmGC.h b/js/src/wasm/WasmGC.h index 2ac6590b5083..58e0f8630333 100644 --- a/js/src/wasm/WasmGC.h +++ b/js/src/wasm/WasmGC.h @@ -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); +// +// EmitWasmPreBarrierCall(...); +// bind(&skipPreBarrier); +// +// +// +// Label skipPostBarrier; +// +// EmitWasmPostBarrierGuard(..., &skipPostBarrier); +// +// 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& object, + Register otherScratch, Register setValue, + Label* skipBarrier); + } // namespace wasm } // namespace js diff --git a/layout/style/Loader.cpp b/layout/style/Loader.cpp index fbaa98a8d06a..cb5d2065c2aa 100644 --- a/layout/style/Loader.cpp +++ b/layout/style/Loader.cpp @@ -743,8 +743,8 @@ nsresult SheetLoadData::VerifySheetReadyToParse(nsresult aStatus, SRIMetadata sriMetadata; mSheet->GetIntegrity(sriMetadata); if (sriMetadata.IsEmpty()) { - nsCOMPtr loadInfo = aChannel->GetLoadInfo(); - if (loadInfo && loadInfo->GetEnforceSRI()) { + nsCOMPtr 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 loadInfo = channel->GetLoadInfo(); + nsCOMPtr 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 loadInfo = channel->GetLoadInfo(); + nsCOMPtr loadInfo = channel->LoadInfo(); loadInfo->SetCspNonce(cspNonce); } } diff --git a/media/mtransport/common.build b/media/mtransport/common.build index e6f03e6c5b0a..d60ae8be289f 100644 --- a/media/mtransport/common.build +++ b/media/mtransport/common.build @@ -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 diff --git a/memory/build/mozjemalloc.cpp b/memory/build/mozjemalloc.cpp index 0a25d1e062fb..3a69c68c7ca3 100644 --- a/memory/build/mozjemalloc.cpp +++ b/memory/build/mozjemalloc.cpp @@ -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. // *************************************************************************** diff --git a/memory/replace/dmd/DMD.cpp b/memory/replace/dmd/DMD.cpp index 2e77684e4488..e803f5c7332a 100644 --- a/memory/replace/dmd/DMD.cpp +++ b/memory/replace/dmd/DMD.cpp @@ -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 diff --git a/memory/replace/dmd/moz.build b/memory/replace/dmd/moz.build index 507ed84cbc7a..c6603df92a06 100644 --- a/memory/replace/dmd/moz.build +++ b/memory/replace/dmd/moz.build @@ -36,6 +36,3 @@ if CONFIG['OS_ARCH'] == 'WINNT': ] TEST_DIRS += ['test'] - -if CONFIG['CC_TYPE'] == 'clang-cl': - AllowCompilerWarnings() # workaround for bug 1090497 diff --git a/memory/replace/logalloc/LogAlloc.cpp b/memory/replace/logalloc/LogAlloc.cpp index a2a0b0901347..0627ac7a77ce 100644 --- a/memory/replace/logalloc/LogAlloc.cpp +++ b/memory/replace/logalloc/LogAlloc.cpp @@ -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()); } diff --git a/memory/replace/logalloc/moz.build b/memory/replace/logalloc/moz.build index 70aa8cf8104c..d6ec145559dc 100644 --- a/memory/replace/logalloc/moz.build +++ b/memory/replace/logalloc/moz.build @@ -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 diff --git a/memory/replace/moz.build b/memory/replace/moz.build index 49e6966eb537..4858b3379015 100644 --- a/memory/replace/moz.build +++ b/memory/replace/moz.build @@ -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 diff --git a/mobile/android/chrome/content/browser.js b/mobile/android/chrome/content/browser.js index c3edaaed4e4c..482357522f82 100644 --- a/mobile/android/chrome/content/browser.js +++ b/mobile/android/chrome/content/browser.js @@ -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) { diff --git a/modules/libjar/nsJARProtocolHandler.cpp b/modules/libjar/nsJARProtocolHandler.cpp index 5cdb4f698326..0289c7284406 100644 --- a/modules/libjar/nsJARProtocolHandler.cpp +++ b/modules/libjar/nsJARProtocolHandler.cpp @@ -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) { diff --git a/mozglue/build/Authenticode.cpp b/mozglue/build/Authenticode.cpp index a2c17ca3e5ce..65b649d09c82 100644 --- a/mozglue/build/Authenticode.cpp +++ b/mozglue/build/Authenticode.cpp @@ -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 diff --git a/mozglue/build/moz.build b/mozglue/build/moz.build index e47f3be7968b..ac1ba9361666 100644 --- a/mozglue/build/moz.build +++ b/mozglue/build/moz.build @@ -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 diff --git a/netwerk/base/LoadInfo.cpp b/netwerk/base/LoadInfo.cpp index 71150f70742f..aeac78962c49 100644 --- a/netwerk/base/LoadInfo.cpp +++ b/netwerk/base/LoadInfo.cpp @@ -269,10 +269,8 @@ LoadInfo::LoadInfo( // if owner doc has content signature, we enforce SRI nsCOMPtr channel = aLoadingContext->OwnerDoc()->GetChannel(); if (channel) { - nsCOMPtr loadInfo = channel->GetLoadInfo(); - if (loadInfo) { - mEnforceSRI = loadInfo->GetVerifySignedContent(); - } + nsCOMPtr loadInfo = channel->LoadInfo(); + mEnforceSRI = loadInfo->GetVerifySignedContent(); } } diff --git a/netwerk/base/Predictor.cpp b/netwerk/base/Predictor.cpp index b652e42d470e..4f6ead58f1a7 100644 --- a/netwerk/base/Predictor.cpp +++ b/netwerk/base/Predictor.cpp @@ -1255,10 +1255,8 @@ nsresult Predictor::Prefetch(nsIURI *uri, nsIURI *referrer, return rv; } - nsCOMPtr loadInfo = channel->GetLoadInfo(); - if (loadInfo) { - rv = loadInfo->SetOriginAttributes(originAttributes); - } + nsCOMPtr loadInfo = channel->LoadInfo(); + rv = loadInfo->SetOriginAttributes(originAttributes); if (NS_FAILED(rv)) { PREDICTOR_LOG( diff --git a/netwerk/base/nsAsyncRedirectVerifyHelper.cpp b/netwerk/base/nsAsyncRedirectVerifyHelper.cpp index ce2529e3490a..76bbee25dd92 100644 --- a/netwerk/base/nsAsyncRedirectVerifyHelper.cpp +++ b/netwerk/base/nsAsyncRedirectVerifyHelper.cpp @@ -74,8 +74,8 @@ nsresult nsAsyncRedirectVerifyHelper::Init( if (!(flags & (nsIChannelEventSink::REDIRECT_INTERNAL | nsIChannelEventSink::REDIRECT_STS_UPGRADE))) { - nsCOMPtr loadInfo = oldChan->GetLoadInfo(); - if (loadInfo && loadInfo->GetDontFollowRedirects()) { + nsCOMPtr loadInfo = oldChan->LoadInfo(); + if (loadInfo->GetDontFollowRedirects()) { ExplicitCallback(NS_BINDING_ABORTED); return NS_OK; } diff --git a/netwerk/base/nsBaseChannel.cpp b/netwerk/base/nsBaseChannel.cpp index 7ce013b2d3d5..9487a32ce2a1 100644 --- a/netwerk/base/nsBaseChannel.cpp +++ b/netwerk/base/nsBaseChannel.cpp @@ -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 newLoadInfo = - static_cast(mLoadInfo.get()) - ->CloneWithNewSecFlags(secFlags); + nsSecurityFlags secFlags = + mLoadInfo->GetSecurityFlags() & ~nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL; + nsCOMPtr newLoadInfo = + static_cast(mLoadInfo.get()) + ->CloneWithNewSecFlags(secFlags); - nsCOMPtr uriPrincipal; - nsIScriptSecurityManager *sm = nsContentUtils::GetSecurityManager(); - sm->GetChannelURIPrincipal(this, getter_AddRefs(uriPrincipal)); - bool isInternalRedirect = - (redirectFlags & (nsIChannelEventSink::REDIRECT_INTERNAL | - nsIChannelEventSink::REDIRECT_STS_UPGRADE)); + nsCOMPtr 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 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 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 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 resultPrincipalURI; - nsCOMPtr 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 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) { diff --git a/netwerk/base/nsIChannel.idl b/netwerk/base/nsIChannel.idl index 4b0be6031937..260eb97bbde9 100644 --- a/netwerk/base/nsIChannel.idl +++ b/netwerk/base/nsIChannel.idl @@ -356,11 +356,11 @@ interface nsIChannel : nsIRequest return false; } - inline already_AddRefed GetLoadInfo() + inline already_AddRefed LoadInfo() { nsCOMPtr result; mozilla::DebugOnly rv = GetLoadInfo(getter_AddRefs(result)); - MOZ_ASSERT(NS_SUCCEEDED(rv) || !result); + MOZ_ASSERT(NS_SUCCEEDED(rv) && result); return result.forget(); } %} diff --git a/netwerk/base/nsINetworkInterceptController.idl b/netwerk/base/nsINetworkInterceptController.idl index ea4dd16f4893..3a33cd7f9abf 100644 --- a/netwerk/base/nsINetworkInterceptController.idl +++ b/netwerk/base/nsINetworkInterceptController.idl @@ -192,35 +192,33 @@ interface nsIInterceptedChannel : nsISupports GetSubresourceTimeStampKey(nsIChannel* aChannel, nsACString& aKey) { if (!nsContentUtils::IsNonSubresourceRequest(aChannel)) { - nsCOMPtr 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 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; } } } diff --git a/netwerk/base/nsIOService.cpp b/netwerk/base/nsIOService.cpp index a730eff7f56c..417db87b7114 100644 --- a/netwerk/base/nsIOService.cpp +++ b/netwerk/base/nsIOService.cpp @@ -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 channel; nsCOMPtr 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 loadInfo = channel->GetLoadInfo(); + nsCOMPtr 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 loadInfo = channel->GetLoadInfo(); - nsCOMPtr principal; - if (loadInfo) { - principal = loadInfo->LoadingPrincipal(); - } + nsCOMPtr loadInfo = channel->LoadInfo(); + nsCOMPtr principal = loadInfo->LoadingPrincipal(); nsLoadFlags loadFlags = 0; channel->GetLoadFlags(&loadFlags); diff --git a/netwerk/base/nsIProtocolHandler.idl b/netwerk/base/nsIProtocolHandler.idl index 58a166d2313e..bacb0fed78a8 100644 --- a/netwerk/base/nsIProtocolHandler.idl +++ b/netwerk/base/nsIProtocolHandler.idl @@ -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. diff --git a/netwerk/base/nsNetUtil.cpp b/netwerk/base/nsNetUtil.cpp index c28552886590..f00056aa8dce 100644 --- a/netwerk/base/nsNetUtil.cpp +++ b/netwerk/base/nsNetUtil.cpp @@ -232,10 +232,7 @@ nsresult NS_NewChannelInternal( } if (aPerformanceStorage) { - nsCOMPtr loadInfo; - rv = channel->GetLoadInfo(getter_AddRefs(loadInfo)); - NS_ENSURE_SUCCESS(rv, rv); - + nsCOMPtr loadInfo = channel->LoadInfo(); loadInfo->SetPerformanceStorage(aPerformanceStorage); } @@ -387,10 +384,7 @@ nsresult NS_NewChannelInternal( } if (aPerformanceStorage) { - nsCOMPtr loadInfo; - rv = channel->GetLoadInfo(getter_AddRefs(loadInfo)); - NS_ENSURE_SUCCESS(rv, rv); - + nsCOMPtr 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 loadInfo = aChannel->GetLoadInfo(); - // For some channels, they might not have loadInfo, like - // ExternalHelperAppParent.. - if (loadInfo) { - loadInfo->GetOriginAttributes(&aAttributes); - } + nsCOMPtr loadInfo = aChannel->LoadInfo(); + loadInfo->GetOriginAttributes(&aAttributes); bool isPrivate = false; nsCOMPtr pbChannel = do_QueryInterface(aChannel); @@ -1726,15 +1717,7 @@ bool NS_GetOriginAttributes(nsIChannel *aChannel, } bool NS_HasBeenCrossOrigin(nsIChannel *aChannel, bool aReport) { - nsCOMPtr loadInfo = aChannel->GetLoadInfo(); - MOZ_RELEASE_ASSERT( - loadInfo, - "Origin tracking only works for channels created with a loadinfo"); - - if (!loadInfo) { - return false; - } - + nsCOMPtr 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 loadInfo = aChannel->GetLoadInfo(); - if (!loadInfo) { - return false; - } + nsCOMPtr 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 loadInfo = aChannel->GetLoadInfo(); - if (!loadInfo) { - return false; - } - + nsCOMPtr loadInfo = aChannel->LoadInfo(); // Do not treat loads triggered by web extensions as foreign nsCOMPtr channelURI; NS_GetFinalChannelURI(aChannel, getter_AddRefs(channelURI)); @@ -2024,16 +2000,13 @@ already_AddRefed NS_GetInnermostURI(nsIURI *aURI) { nsresult NS_GetFinalChannelURI(nsIChannel *channel, nsIURI **uri) { *uri = nullptr; - nsCOMPtr loadInfo = channel->GetLoadInfo(); - if (loadInfo) { - nsCOMPtr resultPrincipalURI; - loadInfo->GetResultPrincipalURI(getter_AddRefs(resultPrincipalURI)); - if (resultPrincipalURI) { - resultPrincipalURI.forget(uri); - return NS_OK; - } + nsCOMPtr loadInfo = channel->LoadInfo(); + nsCOMPtr 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 loadInfo = aChannel->GetLoadInfo(); + nsCOMPtr loadInfo = aChannel->LoadInfo(); return aChannel->Open(aStream); } nsresult NS_MaybeOpenChannelUsingAsyncOpen(nsIChannel *aChannel, nsIStreamListener *aListener) { - nsCOMPtr loadInfo = aChannel->GetLoadInfo(); + nsCOMPtr loadInfo = aChannel->LoadInfo(); return aChannel->AsyncOpen(aListener); } @@ -2688,12 +2661,11 @@ nsresult NS_GetSecureUpgradedURI(nsIURI *aURI, nsIURI **aUpgradedURI) { } nsresult NS_CompareLoadInfoAndLoadContext(nsIChannel *aChannel) { - nsCOMPtr loadInfo; - aChannel->GetLoadInfo(getter_AddRefs(loadInfo)); + nsCOMPtr loadInfo = aChannel->LoadInfo(); nsCOMPtr loadContext; NS_QueryNotificationCallbacks(aChannel, loadContext); - if (!loadInfo || !loadContext) { + if (!loadContext) { return NS_OK; } diff --git a/netwerk/cookie/CookieServiceChild.cpp b/netwerk/cookie/CookieServiceChild.cpp index 62dbbc02bd39..78b90522348d 100644 --- a/netwerk/cookie/CookieServiceChild.cpp +++ b/netwerk/cookie/CookieServiceChild.cpp @@ -176,11 +176,8 @@ void CookieServiceChild::TrackCookieLoad(nsIChannel *aChannel) { rejectedReason); } } - nsCOMPtr loadInfo = aChannel->GetLoadInfo(); - mozilla::OriginAttributes attrs; - if (loadInfo) { - attrs = loadInfo->GetOriginAttributes(); - } + nsCOMPtr 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 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 loadInfo = aChannel->GetLoadInfo(); - if (loadInfo) { - attrs = loadInfo->GetOriginAttributes(); - } + nsCOMPtr loadInfo = aChannel->LoadInfo(); + attrs = loadInfo->GetOriginAttributes(); } else { SerializeURI(nullptr, channelURIParams); } diff --git a/netwerk/cookie/CookieServiceParent.cpp b/netwerk/cookie/CookieServiceParent.cpp index dc02e2c2bced..717ac4781d6c 100644 --- a/netwerk/cookie/CookieServiceParent.cpp +++ b/netwerk/cookie/CookieServiceParent.cpp @@ -132,11 +132,8 @@ void CookieServiceParent::TrackCookieLoad(nsIChannel *aChannel) { nsCOMPtr uri; aChannel->GetURI(getter_AddRefs(uri)); - nsCOMPtr loadInfo = aChannel->GetLoadInfo(); - mozilla::OriginAttributes attrs; - if (loadInfo) { - attrs = loadInfo->GetOriginAttributes(); - } + nsCOMPtr loadInfo = aChannel->LoadInfo(); + mozilla::OriginAttributes attrs = loadInfo->GetOriginAttributes(); bool isSafeTopLevelNav = NS_IsSafeTopLevelNav(aChannel); bool aIsSameSiteForeign = NS_IsSameSiteForeign(aChannel, uri); diff --git a/netwerk/cookie/nsCookieService.cpp b/netwerk/cookie/nsCookieService.cpp index e795441108b8..12e007db3f54 100644 --- a/netwerk/cookie/nsCookieService.cpp +++ b/netwerk/cookie/nsCookieService.cpp @@ -3390,10 +3390,9 @@ bool nsCookieService::CanSetCookie(nsIURI *aHostURI, const nsCookieKey &aKey, if (aChannel) { nsCOMPtr channelURI; NS_GetFinalChannelURI(aChannel, getter_AddRefs(channelURI)); - nsCOMPtr loadInfo = aChannel->GetLoadInfo(); - addonAllowsLoad = - loadInfo && BasePrincipal::Cast(loadInfo->TriggeringPrincipal()) - ->AddonAllowsLoad(channelURI); + nsCOMPtr loadInfo = aChannel->LoadInfo(); + addonAllowsLoad = BasePrincipal::Cast(loadInfo->TriggeringPrincipal()) + ->AddonAllowsLoad(channelURI); } if (!addonAllowsLoad) { diff --git a/netwerk/ipc/ChannelEventQueue.cpp b/netwerk/ipc/ChannelEventQueue.cpp index 8be2e4b29b13..52ad611b0514 100644 --- a/netwerk/ipc/ChannelEventQueue.cpp +++ b/netwerk/ipc/ChannelEventQueue.cpp @@ -186,11 +186,7 @@ bool ChannelEventQueue::MaybeSuspendIfEventsAreSuppressed() { return false; } - nsCOMPtr loadInfo = channel->GetLoadInfo(); - if (!loadInfo) { - return false; - } - + nsCOMPtr loadInfo = channel->LoadInfo(); // Figure out if this is for an XHR, if we haven't done so already. if (!mHasCheckedForXMLHttpRequest) { nsContentPolicyType contentType = loadInfo->InternalContentPolicyType(); diff --git a/netwerk/protocol/about/nsAboutProtocolHandler.cpp b/netwerk/protocol/about/nsAboutProtocolHandler.cpp index e282405044a5..9fad45075ea7 100644 --- a/netwerk/protocol/about/nsAboutProtocolHandler.cpp +++ b/netwerk/protocol/about/nsAboutProtocolHandler.cpp @@ -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 loadInfo = (*result)->GetLoadInfo(); + nsCOMPtr 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; } diff --git a/netwerk/protocol/data/nsDataHandler.cpp b/netwerk/protocol/data/nsDataHandler.cpp index 2a2db1cfc689..3c0ed1a08a4c 100644 --- a/netwerk/protocol/data/nsDataHandler.cpp +++ b/netwerk/protocol/data/nsDataHandler.cpp @@ -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. diff --git a/netwerk/protocol/file/nsFileProtocolHandler.cpp b/netwerk/protocol/file/nsFileProtocolHandler.cpp index bf6757c11f65..b56c394da5e3 100644 --- a/netwerk/protocol/file/nsFileProtocolHandler.cpp +++ b/netwerk/protocol/file/nsFileProtocolHandler.cpp @@ -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) { diff --git a/netwerk/protocol/ftp/nsFtpProtocolHandler.cpp b/netwerk/protocol/ftp/nsFtpProtocolHandler.cpp index 8ab38cabe84a..33268f3125a4 100644 --- a/netwerk/protocol/ftp/nsFtpProtocolHandler.cpp +++ b/netwerk/protocol/ftp/nsFtpProtocolHandler.cpp @@ -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, diff --git a/netwerk/protocol/gio/nsGIOProtocolHandler.cpp b/netwerk/protocol/gio/nsGIOProtocolHandler.cpp index 85ef0ab9ba05..2640d644bfec 100644 --- a/netwerk/protocol/gio/nsGIOProtocolHandler.cpp +++ b/netwerk/protocol/gio/nsGIOProtocolHandler.cpp @@ -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) { diff --git a/netwerk/protocol/http/HttpBaseChannel.cpp b/netwerk/protocol/http/HttpBaseChannel.cpp index 659bf517c22f..8bd9a7659be5 100644 --- a/netwerk/protocol/http/HttpBaseChannel.cpp +++ b/netwerk/protocol/http/HttpBaseChannel.cpp @@ -2581,9 +2581,6 @@ nsresult HttpBaseChannel::AddSecurityMessage( nsCOMPtr 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 newLoadInfo = newChannel->GetLoadInfo(); - if (newLoadInfo) { - nsCOMPtr resultPrincipalURI; - rv = newLoadInfo->GetResultPrincipalURI(getter_AddRefs(resultPrincipalURI)); + nsCOMPtr newLoadInfo = newChannel->LoadInfo(); + nsCOMPtr 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; diff --git a/netwerk/protocol/http/HttpChannelParent.cpp b/netwerk/protocol/http/HttpChannelParent.cpp index 79187644dd89..6839c15537b6 100644 --- a/netwerk/protocol/http/HttpChannelParent.cpp +++ b/netwerk/protocol/http/HttpChannelParent.cpp @@ -445,10 +445,6 @@ bool HttpChannelParent::DoAsyncOpen( return SendFailedAsyncOpen(rv); } - if (!loadInfo) { - return SendFailedAsyncOpen(NS_ERROR_UNEXPECTED); - } - nsCOMPtr channel; rv = NS_NewChannelInternal(getter_AddRefs(channel), uri, loadInfo, nullptr, nullptr, nullptr, aLoadFlags, ios); diff --git a/netwerk/protocol/http/TrackingDummyChannelChild.cpp b/netwerk/protocol/http/TrackingDummyChannelChild.cpp index f3dc9f90d64c..6395d77664a0 100644 --- a/netwerk/protocol/http/TrackingDummyChannelChild.cpp +++ b/netwerk/protocol/http/TrackingDummyChannelChild.cpp @@ -32,11 +32,7 @@ namespace net { nsresult topWindowURIResult = httpChannelInternal->GetTopWindowURI(getter_AddRefs(topWindowURI)); - nsCOMPtr loadInfo = aChannel->GetLoadInfo(); - if (!loadInfo) { - return false; - } - + nsCOMPtr loadInfo = aChannel->LoadInfo(); OptionalLoadInfoArgs loadInfoArgs; mozilla::ipc::LoadInfoToLoadInfoArgs(loadInfo, &loadInfoArgs); diff --git a/netwerk/protocol/http/nsCORSListenerProxy.cpp b/netwerk/protocol/http/nsCORSListenerProxy.cpp index 9caf7d21b83f..8538f5c95507 100644 --- a/netwerk/protocol/http/nsCORSListenerProxy.cpp +++ b/netwerk/protocol/http/nsCORSListenerProxy.cpp @@ -532,8 +532,8 @@ nsresult nsCORSListenerProxy::CheckRequestApproved(nsIRequest* aRequest) { return NS_ERROR_DOM_BAD_URI; } - nsCOMPtr loadInfo = http->GetLoadInfo(); - if (loadInfo && loadInfo->GetServiceWorkerTaintingSynthesized()) { + nsCOMPtr 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 loadInfo; - rv = aChannel->GetLoadInfo(getter_AddRefs(loadInfo)); - NS_ENSURE_SUCCESS(rv, false); - - if (!loadInfo) { - return false; - } - + nsCOMPtr 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 loadInfo = aChannel->GetLoadInfo(); + nsCOMPtr 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 loadInfo = aChannel->GetLoadInfo(); - if (!loadInfo || - loadInfo->GetSecurityMode() != + nsCOMPtr 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 channel = do_QueryInterface(aRequest); - nsCOMPtr loadInfo = channel ? channel->GetLoadInfo() : nullptr; + nsCOMPtr 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 originalLoadInfo = aRequestChannel->GetLoadInfo(); - MOZ_ASSERT(originalLoadInfo, - "can not perform CORS preflight without a loadInfo"); - if (!originalLoadInfo) { - return NS_ERROR_FAILURE; - } - + nsCOMPtr originalLoadInfo = aRequestChannel->LoadInfo(); MOZ_ASSERT(originalLoadInfo->GetSecurityMode() == nsILoadInfo::SEC_REQUIRE_CORS_DATA_INHERITS, "how did we end up here?"); diff --git a/netwerk/protocol/http/nsHttpChannel.cpp b/netwerk/protocol/http/nsHttpChannel.cpp index f55723326a52..6fd834445c5b 100644 --- a/netwerk/protocol/http/nsHttpChannel.cpp +++ b/netwerk/protocol/http/nsHttpChannel.cpp @@ -3668,7 +3668,7 @@ nsresult nsHttpChannel::ProcessFallback(bool *waitingForRedirectCallback) { // Create a new channel to load the fallback entry. RefPtr 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; diff --git a/netwerk/protocol/http/nsHttpChannelAuthProvider.cpp b/netwerk/protocol/http/nsHttpChannelAuthProvider.cpp index 56ee35a66d00..670b3e74ec9b 100644 --- a/netwerk/protocol/http/nsHttpChannelAuthProvider.cpp +++ b/netwerk/protocol/http/nsHttpChannelAuthProvider.cpp @@ -899,47 +899,44 @@ bool nsHttpChannelAuthProvider::BlockPrompt(bool proxyAuth) { } nsCOMPtr chan = do_QueryInterface(mAuthChannel); - nsCOMPtr loadInfo; - chan->GetLoadInfo(getter_AddRefs(loadInfo)); + nsCOMPtr 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 triggeringPrinc = loadInfo->TriggeringPrincipal(); - if (nsContentUtils::IsSystemPrincipal(triggeringPrinc)) { - nonWebContent = true; + if (!topDoc) { + nsCOMPtr triggeringPrinc = loadInfo->TriggeringPrincipal(); + if (nsContentUtils::IsSystemPrincipal(triggeringPrinc)) { + nonWebContent = true; + } + } + + if (loadInfo->GetExternalContentPolicyType() == + nsIContentPolicy::TYPE_XMLHTTPREQUEST) { + xhr = true; + } + + if (!topDoc && !xhr) { + nsCOMPtr topURI; + Unused << chanInternal->GetTopWindowURI(getter_AddRefs(topURI)); + + if (!topURI) { + // If we do not have topURI try the loadingPrincipal. + nsCOMPtr loadingPrinc = loadInfo->LoadingPrincipal(); + if (loadingPrinc) { + loadingPrinc->GetURI(getter_AddRefs(topURI)); } } - if (loadInfo->GetExternalContentPolicyType() == - nsIContentPolicy::TYPE_XMLHTTPREQUEST) { - xhr = true; - } - - if (!topDoc && !xhr) { - nsCOMPtr topURI; - Unused << chanInternal->GetTopWindowURI(getter_AddRefs(topURI)); - - if (!topURI) { - // If we do not have topURI try the loadingPrincipal. - nsCOMPtr 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; } } diff --git a/netwerk/protocol/http/nsHttpHandler.cpp b/netwerk/protocol/http/nsHttpHandler.cpp index 7a5ff55de832..59299f02a9df 100644 --- a/netwerk/protocol/http/nsHttpHandler.cpp +++ b/netwerk/protocol/http/nsHttpHandler.cpp @@ -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 diff --git a/netwerk/protocol/res/SubstitutingProtocolHandler.cpp b/netwerk/protocol/res/SubstitutingProtocolHandler.cpp index 644bfde08191..d42bd6fb6276 100644 --- a/netwerk/protocol/res/SubstitutingProtocolHandler.cpp +++ b/netwerk/protocol/res/SubstitutingProtocolHandler.cpp @@ -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) { diff --git a/netwerk/protocol/viewsource/nsViewSourceChannel.cpp b/netwerk/protocol/viewsource/nsViewSourceChannel.cpp index a02c9a9f1b68..37012a2ff9fc 100644 --- a/netwerk/protocol/viewsource/nsViewSourceChannel.cpp +++ b/netwerk/protocol/viewsource/nsViewSourceChannel.cpp @@ -136,11 +136,7 @@ nsresult nsViewSourceChannel::UpdateLoadInfoResultPrincipalURI() { MOZ_ASSERT(mChannel); - nsCOMPtr channelLoadInfo = mChannel->GetLoadInfo(); - if (!channelLoadInfo) { - return NS_OK; - } - + nsCOMPtr channelLoadInfo = mChannel->LoadInfo(); nsCOMPtr 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 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 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); diff --git a/netwerk/protocol/viewsource/nsViewSourceHandler.cpp b/netwerk/protocol/viewsource/nsViewSourceHandler.cpp index f78ace944e64..a8d0a1161d10 100644 --- a/netwerk/protocol/viewsource/nsViewSourceHandler.cpp +++ b/netwerk/protocol/viewsource/nsViewSourceHandler.cpp @@ -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, diff --git a/netwerk/protocol/websocket/BaseWebSocketChannel.cpp b/netwerk/protocol/websocket/BaseWebSocketChannel.cpp index 1b7d3b29f1f6..533e6aa971b0 100644 --- a/netwerk/protocol/websocket/BaseWebSocketChannel.cpp +++ b/netwerk/protocol/websocket/BaseWebSocketChannel.cpp @@ -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; } diff --git a/netwerk/protocol/wyciwyg/WyciwygChannelParent.cpp b/netwerk/protocol/wyciwyg/WyciwygChannelParent.cpp index 205a5281ae61..8f0640474096 100644 --- a/netwerk/protocol/wyciwyg/WyciwygChannelParent.cpp +++ b/netwerk/protocol/wyciwyg/WyciwygChannelParent.cpp @@ -111,10 +111,8 @@ mozilla::ipc::IPCResult WyciwygChannelParent::RecvInit( return IPC_OK(); } - nsCOMPtr loadInfo = chan->GetLoadInfo(); - if (loadInfo) { - rv = loadInfo->SetPrincipalToInherit(principalToInherit); - } + nsCOMPtr 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 loadInfo = mChannel->GetLoadInfo(); + nsCOMPtr loadInfo = mChannel->LoadInfo(); rv = mChannel->AsyncOpen(this); if (NS_FAILED(rv)) { diff --git a/netwerk/protocol/wyciwyg/nsWyciwygProtocolHandler.cpp b/netwerk/protocol/wyciwyg/nsWyciwygProtocolHandler.cpp index 18c009e34054..ab84f63281be 100644 --- a/netwerk/protocol/wyciwyg/nsWyciwygProtocolHandler.cpp +++ b/netwerk/protocol/wyciwyg/nsWyciwygProtocolHandler.cpp @@ -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 diff --git a/netwerk/test/browser/browser_nsIFormPOSTActionChannel.js b/netwerk/test/browser/browser_nsIFormPOSTActionChannel.js index 0b647723064e..b33b771038f4 100644 --- a/netwerk/test/browser/browser_nsIFormPOSTActionChannel.js +++ b/netwerk/test/browser/browser_nsIFormPOSTActionChannel.js @@ -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; }, diff --git a/netwerk/test/unit/test_bug894586.js b/netwerk/test/unit/test_bug894586.js index aad816b3b43d..2e94763bec48 100644 --- a/netwerk/test/unit/test_bug894586.js +++ b/netwerk/test/unit/test_bug894586.js @@ -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; }, diff --git a/netwerk/test/unit/test_protocolproxyservice-async-filters.js b/netwerk/test/unit/test_protocolproxyservice-async-filters.js index deba7a1db4ab..90267c5bdc7a 100644 --- a/netwerk/test/unit/test_protocolproxyservice-async-filters.js +++ b/netwerk/test/unit/test_protocolproxyservice-async-filters.js @@ -43,10 +43,7 @@ TestProtocolHandler.prototype = { .setSpec(spec) .finalize(); }, - newChannel2: function(uri, aLoadInfo) { - throw Cr.NS_ERROR_NOT_IMPLEMENTED; - }, - newChannel: function(uri) { + newChannel: function(uri, aLoadInfo) { throw Cr.NS_ERROR_NOT_IMPLEMENTED; }, allowPort: function(port, scheme) { diff --git a/netwerk/test/unit/test_protocolproxyservice.js b/netwerk/test/unit/test_protocolproxyservice.js index a570b44c4f0c..faf7caef874c 100644 --- a/netwerk/test/unit/test_protocolproxyservice.js +++ b/netwerk/test/unit/test_protocolproxyservice.js @@ -54,10 +54,7 @@ TestProtocolHandler.prototype = { .setSpec(spec) .finalize(); }, - newChannel2: function(uri, aLoadInfo) { - throw Cr.NS_ERROR_NOT_IMPLEMENTED; - }, - newChannel: function(uri) { + newChannel: function(uri, aLoadInfo) { throw Cr.NS_ERROR_NOT_IMPLEMENTED; }, allowPort: function(port, scheme) { diff --git a/netwerk/url-classifier/UrlClassifierCommon.cpp b/netwerk/url-classifier/UrlClassifierCommon.cpp index fd9a20f1cf2f..3a67e5380dd6 100644 --- a/netwerk/url-classifier/UrlClassifierCommon.cpp +++ b/netwerk/url-classifier/UrlClassifierCommon.cpp @@ -33,11 +33,7 @@ LazyLogModule UrlClassifierCommon::sLog("nsChannelClassifier"); /* static */ bool UrlClassifierCommon::AddonMayLoad(nsIChannel* aChannel, nsIURI* aURI) { - nsCOMPtr channelLoadInfo = aChannel->GetLoadInfo(); - if (!channelLoadInfo) { - return false; - } - + nsCOMPtr channelLoadInfo = aChannel->LoadInfo(); // loadingPrincipal is used here to ensure we are loading into an // addon principal. This allows an addon, with explicit permission, to // call out to API endpoints that may otherwise get blocked. diff --git a/netwerk/url-classifier/UrlClassifierFeatureFlash.cpp b/netwerk/url-classifier/UrlClassifierFeatureFlash.cpp index 80169c1fa1b8..1ae076f7413c 100644 --- a/netwerk/url-classifier/UrlClassifierFeatureFlash.cpp +++ b/netwerk/url-classifier/UrlClassifierFeatureFlash.cpp @@ -98,10 +98,9 @@ UrlClassifierFeatureFlash::UrlClassifierFeatureFlash( } // We use Flash feature just for document loading. - nsCOMPtr loadInfo = aChannel->GetLoadInfo(); + nsCOMPtr loadInfo = aChannel->LoadInfo(); nsContentPolicyType contentPolicyType = - loadInfo ? loadInfo->GetExternalContentPolicyType() - : nsIContentPolicy::TYPE_INVALID; + loadInfo->GetExternalContentPolicyType(); if (contentPolicyType != nsIContentPolicy::TYPE_DOCUMENT && contentPolicyType != nsIContentPolicy::TYPE_SUBDOCUMENT) { diff --git a/netwerk/wifi/moz.build b/netwerk/wifi/moz.build index fcc85db476e9..7aef5e2e01f2 100644 --- a/netwerk/wifi/moz.build +++ b/netwerk/wifi/moz.build @@ -54,6 +54,3 @@ if CONFIG['NECKO_WIFI_DBUS']: CXXFLAGS += CONFIG['MOZ_DBUS_GLIB_CFLAGS'] FINAL_LIBRARY = 'xul' - -if CONFIG['CC_TYPE'] == 'clang-cl': - AllowCompilerWarnings() # workaround for bug 1090497 diff --git a/netwerk/wifi/win_wifiScanner.cpp b/netwerk/wifi/win_wifiScanner.cpp index 9114f70c5f4f..bb7e19aa1304 100644 --- a/netwerk/wifi/win_wifiScanner.cpp +++ b/netwerk/wifi/win_wifiScanner.cpp @@ -42,7 +42,8 @@ class InterfaceScanCallbackData { HANDLE mAllInterfacesDoneScanningEvent; }; -static void OnScanComplete(PWLAN_NOTIFICATION_DATA data, PVOID context) { +static void WINAPI OnScanComplete(PWLAN_NOTIFICATION_DATA data, + PVOID context) { if (WLAN_NOTIFICATION_SOURCE_ACM != data->NotificationSource) { return; } diff --git a/nsprpub/TAG-INFO b/nsprpub/TAG-INFO index a5291854a14c..bd7576465573 100644 --- a/nsprpub/TAG-INFO +++ b/nsprpub/TAG-INFO @@ -1 +1 @@ -753fe0f7964c +NSPR_4_21_BETA1 diff --git a/nsprpub/config/prdepend.h b/nsprpub/config/prdepend.h index e49e92677e3e..6c66b37ca0fc 100644 --- a/nsprpub/config/prdepend.h +++ b/nsprpub/config/prdepend.h @@ -10,3 +10,4 @@ */ #error "Do not include this header file." + diff --git a/nsprpub/pr/src/io/pripv6.c b/nsprpub/pr/src/io/pripv6.c index cdd1ce549181..a164ae7c8f57 100644 --- a/nsprpub/pr/src/io/pripv6.c +++ b/nsprpub/pr/src/io/pripv6.c @@ -16,8 +16,8 @@ static PRIOMethods ipv6_to_v4_tcpMethods; static PRIOMethods ipv6_to_v4_udpMethods; static PRDescIdentity _pr_ipv6_to_ipv4_id; extern PRBool IsValidNetAddr(const PRNetAddr *addr); -extern PRIPv6Addr _pr_in6addr_any; -extern PRIPv6Addr _pr_in6addr_loopback; +extern const PRIPv6Addr _pr_in6addr_any; +extern const PRIPv6Addr _pr_in6addr_loopback; /* * convert an IPv4-mapped IPv6 addr to an IPv4 addr diff --git a/nsprpub/pr/src/md/unix/unix.c b/nsprpub/pr/src/md/unix/unix.c index 7c90b5075b7f..32ad3321feae 100644 --- a/nsprpub/pr/src/md/unix/unix.c +++ b/nsprpub/pr/src/md/unix/unix.c @@ -3569,12 +3569,20 @@ PRStatus _MD_CreateFileMap(PRFileMap *fmap, PRInt64 size) } if (fmap->prot == PR_PROT_READONLY) { fmap->md.prot = PROT_READ; -#ifdef OSF1V4_MAP_PRIVATE_BUG +#if defined(OSF1V4_MAP_PRIVATE_BUG) || defined(DARWIN) || defined(ANDROID) /* * Use MAP_SHARED to work around a bug in OSF1 V4.0D * (QAR 70220 in the OSF_QAR database) that results in * corrupted data in the memory-mapped region. This * bug is fixed in V5.0. + * + * This is also needed on OS X because its implementation of + * POSIX shared memory returns an error for MAP_PRIVATE, even + * when the mapping is read-only. + * + * And this is needed on Android, because mapping ashmem with + * MAP_PRIVATE creates a mapping of zeroed memory instead of + * the shm contents. */ fmap->md.flags = MAP_SHARED; #else diff --git a/python/mozboot/mozboot/base.py b/python/mozboot/mozboot/base.py index 661bac52689f..afca4f9a79fe 100644 --- a/python/mozboot/mozboot/base.py +++ b/python/mozboot/mozboot/base.py @@ -153,6 +153,9 @@ MODERN_PYTHON_VERSION = LooseVersion('2.7.3') # Upgrade rust older than this. MODERN_RUST_VERSION = LooseVersion('1.32.0') +# Upgrade nasm older than this. +MODERN_NASM_VERSION = LooseVersion('2.14') + class BaseBootstrapper(object): """Base class for system bootstrappers.""" @@ -453,7 +456,7 @@ class BaseBootstrapper(object): This should be defined in child classes. """ - def _parse_version(self, path, name=None, env=None): + def _parse_version_impl(self, path, name, env, version_param): '''Execute the given path, returning the version. Invokes the path argument with the --version switch @@ -473,7 +476,7 @@ class BaseBootstrapper(object): if name.endswith('.exe'): name = name[:-4] - info = self.check_output([path, '--version'], + info = self.check_output([path, version_param], env=env, stderr=subprocess.STDOUT) match = re.search(name + ' ([a-z0-9\.]+)', info) @@ -483,6 +486,12 @@ class BaseBootstrapper(object): return LooseVersion(match.group(1)) + def _parse_version(self, path, name=None, env=None): + return self._parse_version_impl(path, name, env, "--version") + + def _parse_version_short(self, path, name=None, env=None): + return self._parse_version_impl(path, name, env, "-v") + def _hg_cleanenv(self, load_hgrc=False): """ Returns a copy of the current environment updated with the HGPLAIN and HGRCPATH environment variables. @@ -593,6 +602,17 @@ class BaseBootstrapper(object): """ print(PYTHON_UNABLE_UPGRADE % (current, MODERN_PYTHON_VERSION)) + def is_nasm_modern(self): + nasm = self.which('nasm') + if not nasm: + return False + + our = self._parse_version_short(nasm, 'version') + if not our: + return False + + return our >= MODERN_NASM_VERSION + def is_rust_modern(self, cargo_bin): rustc = self.which('rustc', cargo_bin) if not rustc: diff --git a/python/mozboot/mozboot/debian.py b/python/mozboot/mozboot/debian.py index 40769960f6ec..bba092cec1be 100644 --- a/python/mozboot/mozboot/debian.py +++ b/python/mozboot/mozboot/debian.py @@ -66,7 +66,6 @@ class DebianBootstrapper(NodeInstall, StyloInstall, ClangStaticAnalysisInstall, 'libpulse-dev', 'libx11-xcb-dev', 'libxt-dev', - 'nasm', 'python-dbus', 'xvfb', 'yasm', @@ -132,6 +131,9 @@ class DebianBootstrapper(NodeInstall, StyloInstall, ClangStaticAnalysisInstall, def ensure_browser_packages(self, artifact_mode=False): # TODO: Figure out what not to install for artifact mode self.apt_install(*self.browser_packages) + modern = self.is_nasm_modern() + if not modern: + self.apt_install('nasm') def ensure_mobile_android_packages(self, artifact_mode=False): # Multi-part process: diff --git a/security/manager/ssl/nsNSSCallbacks.cpp b/security/manager/ssl/nsNSSCallbacks.cpp index bf431d358efc..549c87d7f59e 100644 --- a/security/manager/ssl/nsNSSCallbacks.cpp +++ b/security/manager/ssl/nsNSSCallbacks.cpp @@ -271,10 +271,7 @@ OCSPRequest::Run() { attrs.mFirstPartyDomain = mOriginAttributes.mFirstPartyDomain; attrs.mPrivateBrowsingId = mOriginAttributes.mPrivateBrowsingId; - nsCOMPtr loadInfo = channel->GetLoadInfo(); - if (!loadInfo) { - return NotifyDone(NS_ERROR_FAILURE, lock); - } + nsCOMPtr loadInfo = channel->LoadInfo(); rv = loadInfo->SetOriginAttributes(attrs); if (NS_FAILED(rv)) { return NotifyDone(rv, lock); diff --git a/security/sandbox/moz.build b/security/sandbox/moz.build index 97cf2e5dda9f..28283f05528c 100755 --- a/security/sandbox/moz.build +++ b/security/sandbox/moz.build @@ -178,6 +178,3 @@ elif CONFIG['OS_ARCH'] == 'WINNT': '-wd4311', # 'reinterpret_cast': pointer truncation from 'LPOVERLAPPED' to 'DWORD' '-wd4312', # 'reinterpret_cast': conversion from 'DWORD' to 'LPOVERLAPPED' of greater size ] - -if CONFIG['CC_TYPE'] == 'clang-cl': - AllowCompilerWarnings() # workaround for bug 1090497 diff --git a/security/sandbox/win/SandboxInitialization.cpp b/security/sandbox/win/SandboxInitialization.cpp index 406a83f42577..a38b0f4dea99 100644 --- a/security/sandbox/win/SandboxInitialization.cpp +++ b/security/sandbox/win/SandboxInitialization.cpp @@ -131,7 +131,7 @@ static sandbox::BrokerServices* InitializeBrokerServices() { // the process to swap its window station. During this time all the UI // will be broken. This has to run before threads and windows are created. scoped_refptr policy = brokerServices->CreatePolicy(); - sandbox::ResultCode result = policy->CreateAlternateDesktop(true); + policy->CreateAlternateDesktop(true); return brokerServices; } diff --git a/security/sandbox/win/src/sandboxbroker/moz.build b/security/sandbox/win/src/sandboxbroker/moz.build index f06bd3c6955c..cf97b038865b 100644 --- a/security/sandbox/win/src/sandboxbroker/moz.build +++ b/security/sandbox/win/src/sandboxbroker/moz.build @@ -19,6 +19,3 @@ LOCAL_INCLUDES += ['/security/sandbox/chromium-shim'] LOCAL_INCLUDES += ['/security/sandbox/chromium'] FINAL_LIBRARY = 'xul' - -if CONFIG['CC_TYPE'] == 'clang-cl': - AllowCompilerWarnings() # workaround for bug 1090497 diff --git a/security/sandbox/win/src/sandboxbroker/sandboxBroker.cpp b/security/sandbox/win/src/sandboxbroker/sandboxBroker.cpp index 5df5aee2f6f3..7e5bae8e817a 100644 --- a/security/sandbox/win/src/sandboxbroker/sandboxBroker.cpp +++ b/security/sandbox/win/src/sandboxbroker/sandboxBroker.cpp @@ -594,14 +594,14 @@ void SandboxBroker::SetSecurityLevelForGPUProcess(int32_t aSandboxLevel) { // The setting of these levels is pretty arbitrary, but they are a useful (if // crude) tool while we are tightening the policy. Gaps are left to try and // avoid changing their meaning. - MOZ_RELEASE_ASSERT(aSandboxLevel >= 1, - "Should not be called with aSandboxLevel < 1"); if (aSandboxLevel >= 2) { jobLevel = sandbox::JOB_NONE; accessTokenLevel = sandbox::USER_LIMITED; initialIntegrityLevel = sandbox::INTEGRITY_LEVEL_LOW; delayedIntegrityLevel = sandbox::INTEGRITY_LEVEL_LOW; - } else if (aSandboxLevel == 1) { + } else { + MOZ_RELEASE_ASSERT(aSandboxLevel >= 1, + "Should not be called with aSandboxLevel < 1"); jobLevel = sandbox::JOB_NONE; accessTokenLevel = sandbox::USER_NON_ADMIN; initialIntegrityLevel = sandbox::INTEGRITY_LEVEL_LOW; diff --git a/testing/marionette/browser.js b/testing/marionette/browser.js index 8563d0aec3fb..a0903cbcb60b 100644 --- a/testing/marionette/browser.js +++ b/testing/marionette/browser.js @@ -5,18 +5,24 @@ "use strict"; /* global frame */ +const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm"); +const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); + const {WebElementEventTarget} = ChromeUtils.import("chrome://marionette/content/dom.js"); const {element} = ChromeUtils.import("chrome://marionette/content/element.js"); const { NoSuchWindowError, UnsupportedOperationError, } = ChromeUtils.import("chrome://marionette/content/error.js"); +const {Log} = ChromeUtils.import("chrome://marionette/content/log.js"); const { MessageManagerDestroyedPromise, waitForEvent, waitForObserverTopic, } = ChromeUtils.import("chrome://marionette/content/sync.js"); +XPCOMUtils.defineLazyGetter(this, "logger", Log.get); + this.EXPORTED_SYMBOLS = ["browser", "Context", "WindowState"]; /** @namespace */ @@ -323,12 +329,16 @@ browser.Context = class { await Promise.all([activated, focused, startup]); + logger.trace("Opening window is active window: " + + `${Services.focus.activeWindow == this.window}`); if (!focus) { // The new window shouldn't get focused. As such set the // focus back to the currently selected window. activated = waitForEvent(this.window, "activate"); focused = waitForEvent(this.window, "focus", {capture: true}); + logger.trace("Setting focus back to opening window " + + `due to focus: ${focus}`); this.window.focus(); await Promise.all([activated, focused]); diff --git a/toolkit/components/antitracking/AntiTrackingCommon.cpp b/toolkit/components/antitracking/AntiTrackingCommon.cpp index 949ca7422a7d..6341ffd1b1d9 100644 --- a/toolkit/components/antitracking/AntiTrackingCommon.cpp +++ b/toolkit/components/antitracking/AntiTrackingCommon.cpp @@ -1272,12 +1272,7 @@ bool AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor( ("Computing whether channel %p has access to URI %s", aChannel, _spec), channelURI); - nsCOMPtr loadInfo = aChannel->GetLoadInfo(); - if (!loadInfo) { - LOG(("No loadInfo, bail out early")); - return true; - } - + nsCOMPtr loadInfo = aChannel->LoadInfo(); // We need to find the correct principal to check the cookie permission. For // third-party contexts, we want to check if the top-level window has a custom // cookie permission. diff --git a/toolkit/components/extensions/ExtensionPolicyService.cpp b/toolkit/components/extensions/ExtensionPolicyService.cpp index 4219a74bd763..95f7fb33c3d6 100644 --- a/toolkit/components/extensions/ExtensionPolicyService.cpp +++ b/toolkit/components/extensions/ExtensionPolicyService.cpp @@ -396,11 +396,7 @@ nsresult ExtensionPolicyService::InjectContentScripts( // Checks a request for matching content scripts, and begins pre-loading them // if necessary. void ExtensionPolicyService::CheckRequest(nsIChannel* aChannel) { - nsCOMPtr loadInfo = aChannel->GetLoadInfo(); - if (!loadInfo) { - return; - } - + nsCOMPtr loadInfo = aChannel->LoadInfo(); auto loadType = loadInfo->GetExternalContentPolicyType(); if (loadType != nsIContentPolicy::TYPE_DOCUMENT && loadType != nsIContentPolicy::TYPE_SUBDOCUMENT) { diff --git a/toolkit/components/extensions/WebExtensionPolicy.cpp b/toolkit/components/extensions/WebExtensionPolicy.cpp index d5b6f1fe99fa..1e23b30679b3 100644 --- a/toolkit/components/extensions/WebExtensionPolicy.cpp +++ b/toolkit/components/extensions/WebExtensionPolicy.cpp @@ -745,12 +745,7 @@ bool WindowShouldMatchActiveTab(nsPIDOMWindowOuter* aWin) { return false; } - nsCOMPtr loadInfo = channel->GetLoadInfo(); - - if (!loadInfo) { - return false; - } - + nsCOMPtr loadInfo = channel->LoadInfo(); if (!loadInfo->GetOriginalFrameSrcLoad()) { return false; } diff --git a/toolkit/components/extensions/webrequest/ChannelWrapper.h b/toolkit/components/extensions/webrequest/ChannelWrapper.h index d0c60af31c54..a63f502fe98f 100644 --- a/toolkit/components/extensions/webrequest/ChannelWrapper.h +++ b/toolkit/components/extensions/webrequest/ChannelWrapper.h @@ -180,7 +180,7 @@ class ChannelWrapper final : public DOMEventTargetHelper, already_AddRefed GetLoadInfo() const { nsCOMPtr chan = MaybeChannel(); if (chan) { - return chan->GetLoadInfo(); + return chan->LoadInfo(); } return nullptr; } diff --git a/toolkit/components/mozprotocol/MozProtocolHandler.jsm b/toolkit/components/mozprotocol/MozProtocolHandler.jsm index dfc5238f2594..480b069218d9 100644 --- a/toolkit/components/mozprotocol/MozProtocolHandler.jsm +++ b/toolkit/components/mozprotocol/MozProtocolHandler.jsm @@ -28,7 +28,7 @@ MozProtocolHandler.prototype = { return mutator.finalize(); }, - newChannel2(uri, loadInfo) { + newChannel(uri, loadInfo) { const kCanada = "https://www.mozilla.org/contact/communities/canada/"; let realURL = NetUtil.newURI((uri && uri.spec == "moz://eh") ? kCanada : this.urlToLoad); let channel = Services.io.newChannelFromURIWithLoadInfo(realURL, loadInfo); @@ -36,10 +36,6 @@ MozProtocolHandler.prototype = { return channel; }, - newChannel(uri) { - return this.newChannel2(uri, null); - }, - QueryInterface: ChromeUtils.generateQI([Ci.nsIProtocolHandler]), }; diff --git a/toolkit/components/places/PageIconProtocolHandler.jsm b/toolkit/components/places/PageIconProtocolHandler.jsm index 47770d96c323..85cd4507de0c 100644 --- a/toolkit/components/places/PageIconProtocolHandler.jsm +++ b/toolkit/components/places/PageIconProtocolHandler.jsm @@ -76,7 +76,7 @@ PageIconProtocolHandler.prototype = { .finalize(); }, - newChannel2(uri, loadInfo) { + newChannel(uri, loadInfo) { try { // Create a pipe that will give us an output stream that we can use once // we got all the favicon data. @@ -114,10 +114,6 @@ PageIconProtocolHandler.prototype = { } }, - newChannel(uri) { - return this.newChannel2(uri, null); - }, - allowPort(port, scheme) { return false; }, diff --git a/toolkit/components/places/nsAnnoProtocolHandler.cpp b/toolkit/components/places/nsAnnoProtocolHandler.cpp index a666386b4e82..4dfa6c068c09 100644 --- a/toolkit/components/places/nsAnnoProtocolHandler.cpp +++ b/toolkit/components/places/nsAnnoProtocolHandler.cpp @@ -51,7 +51,7 @@ static nsresult GetDefaultIcon(nsIChannel *aOriginalChannel, nsresult rv = NS_NewURI(getter_AddRefs(defaultIconURI), NS_LITERAL_CSTRING(FAVICON_DEFAULT_URL)); NS_ENSURE_SUCCESS(rv, rv); - nsCOMPtr loadInfo = aOriginalChannel->GetLoadInfo(); + nsCOMPtr loadInfo = aOriginalChannel->LoadInfo(); rv = NS_NewChannelInternal(aChannel, defaultIconURI, loadInfo); NS_ENSURE_SUCCESS(rv, rv); Unused << (*aChannel)->SetContentType( @@ -132,7 +132,7 @@ class faviconAsyncLoader : public AsyncStatementCallback { // Ensure we'll break possible cycles with the listener. auto cleanup = MakeScopeExit([&]() { mListener = nullptr; }); - nsCOMPtr loadInfo = mChannel->GetLoadInfo(); + nsCOMPtr loadInfo = mChannel->LoadInfo(); nsCOMPtr target = nsContentUtils::GetEventTargetByLoadInfo(loadInfo, TaskCategory::Other); if (!mData.IsEmpty()) { @@ -224,8 +224,8 @@ nsAnnoProtocolHandler::NewURI(const nsACString &aSpec, // NS_IMETHODIMP -nsAnnoProtocolHandler::NewChannel2(nsIURI *aURI, nsILoadInfo *aLoadInfo, - nsIChannel **_retval) { +nsAnnoProtocolHandler::NewChannel(nsIURI *aURI, nsILoadInfo *aLoadInfo, + nsIChannel **_retval) { NS_ENSURE_ARG_POINTER(aURI); // annotation info @@ -241,11 +241,6 @@ nsAnnoProtocolHandler::NewChannel2(nsIURI *aURI, nsILoadInfo *aLoadInfo, return NewFaviconChannel(aURI, annoURI, aLoadInfo, _retval); } -NS_IMETHODIMP -nsAnnoProtocolHandler::NewChannel(nsIURI *aURI, nsIChannel **_retval) { - return NewChannel2(aURI, nullptr, _retval); -} - // nsAnnoProtocolHandler::AllowPort // // Don't override any bans on bad ports. diff --git a/toolkit/components/places/nsFaviconService.cpp b/toolkit/components/places/nsFaviconService.cpp index e82cc79540be..aade118ace3b 100644 --- a/toolkit/components/places/nsFaviconService.cpp +++ b/toolkit/components/places/nsFaviconService.cpp @@ -519,7 +519,7 @@ nsFaviconService::ReplaceFaviconDataFromDataURL( nsIContentPolicy::TYPE_INTERNAL_IMAGE_FAVICON); nsCOMPtr channel; - rv = protocolHandler->NewChannel2(dataURI, loadInfo, getter_AddRefs(channel)); + rv = protocolHandler->NewChannel(dataURI, loadInfo, getter_AddRefs(channel)); NS_ENSURE_SUCCESS(rv, rv); // Blocking stream is OK for data URIs. diff --git a/toolkit/components/reputationservice/ApplicationReputation.cpp b/toolkit/components/reputationservice/ApplicationReputation.cpp index c70e217af9eb..b47f8491b331 100644 --- a/toolkit/components/reputationservice/ApplicationReputation.cpp +++ b/toolkit/components/reputationservice/ApplicationReputation.cpp @@ -1592,13 +1592,10 @@ nsresult PendingLookup::SendRemoteQueryInternal(Reason& aReason) { nsIContentPolicy::TYPE_OTHER, getter_AddRefs(mChannel)); NS_ENSURE_SUCCESS(rv, rv); - nsCOMPtr loadInfo = mChannel->GetLoadInfo(); - if (loadInfo) { - mozilla::OriginAttributes attrs; - attrs.mFirstPartyDomain.AssignLiteral( - NECKO_SAFEBROWSING_FIRST_PARTY_DOMAIN); - loadInfo->SetOriginAttributes(attrs); - } + nsCOMPtr loadInfo = mChannel->LoadInfo(); + mozilla::OriginAttributes attrs; + attrs.mFirstPartyDomain.AssignLiteral(NECKO_SAFEBROWSING_FIRST_PARTY_DOMAIN); + loadInfo->SetOriginAttributes(attrs); nsCOMPtr httpChannel(do_QueryInterface(mChannel, &rv)); NS_ENSURE_SUCCESS(rv, rv); diff --git a/toolkit/components/thumbnails/PageThumbsProtocol.cpp b/toolkit/components/thumbnails/PageThumbsProtocol.cpp index 6f07591c2722..19b71c81c2f6 100644 --- a/toolkit/components/thumbnails/PageThumbsProtocol.cpp +++ b/toolkit/components/thumbnails/PageThumbsProtocol.cpp @@ -62,8 +62,8 @@ PageThumbsProtocol::NewURI(const nsACString& aSpec, const char* aOriginCharset, // PageThumbsProtocol::NewChannel NS_IMETHODIMP -PageThumbsProtocol::NewChannel2(nsIURI* aURI, nsILoadInfo* aLoadInfo, - nsIChannel** _retval) { +PageThumbsProtocol::NewChannel(nsIURI* aURI, nsILoadInfo* aLoadInfo, + nsIChannel** _retval) { // Get the file path for the URL nsCOMPtr filePath; nsresult rv = GetFilePathForURL(aURI, getter_AddRefs(filePath)); @@ -86,11 +86,6 @@ PageThumbsProtocol::NewChannel2(nsIURI* aURI, nsILoadInfo* aLoadInfo, return NS_OK; } -NS_IMETHODIMP -PageThumbsProtocol::NewChannel(nsIURI* aURI, nsIChannel** _retval) { - return NewChannel2(aURI, nullptr, _retval); -} - // PageThumbsProtocol::AllowPort NS_IMETHODIMP diff --git a/toolkit/components/thumbnails/test/test_thumbnails_interfaces.js b/toolkit/components/thumbnails/test/test_thumbnails_interfaces.js index 4406366c39aa..f55d4f28c5c9 100644 --- a/toolkit/components/thumbnails/test/test_thumbnails_interfaces.js +++ b/toolkit/components/thumbnails/test/test_thumbnails_interfaces.js @@ -1,6 +1,7 @@ "use strict"; const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm"); +const {NetUtil} = ChromeUtils.import("resource://gre/modules/NetUtil.jsm"); // need profile so that PageThumbsStorageService can resolve the path to the underlying file do_get_profile(); @@ -11,16 +12,21 @@ function run_test() { ok(handler instanceof Ci.nsIProtocolHandler, "moz-page-thumb handler provides a protocol handler interface"); + // create a dummy loadinfo which we can hand to newChannel. + let dummyURI = Services.io.newURI("https://www.example.com/1"); + let dummyChannel = NetUtil.newChannel({uri: dummyURI, loadUsingSystemPrincipal: true}); + let dummyLoadInfo = dummyChannel.loadInfo; + // and check that the error cases work as specified let badhost = Services.io.newURI("moz-page-thumb://wronghost/?url=http%3A%2F%2Fwww.mozilla.org%2F"); - Assert.throws(() => handler.newChannel(badhost), /NS_ERROR_NOT_AVAILABLE/i, + Assert.throws(() => handler.newChannel(badhost, dummyLoadInfo), /NS_ERROR_NOT_AVAILABLE/i, "moz-page-thumb object with wrong host must not resolve to a file path"); let badQuery = Services.io.newURI("moz-page-thumb://thumbnail/http%3A%2F%2Fwww.mozilla.org%2F"); - Assert.throws(() => handler.newChannel(badQuery), /NS_ERROR_MALFORMED_URI/i, + Assert.throws(() => handler.newChannel(badQuery, dummyLoadInfo), /NS_ERROR_MALFORMED_URI/i, "moz-page-thumb object with malformed query parameters must not resolve to a file path"); let noURL = Services.io.newURI("moz-page-thumb://thumbnail/?badStuff"); - Assert.throws(() => handler.newChannel(noURL), /NS_ERROR_NOT_AVAILABLE/i, + Assert.throws(() => handler.newChannel(noURL, dummyLoadInfo), /NS_ERROR_NOT_AVAILABLE/i, "moz-page-thumb object without a URL parameter must not resolve to a file path"); } diff --git a/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp b/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp index eae9bda96011..e3a6b85e303f 100644 --- a/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp +++ b/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp @@ -2000,12 +2000,10 @@ nsUrlClassifierDBService::SendThreatHitReport(nsIChannel* aChannel, nullptr, loadFlags); NS_ENSURE_SUCCESS(rv, rv); - nsCOMPtr loadInfo = reportChannel->GetLoadInfo(); + nsCOMPtr loadInfo = reportChannel->LoadInfo(); mozilla::OriginAttributes attrs; attrs.mFirstPartyDomain.AssignLiteral(NECKO_SAFEBROWSING_FIRST_PARTY_DOMAIN); - if (loadInfo) { - loadInfo->SetOriginAttributes(attrs); - } + loadInfo->SetOriginAttributes(attrs); nsCOMPtr uploadChannel(do_QueryInterface(reportChannel)); NS_ENSURE_TRUE(uploadChannel, NS_ERROR_FAILURE); diff --git a/toolkit/components/url-classifier/nsUrlClassifierStreamUpdater.cpp b/toolkit/components/url-classifier/nsUrlClassifierStreamUpdater.cpp index db67b66e4f4e..39c6fd3a80b3 100644 --- a/toolkit/components/url-classifier/nsUrlClassifierStreamUpdater.cpp +++ b/toolkit/components/url-classifier/nsUrlClassifierStreamUpdater.cpp @@ -140,12 +140,10 @@ nsresult nsUrlClassifierStreamUpdater::FetchUpdate( NS_ENSURE_SUCCESS(rv, rv); - nsCOMPtr loadInfo = mChannel->GetLoadInfo(); + nsCOMPtr loadInfo = mChannel->LoadInfo(); mozilla::OriginAttributes attrs; attrs.mFirstPartyDomain.AssignLiteral(NECKO_SAFEBROWSING_FIRST_PARTY_DOMAIN); - if (loadInfo) { - loadInfo->SetOriginAttributes(attrs); - } + loadInfo->SetOriginAttributes(attrs); mBeganStream = false; diff --git a/toolkit/components/url-classifier/nsUrlClassifierUtils.cpp b/toolkit/components/url-classifier/nsUrlClassifierUtils.cpp index d23b949ebdd6..85ddb9cba3c4 100644 --- a/toolkit/components/url-classifier/nsUrlClassifierUtils.cpp +++ b/toolkit/components/url-classifier/nsUrlClassifierUtils.cpp @@ -661,8 +661,8 @@ static nsresult AddTabThreatSources(ThreatHit& aHit, nsIChannel* aChannel) { bool isTopUri = false; rv = topUri->Equals(uri, &isTopUri); if (NS_SUCCEEDED(rv) && !isTopUri) { - nsCOMPtr loadInfo = aChannel->GetLoadInfo(); - if (loadInfo && loadInfo->RedirectChain().Length()) { + nsCOMPtr loadInfo = aChannel->LoadInfo(); + if (loadInfo->RedirectChain().Length()) { AddThreatSourceFromRedirectEntry(aHit, loadInfo->RedirectChain()[0], ThreatHit_ThreatSourceType_TAB_RESOURCE); } @@ -674,11 +674,7 @@ static nsresult AddTabThreatSources(ThreatHit& aHit, nsIChannel* aChannel) { Unused << NS_WARN_IF(NS_FAILED(rv)); // Set tab_redirect threat sources if there's any - nsCOMPtr topLoadInfo = topChannel->GetLoadInfo(); - if (!topLoadInfo) { - return NS_OK; - } - + nsCOMPtr topLoadInfo = topChannel->LoadInfo(); nsIRedirectHistoryEntry* redirectEntry; size_t length = topLoadInfo->RedirectChain().Length(); for (size_t i = 0; i < length; i++) { diff --git a/tools/profiler/core/platform-win32.cpp b/tools/profiler/core/platform-win32.cpp index 0ad15d34f421..7b533b7c33dd 100644 --- a/tools/profiler/core/platform-win32.cpp +++ b/tools/profiler/core/platform-win32.cpp @@ -94,8 +94,10 @@ class PlatformData { HANDLE mProfiledThread; }; +#if defined(USE_MOZ_STACK_WALK) HANDLE GetThreadHandle(PlatformData* aData) { return aData->ProfiledThread(); } +#endif static const HANDLE kNoThread = INVALID_HANDLE_VALUE; diff --git a/tools/profiler/core/platform.cpp b/tools/profiler/core/platform.cpp index 66ad749fde40..84657925710f 100644 --- a/tools/profiler/core/platform.cpp +++ b/tools/profiler/core/platform.cpp @@ -1259,7 +1259,7 @@ static void MergeStacks(uint32_t aFeatures, bool aIsSynchronous, } } -#if defined(GP_OS_windows) +#if defined(GP_OS_windows) && defined(USE_MOZ_STACK_WALK) static HANDLE GetThreadHandle(PlatformData* aData); #endif diff --git a/tools/profiler/core/shared-libraries-win32.cc b/tools/profiler/core/shared-libraries-win32.cc index 2105a02f0f90..2be73b332dc5 100644 --- a/tools/profiler/core/shared-libraries-win32.cc +++ b/tools/profiler/core/shared-libraries-win32.cc @@ -77,8 +77,6 @@ static bool GetPdbInfo(uintptr_t aStart, nsID& aSignature, uint32_t& aAge, return true; } -static bool IsDashOrBraces(char c) { return c == '-' || c == '{' || c == '}'; } - static nsCString GetVersion(WCHAR* dllPath) { DWORD infoSize = GetFileVersionInfoSizeW(dllPath, nullptr); if (infoSize == 0) { diff --git a/tools/profiler/moz.build b/tools/profiler/moz.build index c417de5219db..c12ad1211dc2 100644 --- a/tools/profiler/moz.build +++ b/tools/profiler/moz.build @@ -169,6 +169,3 @@ if CONFIG['CC_TYPE'] in ('clang', 'gcc'): with Files('**'): BUG_COMPONENT = ('Core', 'Gecko Profiler') - -if CONFIG['CC_TYPE'] == 'clang-cl': - AllowCompilerWarnings() # workaround for bug 1090497 diff --git a/uriloader/exthandler/nsExternalHelperAppService.cpp b/uriloader/exthandler/nsExternalHelperAppService.cpp index ac9803092d91..88493a6df6eb 100644 --- a/uriloader/exthandler/nsExternalHelperAppService.cpp +++ b/uriloader/exthandler/nsExternalHelperAppService.cpp @@ -625,7 +625,7 @@ nsresult nsExternalHelperAppService::DoContentContentProcessHelper( channel->GetContentDisposition(&contentDisposition); channel->GetContentDispositionFilename(fileName); channel->GetContentDispositionHeader(disp); - loadInfo = channel->GetLoadInfo(); + loadInfo = channel->LoadInfo(); nsCOMPtr fileChan(do_QueryInterface(aRequest)); wasFileChannel = fileChan != nullptr; @@ -1978,19 +1978,17 @@ nsExternalAppHandler::OnSaveComplete(nsIBackgroundFileSaver* aSaver, // Save the redirect information. nsCOMPtr channel = do_QueryInterface(mRequest); if (channel) { - nsCOMPtr loadInfo = channel->GetLoadInfo(); - if (loadInfo) { - nsresult rv = NS_OK; - nsCOMPtr redirectChain = - do_CreateInstance(NS_ARRAY_CONTRACTID, &rv); - NS_ENSURE_SUCCESS(rv, rv); - LOG(("nsExternalAppHandler: Got %zu redirects\n", - loadInfo->RedirectChain().Length())); - for (nsIRedirectHistoryEntry* entry : loadInfo->RedirectChain()) { - redirectChain->AppendElement(entry); - } - mRedirects = redirectChain; + nsCOMPtr loadInfo = channel->LoadInfo(); + nsresult rv = NS_OK; + nsCOMPtr redirectChain = + do_CreateInstance(NS_ARRAY_CONTRACTID, &rv); + NS_ENSURE_SUCCESS(rv, rv); + LOG(("nsExternalAppHandler: Got %zu redirects\n", + loadInfo->RedirectChain().Length())); + for (nsIRedirectHistoryEntry* entry : loadInfo->RedirectChain()) { + redirectChain->AppendElement(entry); } + mRedirects = redirectChain; } if (NS_FAILED(aStatus)) { diff --git a/uriloader/exthandler/nsExternalProtocolHandler.cpp b/uriloader/exthandler/nsExternalProtocolHandler.cpp index 7a1b265617dc..77f69cbcdfc3 100644 --- a/uriloader/exthandler/nsExternalProtocolHandler.cpp +++ b/uriloader/exthandler/nsExternalProtocolHandler.cpp @@ -515,8 +515,8 @@ NS_IMETHODIMP nsExternalProtocolHandler::NewURI( } NS_IMETHODIMP -nsExternalProtocolHandler::NewChannel2(nsIURI *aURI, nsILoadInfo *aLoadInfo, - nsIChannel **aRetval) { +nsExternalProtocolHandler::NewChannel(nsIURI *aURI, nsILoadInfo *aLoadInfo, + nsIChannel **aRetval) { NS_ENSURE_TRUE(aURI, NS_ERROR_UNKNOWN_PROTOCOL); NS_ENSURE_TRUE(aRetval, NS_ERROR_UNKNOWN_PROTOCOL); @@ -533,11 +533,6 @@ nsExternalProtocolHandler::NewChannel2(nsIURI *aURI, nsILoadInfo *aLoadInfo, return NS_OK; } -NS_IMETHODIMP nsExternalProtocolHandler::NewChannel(nsIURI *aURI, - nsIChannel **_retval) { - return NewChannel2(aURI, nullptr, _retval); -} - /////////////////////////////////////////////////////////////////////// // External protocol handler interface implementation ////////////////////////////////////////////////////////////////////// diff --git a/uriloader/prefetch/nsPrefetchService.cpp b/uriloader/prefetch/nsPrefetchService.cpp index 90b047d685a2..84fd5dfc3508 100644 --- a/uriloader/prefetch/nsPrefetchService.cpp +++ b/uriloader/prefetch/nsPrefetchService.cpp @@ -188,13 +188,11 @@ nsPrefetchNode::OnStartRequest(nsIRequest *aRequest, nsISupports *aContext) { // if the load is cross origin without CORS, or the CORS access is rejected, // always fire load event to avoid leaking site information. - nsCOMPtr loadInfo = httpChannel->GetLoadInfo(); - if (loadInfo) { - mShouldFireLoadEvent = - loadInfo->GetTainting() == LoadTainting::Opaque || - (loadInfo->GetTainting() == LoadTainting::CORS && - (NS_FAILED(httpChannel->GetStatus(&rv)) || NS_FAILED(rv))); - } + nsCOMPtr loadInfo = httpChannel->LoadInfo(); + mShouldFireLoadEvent = + loadInfo->GetTainting() == LoadTainting::Opaque || + (loadInfo->GetTainting() == LoadTainting::CORS && + (NS_FAILED(httpChannel->GetStatus(&rv)) || NS_FAILED(rv))); // no need to prefetch http error page bool requestSucceeded; diff --git a/widget/android/nsAndroidProtocolHandler.cpp b/widget/android/nsAndroidProtocolHandler.cpp index 513c5911bea9..b98db4840bcd 100644 --- a/widget/android/nsAndroidProtocolHandler.cpp +++ b/widget/android/nsAndroidProtocolHandler.cpp @@ -141,8 +141,8 @@ nsAndroidProtocolHandler::NewURI(const nsACString &aSpec, const char *aCharset, } NS_IMETHODIMP -nsAndroidProtocolHandler::NewChannel2(nsIURI *aURI, nsILoadInfo *aLoadInfo, - nsIChannel **aResult) { +nsAndroidProtocolHandler::NewChannel(nsIURI *aURI, nsILoadInfo *aLoadInfo, + nsIChannel **aResult) { nsCOMPtr channel = AndroidChannel::CreateChannel(aURI); if (!channel) return NS_ERROR_FAILURE; @@ -153,8 +153,3 @@ nsAndroidProtocolHandler::NewChannel2(nsIURI *aURI, nsILoadInfo *aLoadInfo, NS_ADDREF(*aResult = channel); return NS_OK; } - -NS_IMETHODIMP -nsAndroidProtocolHandler::NewChannel(nsIURI *aURI, nsIChannel **aResult) { - return NewChannel2(aURI, nullptr, aResult); -} diff --git a/xpcom/components/nsComponentManager.cpp b/xpcom/components/nsComponentManager.cpp index 4c9993a2c88b..878bfda960a5 100644 --- a/xpcom/components/nsComponentManager.cpp +++ b/xpcom/components/nsComponentManager.cpp @@ -1966,6 +1966,8 @@ XRE_AddStaticComponent(const mozilla::Module* aComponent) { NS_IMETHODIMP nsComponentManagerImpl::AddBootstrappedManifestLocation(nsIFile* aLocation) { + NS_ENSURE_ARG_POINTER(aLocation); + nsString path; nsresult rv = aLocation->GetPath(path); if (NS_FAILED(rv)) { @@ -1983,6 +1985,8 @@ nsComponentManagerImpl::AddBootstrappedManifestLocation(nsIFile* aLocation) { NS_IMETHODIMP nsComponentManagerImpl::RemoveBootstrappedManifestLocation(nsIFile* aLocation) { + NS_ENSURE_ARG_POINTER(aLocation); + nsCOMPtr cr = mozilla::services::GetChromeRegistryService(); if (!cr) { diff --git a/xpcom/io/SpecialSystemDirectory.cpp b/xpcom/io/SpecialSystemDirectory.cpp index 31ea227eed7a..d89787041fe8 100644 --- a/xpcom/io/SpecialSystemDirectory.cpp +++ b/xpcom/io/SpecialSystemDirectory.cpp @@ -108,6 +108,7 @@ __inline HRESULT SHLoadLibraryFromKnownFolder(REFKNOWNFOLDERID aFolderId, } # endif +# if defined(MOZ_THUNDERBIRD) || defined(MOZ_SUITE) /* * Return the default save-to location for the Windows Library passed in * through aFolderId. @@ -135,6 +136,7 @@ static nsresult GetLibrarySaveToPath(int aFallbackFolderId, return GetWindowsFolder(aFallbackFolderId, aFile); } +# endif /** * Provides a fallback for getting the path to APPDATA or LOCALAPPDATA by diff --git a/xpcom/io/moz.build b/xpcom/io/moz.build index fcc1988ba187..672df3068ed5 100644 --- a/xpcom/io/moz.build +++ b/xpcom/io/moz.build @@ -158,6 +158,3 @@ if CONFIG['CC_TYPE'] == 'clang-cl': # '_snwprintf' : format string '%s' requires an argument of type 'wchar_t *', # but variadic argument 3 has type 'char16ptr_t' CXXFLAGS += ['-wd4477'] - -if CONFIG['CC_TYPE'] == 'clang-cl': - AllowCompilerWarnings() # workaround for bug 1090497 diff --git a/xpcom/windbgdlg/moz.build b/xpcom/windbgdlg/moz.build index a8442bc1fa28..f0343d31ae6f 100644 --- a/xpcom/windbgdlg/moz.build +++ b/xpcom/windbgdlg/moz.build @@ -7,6 +7,3 @@ SimplePrograms([ 'windbgdlg' ]) - -if CONFIG['MOZ_DEBUG'] and CONFIG['CC_TYPE'] == 'clang-cl': - AllowCompilerWarnings() # workaround for bug 1090497 diff --git a/xpcom/windbgdlg/windbgdlg.cpp b/xpcom/windbgdlg/windbgdlg.cpp index 9368b574c3c3..2bd1139b2354 100644 --- a/xpcom/windbgdlg/windbgdlg.cpp +++ b/xpcom/windbgdlg/windbgdlg.cpp @@ -80,7 +80,6 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, KEY_READ, &hkeyCU); RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\mozilla.org\\windbgdlg", 0, KEY_READ, &hkeyLM); - int argc = 0; for (int i = __argc - 1; regValue == (DWORD)-1 && i; --i) { bool ok = false; if (hkeyCU)