Bug 1193924 - Add assertion to AsyncOpen to make sure asyncOpen2() was called first when securityflags in loadInfo are set (r=sicking)

This commit is contained in:
Christoph Kerschbaumer 2015-08-12 21:36:33 -07:00
parent 0ef916cfc2
commit 86bc7eb389
14 changed files with 63 additions and 1 deletions

View File

@ -565,6 +565,15 @@ nsJSChannel::Open2(nsIInputStream** aStream)
NS_IMETHODIMP
nsJSChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports *aContext)
{
#ifdef DEBUG
{
nsCOMPtr<nsILoadInfo> loadInfo = nsIChannel::GetLoadInfo();
MOZ_ASSERT(!loadInfo || loadInfo->GetSecurityMode() == 0 ||
loadInfo->GetInitialSecurityCheckDone(),
"security flags in loadInfo but asyncOpen2() not called");
}
#endif
NS_ENSURE_ARG(aListener);
// First make sure that we have a usable inner window; we'll want to make

View File

@ -225,6 +225,10 @@ NS_IMETHODIMP
nsIconChannel::AsyncOpen(nsIStreamListener* aListener,
nsISupports* ctxt)
{
MOZ_ASSERT(!mLoadInfo || mLoadInfo->GetSecurityMode() == 0 ||
mLoadInfo->GetInitialSecurityCheckDone(),
"security flags in loadInfo but asyncOpen2() not called");
nsCOMPtr<nsIInputStream> inStream;
nsresult rv = MakeInputStream(getter_AddRefs(inStream), true);
NS_ENSURE_SUCCESS(rv, rv);

View File

@ -239,6 +239,10 @@ NS_IMETHODIMP
nsIconChannel::AsyncOpen(nsIStreamListener* aListener,
nsISupports* ctxt)
{
MOZ_ASSERT(!mLoadInfo || mLoadInfo->GetSecurityMode() == 0 ||
mLoadInfo->GetInitialSecurityCheckDone(),
"security flags in loadInfo but asyncOpen2() not called");
nsCOMPtr<nsIInputStream> inStream;
nsresult rv = MakeInputStream(getter_AddRefs(inStream), true);
if (NS_FAILED(rv)) {

View File

@ -933,6 +933,10 @@ nsJARChannel::OverrideWithSynthesizedResponse(nsIInputStream* aSynthesizedInput,
NS_IMETHODIMP
nsJARChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctx)
{
MOZ_ASSERT(!mLoadInfo || mLoadInfo->GetSecurityMode() == 0 ||
mLoadInfo->GetEnforceSecurity(),
"security flags in loadInfo but asyncOpen2() not called");
LOG(("nsJARChannel::AsyncOpen [this=%x]\n", this));
NS_ENSURE_ARG_POINTER(listener);

View File

@ -626,6 +626,10 @@ nsBaseChannel::Open2(nsIInputStream** aStream)
NS_IMETHODIMP
nsBaseChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctxt)
{
MOZ_ASSERT(!mLoadInfo || mLoadInfo->GetSecurityMode() == 0 ||
mLoadInfo->GetInitialSecurityCheckDone(),
"security flags in loadInfo but asyncOpen2() not called");
NS_ENSURE_TRUE(mURI, NS_ERROR_NOT_INITIALIZED);
NS_ENSURE_TRUE(!mPump, NS_ERROR_IN_PROGRESS);
NS_ENSURE_TRUE(!mWasOpened, NS_ERROR_ALREADY_OPENED);

View File

@ -269,7 +269,6 @@ private:
nsCOMPtr<nsIProgressEventSink> mProgressSink;
nsCOMPtr<nsIURI> mOriginalURI;
nsCOMPtr<nsISupports> mOwner;
nsCOMPtr<nsILoadInfo> mLoadInfo;
nsCOMPtr<nsISupports> mSecurityInfo;
nsCOMPtr<nsIChannel> mRedirectChannel;
nsCString mContentType;
@ -285,6 +284,7 @@ private:
protected:
nsCOMPtr<nsIURI> mURI;
nsCOMPtr<nsILoadGroup> mLoadGroup;
nsCOMPtr<nsILoadInfo> mLoadInfo;
nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
nsCOMPtr<nsIStreamListener> mListener;
nsCOMPtr<nsISupports> mListenerContext;

View File

@ -111,6 +111,10 @@ DummyChannel::Open2(nsIInputStream** aStream)
NS_IMETHODIMP DummyChannel::AsyncOpen(nsIStreamListener* aListener, nsISupports* aContext)
{
MOZ_ASSERT(!mLoadInfo || mLoadInfo->GetSecurityMode() == 0 ||
mLoadInfo->GetInitialSecurityCheckDone(),
"security flags in loadInfo but asyncOpen2() not called");
mListener = aListener;
mListenerContext = aContext;
mPending = true;

View File

@ -1488,6 +1488,10 @@ HttpChannelChild::GetSecurityInfo(nsISupports **aSecurityInfo)
NS_IMETHODIMP
HttpChannelChild::AsyncOpen(nsIStreamListener *listener, nsISupports *aContext)
{
MOZ_ASSERT(!mLoadInfo || mLoadInfo->GetSecurityMode() == 0 ||
mLoadInfo->GetInitialSecurityCheckDone(),
"security flags in loadInfo but asyncOpen2() not called");
LOG(("HttpChannelChild::AsyncOpen [this=%p uri=%s]\n", this, mSpec.get()));
if (mCanceled)

View File

@ -4953,6 +4953,10 @@ nsHttpChannel::GetSecurityInfo(nsISupports **securityInfo)
NS_IMETHODIMP
nsHttpChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *context)
{
MOZ_ASSERT(!mLoadInfo || mLoadInfo->GetSecurityMode() == 0 ||
mLoadInfo->GetInitialSecurityCheckDone(),
"security flags in loadInfo but asyncOpen2() not called");
LOG(("nsHttpChannel::AsyncOpen [this=%p]\n", this));
NS_ENSURE_ARG_POINTER(listener);

View File

@ -107,6 +107,10 @@ private:
NS_IMETHODIMP
RtspChannelChild::AsyncOpen(nsIStreamListener *aListener, nsISupports *aContext)
{
MOZ_ASSERT(!mLoadInfo || mLoadInfo->GetSecurityMode() == 0 ||
mLoadInfo->GetInitialSecurityCheckDone(),
"security flags in loadInfo but asyncOpen2() not called");
// Precondition checks.
MOZ_ASSERT(aListener);
nsCOMPtr<nsIURI> uri = nsBaseChannel::URI();

View File

@ -258,6 +258,15 @@ nsViewSourceChannel::Open2(nsIInputStream** aStream)
NS_IMETHODIMP
nsViewSourceChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports *ctxt)
{
#ifdef DEBUG
{
nsCOMPtr<nsILoadInfo> loadInfo = mChannel->GetLoadInfo();
MOZ_ASSERT(!loadInfo || loadInfo->GetSecurityMode() == 0 ||
loadInfo->GetEnforceSecurity(),
"security flags in loadInfo but asyncOpen2() not called");
}
#endif
NS_ENSURE_TRUE(mChannel, NS_ERROR_FAILURE);
mListener = aListener;

View File

@ -626,6 +626,10 @@ GetTabChild(nsIChannel* aChannel)
NS_IMETHODIMP
WyciwygChannelChild::AsyncOpen(nsIStreamListener *aListener, nsISupports *aContext)
{
MOZ_ASSERT(!mLoadInfo || mLoadInfo->GetSecurityMode() == 0 ||
mLoadInfo->GetInitialSecurityCheckDone(),
"security flags in loadInfo but asyncOpen2() not called");
LOG(("WyciwygChannelChild::AsyncOpen [this=%p]\n", this));
// The only places creating wyciwyg: channels should be

View File

@ -431,6 +431,10 @@ nsWyciwygChannel::Open2(nsIInputStream** aStream)
NS_IMETHODIMP
nsWyciwygChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctx)
{
MOZ_ASSERT(!mLoadInfo || mLoadInfo->GetSecurityMode() == 0 ||
mLoadInfo->GetInitialSecurityCheckDone(),
"security flags in loadInfo but asyncOpen2() not called");
LOG(("nsWyciwygChannel::AsyncOpen [this=%p]\n", this));
MOZ_ASSERT(mMode == NONE, "nsWyciwygChannel already open");

View File

@ -186,6 +186,10 @@ NS_IMETHODIMP nsExtProtocolChannel::Open2(nsIInputStream** aStream)
NS_IMETHODIMP nsExtProtocolChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctxt)
{
MOZ_ASSERT(!mLoadInfo || mLoadInfo->GetSecurityMode() == 0 ||
mLoadInfo->GetInitialSecurityCheckDone(),
"security flags in loadInfo but asyncOpen2() not called");
NS_ENSURE_ARG_POINTER(listener);
NS_ENSURE_TRUE(!mWasOpened, NS_ERROR_ALREADY_OPENED);