mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-06 07:17:30 +09:00
Bug 1182569: Use AsyncOpen2 for docshell loads
native in moebius
This commit is contained in:
parent
8dccc387f9
commit
78102ec8c0
3 changed files with 21 additions and 53 deletions
|
|
@ -69,7 +69,6 @@
|
||||||
#include "nsIScriptSecurityManager.h"
|
#include "nsIScriptSecurityManager.h"
|
||||||
#include "nsIScriptObjectPrincipal.h"
|
#include "nsIScriptObjectPrincipal.h"
|
||||||
#include "nsIScrollableFrame.h"
|
#include "nsIScrollableFrame.h"
|
||||||
#include "nsContentPolicyUtils.h" // NS_CheckContentLoadPolicy(...)
|
|
||||||
#include "nsISeekableStream.h"
|
#include "nsISeekableStream.h"
|
||||||
#include "nsAutoPtr.h"
|
#include "nsAutoPtr.h"
|
||||||
#include "nsQueryObject.h"
|
#include "nsQueryObject.h"
|
||||||
|
|
@ -1644,7 +1643,7 @@ nsDocShell::LoadStream(nsIInputStream* aStream, nsIURI* aURI,
|
||||||
uri,
|
uri,
|
||||||
aStream,
|
aStream,
|
||||||
triggeringPrincipal,
|
triggeringPrincipal,
|
||||||
nsILoadInfo::SEC_NORMAL,
|
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
|
||||||
nsIContentPolicy::TYPE_OTHER,
|
nsIContentPolicy::TYPE_OTHER,
|
||||||
aContentType,
|
aContentType,
|
||||||
aContentCharset);
|
aContentCharset);
|
||||||
|
|
@ -9943,23 +9942,6 @@ nsDocShell::InternalLoad(nsIURI* aURI,
|
||||||
rv = extraStr->SetData(msg);
|
rv = extraStr->SetData(msg);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
int16_t shouldLoad = nsIContentPolicy::ACCEPT;
|
|
||||||
rv = NS_CheckContentLoadPolicy(contentType,
|
|
||||||
aURI,
|
|
||||||
aTriggeringPrincipal,
|
|
||||||
requestingContext,
|
|
||||||
EmptyCString(), // mime guess
|
|
||||||
extraStr, // extra
|
|
||||||
&shouldLoad);
|
|
||||||
|
|
||||||
if (NS_FAILED(rv) || NS_CP_REJECTED(shouldLoad)) {
|
|
||||||
if (NS_SUCCEEDED(rv) && shouldLoad == nsIContentPolicy::REJECT_TYPE) {
|
|
||||||
return NS_ERROR_CONTENT_BLOCKED_SHOW_ALT;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NS_ERROR_CONTENT_BLOCKED;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If HSTS priming was set by nsMixedContentBlocker::ShouldLoad, and we
|
// If HSTS priming was set by nsMixedContentBlocker::ShouldLoad, and we
|
||||||
// would block due to mixed content, go ahead and block here. If we try to
|
// would block due to mixed content, go ahead and block here. If we try to
|
||||||
// proceed with priming, we will error out later on.
|
// proceed with priming, we will error out later on.
|
||||||
|
|
@ -10949,7 +10931,8 @@ nsDocShell::DoURILoad(nsIURI* aURI,
|
||||||
}
|
}
|
||||||
|
|
||||||
nsLoadFlags loadFlags = mDefaultLoadFlags;
|
nsLoadFlags loadFlags = mDefaultLoadFlags;
|
||||||
nsSecurityFlags securityFlags = nsILoadInfo::SEC_NORMAL;
|
nsSecurityFlags securityFlags =
|
||||||
|
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL;
|
||||||
|
|
||||||
if (aFirstParty) {
|
if (aFirstParty) {
|
||||||
// tag first party URL loads
|
// tag first party URL loads
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,6 @@
|
||||||
#include "nsIContentViewer.h"
|
#include "nsIContentViewer.h"
|
||||||
#include "nsIXPConnect.h"
|
#include "nsIXPConnect.h"
|
||||||
#include "nsContentUtils.h"
|
#include "nsContentUtils.h"
|
||||||
#include "nsNullPrincipal.h"
|
|
||||||
#include "nsJSUtils.h"
|
#include "nsJSUtils.h"
|
||||||
#include "nsThreadUtils.h"
|
#include "nsThreadUtils.h"
|
||||||
#include "nsIScriptChannel.h"
|
#include "nsIScriptChannel.h"
|
||||||
|
|
@ -336,7 +335,7 @@ public:
|
||||||
NS_FORWARD_SAFE_NSIPROPERTYBAG(mPropertyBag)
|
NS_FORWARD_SAFE_NSIPROPERTYBAG(mPropertyBag)
|
||||||
NS_FORWARD_SAFE_NSIPROPERTYBAG2(mPropertyBag)
|
NS_FORWARD_SAFE_NSIPROPERTYBAG2(mPropertyBag)
|
||||||
|
|
||||||
nsresult Init(nsIURI *aURI);
|
nsresult Init(nsIURI *aURI, nsILoadInfo* aLoadInfo);
|
||||||
|
|
||||||
// Actually evaluate the script.
|
// Actually evaluate the script.
|
||||||
void EvaluateScript();
|
void EvaluateScript();
|
||||||
|
|
@ -354,17 +353,16 @@ protected:
|
||||||
nsCOMPtr<nsIChannel> mStreamChannel;
|
nsCOMPtr<nsIChannel> mStreamChannel;
|
||||||
nsCOMPtr<nsIPropertyBag2> mPropertyBag;
|
nsCOMPtr<nsIPropertyBag2> mPropertyBag;
|
||||||
nsCOMPtr<nsIStreamListener> mListener; // Our final listener
|
nsCOMPtr<nsIStreamListener> mListener; // Our final listener
|
||||||
nsCOMPtr<nsISupports> mContext; // The context passed to AsyncOpen
|
|
||||||
nsCOMPtr<nsPIDOMWindowInner> mOriginalInnerWindow; // The inner window our load
|
nsCOMPtr<nsPIDOMWindowInner> mOriginalInnerWindow; // The inner window our load
|
||||||
// started against.
|
// started against.
|
||||||
// If we blocked onload on a document in AsyncOpen, this is the document we
|
// If we blocked onload on a document in AsyncOpen2, this is the document we
|
||||||
// did it on.
|
// did it on.
|
||||||
nsCOMPtr<nsIDocument> mDocumentOnloadBlockedOn;
|
nsCOMPtr<nsIDocument> mDocumentOnloadBlockedOn;
|
||||||
|
|
||||||
nsresult mStatus; // Our status
|
nsresult mStatus; // Our status
|
||||||
|
|
||||||
nsLoadFlags mLoadFlags;
|
nsLoadFlags mLoadFlags;
|
||||||
nsLoadFlags mActualLoadFlags; // See AsyncOpen
|
nsLoadFlags mActualLoadFlags; // See AsyncOpen2
|
||||||
|
|
||||||
RefPtr<nsJSThunk> mIOThunk;
|
RefPtr<nsJSThunk> mIOThunk;
|
||||||
PopupControlState mPopupState;
|
PopupControlState mPopupState;
|
||||||
|
|
@ -404,7 +402,7 @@ nsresult nsJSChannel::StopAll()
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult nsJSChannel::Init(nsIURI *aURI)
|
nsresult nsJSChannel::Init(nsIURI* aURI, nsILoadInfo* aLoadInfo)
|
||||||
{
|
{
|
||||||
RefPtr<nsJSURI> jsURI;
|
RefPtr<nsJSURI> jsURI;
|
||||||
nsresult rv = aURI->QueryInterface(kJSURICID,
|
nsresult rv = aURI->QueryInterface(kJSURICID,
|
||||||
|
|
@ -418,21 +416,13 @@ nsresult nsJSChannel::Init(nsIURI *aURI)
|
||||||
// Remember, until AsyncOpen is called, the script will not be evaluated
|
// Remember, until AsyncOpen is called, the script will not be evaluated
|
||||||
// and the underlying Input Stream will not be created...
|
// and the underlying Input Stream will not be created...
|
||||||
nsCOMPtr<nsIChannel> channel;
|
nsCOMPtr<nsIChannel> channel;
|
||||||
|
rv = NS_NewInputStreamChannelInternal(getter_AddRefs(channel),
|
||||||
nsCOMPtr<nsIPrincipal> nullPrincipal = nsNullPrincipal::Create();
|
aURI,
|
||||||
|
mIOThunk,
|
||||||
// If the resultant script evaluation actually does return a value, we
|
NS_LITERAL_CSTRING("text/html"),
|
||||||
// treat it as html.
|
EmptyCString(),
|
||||||
// The following channel is never openend, so it does not matter what
|
aLoadInfo);
|
||||||
// securityFlags we pass; let's follow the principle of least privilege.
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
rv = NS_NewInputStreamChannel(getter_AddRefs(channel),
|
|
||||||
aURI,
|
|
||||||
mIOThunk,
|
|
||||||
nullPrincipal,
|
|
||||||
nsILoadInfo::SEC_REQUIRE_SAME_ORIGIN_DATA_IS_BLOCKED,
|
|
||||||
nsIContentPolicy::TYPE_OTHER,
|
|
||||||
NS_LITERAL_CSTRING("text/html"));
|
|
||||||
if (NS_FAILED(rv)) return rv;
|
|
||||||
|
|
||||||
rv = mIOThunk->Init(aURI);
|
rv = mIOThunk->Init(aURI);
|
||||||
if (NS_SUCCEEDED(rv)) {
|
if (NS_SUCCEEDED(rv)) {
|
||||||
|
|
@ -563,6 +553,7 @@ nsJSChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports *aContext)
|
||||||
"security flags in loadInfo but asyncOpen2() not called");
|
"security flags in loadInfo but asyncOpen2() not called");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
MOZ_RELEASE_ASSERT(!aContext, "please call AsyncOpen2()");
|
||||||
|
|
||||||
NS_ENSURE_ARG(aListener);
|
NS_ENSURE_ARG(aListener);
|
||||||
|
|
||||||
|
|
@ -584,7 +575,6 @@ nsJSChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports *aContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
mListener = aListener;
|
mListener = aListener;
|
||||||
mContext = aContext;
|
|
||||||
|
|
||||||
mIsActive = true;
|
mIsActive = true;
|
||||||
|
|
||||||
|
|
@ -655,7 +645,7 @@ nsJSChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports *aContext)
|
||||||
return mStatus;
|
return mStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We're returning success from asyncOpen(), but we didn't open a
|
// We're returning success from asyncOpen2(), but we didn't open a
|
||||||
// stream channel. We'll have to notify ourselves, but make sure to do
|
// stream channel. We'll have to notify ourselves, but make sure to do
|
||||||
// it asynchronously.
|
// it asynchronously.
|
||||||
method = &nsJSChannel::NotifyListener;
|
method = &nsJSChannel::NotifyListener;
|
||||||
|
|
@ -772,7 +762,7 @@ nsJSChannel::EvaluateScript()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mStatus = mStreamChannel->AsyncOpen(this, mContext);
|
mStatus = mStreamChannel->AsyncOpen2(this);
|
||||||
if (NS_SUCCEEDED(mStatus)) {
|
if (NS_SUCCEEDED(mStatus)) {
|
||||||
// mStreamChannel will call OnStartRequest and OnStopRequest on
|
// mStreamChannel will call OnStartRequest and OnStopRequest on
|
||||||
// us, so we'll be sure to call them on our listener.
|
// us, so we'll be sure to call them on our listener.
|
||||||
|
|
@ -800,8 +790,8 @@ nsJSChannel::EvaluateScript()
|
||||||
void
|
void
|
||||||
nsJSChannel::NotifyListener()
|
nsJSChannel::NotifyListener()
|
||||||
{
|
{
|
||||||
mListener->OnStartRequest(this, mContext);
|
mListener->OnStartRequest(this, nullptr);
|
||||||
mListener->OnStopRequest(this, mContext, mStatus);
|
mListener->OnStopRequest(this, nullptr, mStatus);
|
||||||
|
|
||||||
CleanupStrongRefs();
|
CleanupStrongRefs();
|
||||||
}
|
}
|
||||||
|
|
@ -810,7 +800,6 @@ void
|
||||||
nsJSChannel::CleanupStrongRefs()
|
nsJSChannel::CleanupStrongRefs()
|
||||||
{
|
{
|
||||||
mListener = nullptr;
|
mListener = nullptr;
|
||||||
mContext = nullptr;
|
|
||||||
mOriginalInnerWindow = nullptr;
|
mOriginalInnerWindow = nullptr;
|
||||||
if (mDocumentOnloadBlockedOn) {
|
if (mDocumentOnloadBlockedOn) {
|
||||||
mDocumentOnloadBlockedOn->UnblockOnload(false);
|
mDocumentOnloadBlockedOn->UnblockOnload(false);
|
||||||
|
|
@ -1240,11 +1229,7 @@ nsJSProtocolHandler::NewChannel2(nsIURI* uri,
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = channel->Init(uri);
|
rv = channel->Init(uri, aLoadInfo);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
// set the loadInfo on the new channel
|
|
||||||
rv = channel->SetLoadInfo(aLoadInfo);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
if (NS_SUCCEEDED(rv)) {
|
if (NS_SUCCEEDED(rv)) {
|
||||||
|
|
|
||||||
|
|
@ -834,7 +834,7 @@ NS_IMETHODIMP nsURILoader::OpenURI(nsIChannel *channel,
|
||||||
// the preferred protocol handler.
|
// the preferred protocol handler.
|
||||||
|
|
||||||
// But for now, I'm going to let necko do the work for us....
|
// But for now, I'm going to let necko do the work for us....
|
||||||
rv = channel->AsyncOpen(loader, nullptr);
|
rv = channel->AsyncOpen2(loader);
|
||||||
|
|
||||||
// no content from this load - that's OK.
|
// no content from this load - that's OK.
|
||||||
if (rv == NS_ERROR_NO_CONTENT) {
|
if (rv == NS_ERROR_NO_CONTENT) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue