Backed out 6 changesets (bug 1616716) forcausing multiple mochitest failures on test_ext_protocolHandlers.html

Backed out changeset 609cbe8b736e (bug 1616716)
Backed out changeset 9e61658c1778 (bug 1616716)
Backed out changeset a0e842d96cd6 (bug 1616716)
Backed out changeset 0174164a21e5 (bug 1616716)
Backed out changeset 35186917e79a (bug 1616716)
Backed out changeset 156d2898edb7 (bug 1616716)
This commit is contained in:
Arthur Iakab 2020-02-26 07:17:55 +02:00
Родитель de671d8e92
Коммит 49ed791eec
6 изменённых файлов: 63 добавлений и 139 удалений

Просмотреть файл

@ -6,13 +6,10 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "DocumentChannelParent.h"
#include "mozilla/dom/BrowserParent.h"
extern mozilla::LazyLogModule gDocumentChannelLog;
#define LOG(fmt) MOZ_LOG(gDocumentChannelLog, mozilla::LogLevel::Verbose, fmt)
using namespace mozilla::dom;
namespace mozilla {
namespace net {
@ -20,8 +17,8 @@ DocumentChannelParent::DocumentChannelParent(BrowserParent* aBrowser,
nsILoadContext* aLoadContext,
PBOverrideStatus aOverrideStatus) {
LOG(("DocumentChannelParent ctor [this=%p]", this));
mParent = new DocumentLoadListener(aBrowser->GetBrowsingContext(),
aLoadContext, aOverrideStatus, this);
mParent =
new DocumentLoadListener(aBrowser, aLoadContext, aOverrideStatus, this);
}
DocumentChannelParent::~DocumentChannelParent() {
@ -41,14 +38,13 @@ bool DocumentChannelParent::Init(BrowserParent* aBrowser,
MOZ_ASSERT(NS_SUCCEEDED(rv));
rv = NS_ERROR_UNEXPECTED;
if (!mParent->Open(aBrowser->GetBrowsingContext(), loadState, loadInfo,
aArgs.loadFlags(), aArgs.loadType(), aArgs.cacheKey(),
aArgs.isActive(), aArgs.isTopLevelDoc(),
if (!mParent->Open(
aBrowser, loadState, loadInfo, aArgs.loadFlags(), aArgs.loadType(),
aArgs.cacheKey(), aArgs.isActive(), aArgs.isTopLevelDoc(),
aArgs.hasNonEmptySandboxingFlags(), aArgs.topWindowURI(),
aArgs.contentBlockingAllowListPrincipal(),
aArgs.channelId(), aArgs.asyncOpenTime(),
aArgs.documentOpenFlags(), aArgs.pluginsAllowed(),
aArgs.timing().refOr(nullptr), &rv)) {
aArgs.contentBlockingAllowListPrincipal(), aArgs.channelId(),
aArgs.asyncOpenTime(), aArgs.documentOpenFlags(),
aArgs.pluginsAllowed(), aArgs.timing().refOr(nullptr), &rv)) {
return SendFailedAsyncOpen(rv);
}

Просмотреть файл

@ -9,6 +9,7 @@
#include "mozilla/DebugOnly.h"
#include "mozilla/LoadInfo.h"
#include "mozilla/MozPromiseInlines.h" // For MozPromise::FromDomPromise
#include "mozilla/dom/BrowserParent.h"
#include "mozilla/dom/CanonicalBrowsingContext.h"
#include "mozilla/dom/ClientChannelHelper.h"
#include "mozilla/dom/ContentParent.h"
@ -233,14 +234,13 @@ NS_INTERFACE_MAP_BEGIN(DocumentLoadListener)
NS_INTERFACE_MAP_ENTRY_CONCRETE(DocumentLoadListener)
NS_INTERFACE_MAP_END
DocumentLoadListener::DocumentLoadListener(
CanonicalBrowsingContext* aProcessTopBrowsingContext,
nsILoadContext* aLoadContext, PBOverrideStatus aOverrideStatus,
DocumentLoadListener::DocumentLoadListener(BrowserParent* aBrowser,
nsILoadContext* aLoadContext,
PBOverrideStatus aOverrideStatus,
ADocumentChannelBridge* aBridge)
: mLoadContext(aLoadContext), mPBOverride(aOverrideStatus) {
LOG(("DocumentLoadListener ctor [this=%p]", this));
mParentChannelListener = new ParentChannelListener(
this, aProcessTopBrowsingContext, aLoadContext->UsePrivateBrowsing());
mParentChannelListener = new ParentChannelListener(this, aBrowser);
mDocumentChannelBridge = aBridge;
}
@ -249,11 +249,10 @@ DocumentLoadListener::~DocumentLoadListener() {
}
bool DocumentLoadListener::Open(
CanonicalBrowsingContext* aProcessTopBrowsingContext,
nsDocShellLoadState* aLoadState, class LoadInfo* aLoadInfo,
nsLoadFlags aLoadFlags, uint32_t aLoadType, uint32_t aCacheKey,
bool aIsActive, bool aIsTopLevelDoc, bool aHasNonEmptySandboxingFlags,
const Maybe<URIParams>& aTopWindowURI,
BrowserParent* aBrowser, nsDocShellLoadState* aLoadState,
LoadInfo* aLoadInfo, nsLoadFlags aLoadFlags, uint32_t aLoadType,
uint32_t aCacheKey, bool aIsActive, bool aIsTopLevelDoc,
bool aHasNonEmptySandboxingFlags, const Maybe<URIParams>& aTopWindowURI,
const Maybe<PrincipalInfo>& aContentBlockingAllowListPrincipal,
const uint64_t& aChannelId, const TimeStamp& aAsyncOpenTime,
const Maybe<uint32_t>& aDocumentOpenFlags, bool aPluginsAllowed,
@ -315,7 +314,7 @@ bool DocumentLoadListener::Open(
RefPtr<ParentProcessDocumentOpenInfo> openInfo =
new ParentProcessDocumentOpenInfo(mParentChannelListener,
aPluginsAllowed, *aDocumentOpenFlags,
aProcessTopBrowsingContext);
aBrowser->GetBrowsingContext());
openInfo->Prepare();
*aRv = mChannel->AsyncOpen(openInfo);

Просмотреть файл

@ -14,7 +14,7 @@
#include "mozilla/net/PDocumentChannelParent.h"
#include "mozilla/net/ParentChannelListener.h"
#include "mozilla/net/ADocumentChannelBridge.h"
#include "mozilla/dom/CanonicalBrowsingContext.h"
#include "mozilla/dom/BrowserParent.h"
#include "nsDOMNavigationTiming.h"
#include "nsIInterfaceRequestor.h"
#include "nsIObserver.h"
@ -63,23 +63,18 @@ class DocumentLoadListener : public nsIInterfaceRequestor,
public nsIProcessSwitchRequestor,
public nsIMultiPartChannelListener {
public:
// aProcessTopBrowsingContext should be the top BrowsingContext in the same
// process as the load, which would be the owner of the BrowserParent (if
// has been created).
// This is weird legacy behaviour, that will be cleaned up with bug 1618057.
explicit DocumentLoadListener(
dom::CanonicalBrowsingContext* aProcessTopBrowsingContext,
nsILoadContext* aLoadContext, PBOverrideStatus aOverrideStatus,
explicit DocumentLoadListener(dom::BrowserParent* aBrowser,
nsILoadContext* aLoadContext,
PBOverrideStatus aOverrideStatus,
ADocumentChannelBridge* aBridge);
// Creates the channel, and then calls AsyncOpen on it.
// Must be the same BrowsingContext as was passed to the constructor, we
// Must be the same BrowserParent as was passed to the constructor, we
// expect Necko to pass it again so that we don't need a member var for
// it.
bool Open(dom::CanonicalBrowsingContext* aProcessTopBrowsingContext,
nsDocShellLoadState* aLoadState, class LoadInfo* aLoadInfo,
nsLoadFlags aLoadFlags, uint32_t aLoadType, uint32_t aCacheKey,
bool aIsActive, bool aIsTopLevelDoc,
bool Open(dom::BrowserParent* aBrowser, nsDocShellLoadState* aLoadState,
LoadInfo* aLoadInfo, nsLoadFlags aLoadFlags, uint32_t aLoadType,
uint32_t aCacheKey, bool aIsActive, bool aIsTopLevelDoc,
bool aHasNonEmptySandboxingFlags,
const Maybe<ipc::URIParams>& aTopWindowURI,
const Maybe<ipc::PrincipalInfo>& aContentBlockingAllowListPrincipal,

Просмотреть файл

@ -511,9 +511,8 @@ bool HttpChannelParent::DoAsyncOpen(
}
}
RefPtr<ParentChannelListener> parentListener = new ParentChannelListener(
this, mBrowserParent ? mBrowserParent->GetBrowsingContext() : nullptr,
mLoadContext && mLoadContext->UsePrivateBrowsing());
RefPtr<ParentChannelListener> parentListener =
new ParentChannelListener(this, mBrowserParent);
httpChannel->SetRequestMethod(nsDependentCString(requestMethod.get()));

Просмотреть файл

@ -21,12 +21,6 @@
#include "nsQueryObject.h"
#include "nsIAuthPrompt.h"
#include "nsIAuthPrompt2.h"
#include "nsIPromptFactory.h"
#include "Element.h"
#include "nsILoginManagerAuthPrompter.h"
#include "mozilla/dom/CanonicalBrowsingContext.h"
#include "mozilla/dom/LoadURIOptionsBinding.h"
#include "nsIWebNavigation.h"
using mozilla::Unused;
using mozilla::dom::ServiceWorkerInterceptController;
@ -35,16 +29,14 @@ using mozilla::dom::ServiceWorkerParentInterceptEnabled;
namespace mozilla {
namespace net {
ParentChannelListener::ParentChannelListener(
nsIStreamListener* aListener,
dom::CanonicalBrowsingContext* aBrowsingContext, bool aUsePrivateBrowsing)
ParentChannelListener::ParentChannelListener(nsIStreamListener* aListener,
dom::BrowserParent* aBrowserParent)
: mNextListener(aListener),
mSuspendedForDiversion(false),
mShouldIntercept(false),
mShouldSuspendIntercept(false),
mInterceptCanceled(false),
mBrowsingContext(aBrowsingContext),
mUsePrivateBrowsing(aUsePrivateBrowsing) {
mBrowserParent(aBrowserParent) {
LOG(("ParentChannelListener::ParentChannelListener [this=%p, next=%p]", this,
aListener));
@ -69,8 +61,6 @@ NS_INTERFACE_MAP_BEGIN(ParentChannelListener)
NS_INTERFACE_MAP_ENTRY(nsIRequestObserver)
NS_INTERFACE_MAP_ENTRY(nsIMultiPartChannelListener)
NS_INTERFACE_MAP_ENTRY(nsINetworkInterceptController)
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIAuthPromptProvider, mBrowsingContext)
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIRemoteWindowContext, mBrowsingContext)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIInterfaceRequestor)
NS_INTERFACE_MAP_ENTRY_CONCRETE(ParentChannelListener)
NS_INTERFACE_MAP_END
@ -160,9 +150,16 @@ ParentChannelListener::GetInterface(const nsIID& aIID, void** result) {
return QueryInterface(aIID, result);
}
if (mBrowsingContext && aIID.Equals(NS_GET_IID(nsIPrompt))) {
nsCOMPtr<dom::Element> frameElement =
mBrowsingContext->Top()->GetEmbedderElement();
if (aIID.Equals(NS_GET_IID(nsIAuthPromptProvider)) ||
aIID.Equals(NS_GET_IID(nsISecureBrowserUI)) ||
aIID.Equals(NS_GET_IID(nsIRemoteTab))) {
if (mBrowserParent) {
return mBrowserParent->QueryInterface(aIID, result);
}
}
if (mBrowserParent && aIID.Equals(NS_GET_IID(nsIPrompt))) {
nsCOMPtr<dom::Element> frameElement = mBrowserParent->GetOwnerElement();
if (frameElement) {
nsCOMPtr<nsPIDOMWindowOuter> win = frameElement->OwnerDoc()->GetWindow();
NS_ENSURE_TRUE(win, NS_ERROR_UNEXPECTED);
@ -186,9 +183,20 @@ ParentChannelListener::GetInterface(const nsIID& aIID, void** result) {
}
}
if (mBrowsingContext && (aIID.Equals(NS_GET_IID(nsIAuthPrompt)) ||
if (mBrowserParent && (aIID.Equals(NS_GET_IID(nsIAuthPrompt)) ||
aIID.Equals(NS_GET_IID(nsIAuthPrompt2)))) {
return GetAuthPrompt(nsIAuthPromptProvider::PROMPT_NORMAL, aIID, result);
nsCOMPtr<nsIAuthPromptProvider> provider(do_QueryObject(mBrowserParent));
if (provider) {
return provider->GetAuthPrompt(nsIAuthPromptProvider::PROMPT_NORMAL, aIID,
result);
}
}
if (aIID.Equals(NS_GET_IID(nsIRemoteWindowContext)) && mBrowserParent) {
nsCOMPtr<nsIRemoteWindowContext> ctx(
new dom::RemoteWindowContext(mBrowserParent));
ctx.forget(result);
return NS_OK;
}
nsCOMPtr<nsIInterfaceRequestor> ir;
@ -377,66 +385,5 @@ void ParentChannelListener::ClearInterceptedChannel(
mInterceptCanceled = true;
}
//-----------------------------------------------------------------------------
// ParentChannelListener::nsIAuthPromptProvider
//
NS_IMETHODIMP
ParentChannelListener::GetAuthPrompt(uint32_t aPromptReason, const nsIID& iid,
void** aResult) {
if (!mBrowsingContext) {
return NS_ERROR_NOT_AVAILABLE;
}
// we're either allowing auth, or it's a proxy request
nsresult rv;
nsCOMPtr<nsIPromptFactory> wwatch =
do_GetService(NS_WINDOWWATCHER_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsPIDOMWindowOuter> window;
RefPtr<dom::Element> frame = mBrowsingContext->Top()->GetEmbedderElement();
if (frame) window = frame->OwnerDoc()->GetWindow();
// Get an auth prompter for our window so that the parenting
// of the dialogs works as it should when using tabs.
nsCOMPtr<nsISupports> prompt;
rv = wwatch->GetPrompt(window, iid, getter_AddRefs(prompt));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsILoginManagerAuthPrompter> prompter = do_QueryInterface(prompt);
if (prompter) {
prompter->SetBrowser(frame);
}
*aResult = prompt.forget().take();
return NS_OK;
}
//-----------------------------------------------------------------------------
// ParentChannelListener::nsIRemoteWindowContext
//
NS_IMETHODIMP
ParentChannelListener::OpenURI(nsIURI* aURI) {
nsCString spec;
aURI->GetSpec(spec);
dom::LoadURIOptions loadURIOptions;
loadURIOptions.mTriggeringPrincipal = nsContentUtils::GetSystemPrincipal();
loadURIOptions.mLoadFlags =
nsIWebNavigation::LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP |
nsIWebNavigation::LOAD_FLAGS_DISALLOW_INHERIT_PRINCIPAL;
ErrorResult rv;
mBrowsingContext->LoadURI(NS_ConvertUTF8toUTF16(spec), loadURIOptions, rv);
return rv.StealNSResult();
}
NS_IMETHODIMP
ParentChannelListener::GetUsePrivateBrowsing(bool* aUsePrivateBrowsing) {
*aUsePrivateBrowsing = mUsePrivateBrowsing;
return NS_OK;
}
} // namespace net
} // namespace mozilla

Просмотреть файл

@ -8,14 +8,11 @@
#ifndef mozilla_net_ParentChannelListener_h
#define mozilla_net_ParentChannelListener_h
#include "nsIAuthPromptProvider.h"
#include "nsIInterfaceRequestor.h"
#include "nsINetworkInterceptController.h"
#include "nsIStreamListener.h"
#include "nsIMultiPartChannel.h"
#include "nsIRemoteWindowContext.h"
#include "mozilla/dom/CanonicalBrowsingContext.h"
#include "mozilla/dom/CanonicalBrowsingContext.h"
#include "mozilla/dom/BrowserParent.h"
namespace mozilla {
namespace net {
@ -34,9 +31,7 @@ namespace net {
class ParentChannelListener final : public nsIInterfaceRequestor,
public nsIStreamListener,
public nsIMultiPartChannelListener,
public nsINetworkInterceptController,
private nsIAuthPromptProvider,
private nsIRemoteWindowContext {
public nsINetworkInterceptController {
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIINTERFACEREQUESTOR
@ -44,15 +39,11 @@ class ParentChannelListener final : public nsIInterfaceRequestor,
NS_DECL_NSISTREAMLISTENER
NS_DECL_NSIMULTIPARTCHANNELLISTENER
NS_DECL_NSINETWORKINTERCEPTCONTROLLER
NS_DECL_NSIAUTHPROMPTPROVIDER
NS_DECL_NSIREMOTEWINDOWCONTEXT
NS_DECLARE_STATIC_IID_ACCESSOR(PARENT_CHANNEL_LISTENER)
explicit ParentChannelListener(
nsIStreamListener* aListener,
dom::CanonicalBrowsingContext* aBrowsingContext,
bool aUsePrivateBrowsing);
explicit ParentChannelListener(nsIStreamListener* aListener,
dom::BrowserParent* aBrowserParent);
// For channel diversion from child to parent.
void DivertTo(nsIStreamListener* aListener);
@ -98,14 +89,11 @@ class ParentChannelListener final : public nsIInterfaceRequestor,
// interception is enabled.
nsCOMPtr<nsINetworkInterceptController> mInterceptController;
RefPtr<mozilla::dom::CanonicalBrowsingContext> mBrowsingContext;
RefPtr<mozilla::dom::BrowserParent> mBrowserParent;
// True if we received OnStartRequest for a nsIMultiPartChannel, and are
// expected AllPartsStopped to be called when complete.
bool mIsMultiPart = false;
// True if the nsILoadContext for this channel has private browsing enabled.
bool mUsePrivateBrowsing = false;
};
NS_DEFINE_STATIC_IID_ACCESSOR(ParentChannelListener, PARENT_CHANNEL_LISTENER)