Bug 1583700 - Copy hasNonEmptySandboxingFlags across with DocumentChannel so that it can be set on the nHttpChannel in the parent. r=JuniorHsu,valentin

Depends on D49870

We fail coop-sandbox.https.html  without this, since the changes in bug 1566868 don't apply to DocumentChannel.

Differential Revision: https://phabricator.services.mozilla.com/D49871

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Matt Woodrow 2019-10-22 19:16:28 +00:00
Родитель 51bb5e05f0
Коммит e398ffe261
6 изменённых файлов: 36 добавлений и 26 удалений

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

@ -9734,13 +9734,13 @@ static bool HasHttpScheme(nsIURI* aURI) {
nsDocShellLoadState* aLoadState, LoadInfo* aLoadInfo,
nsIInterfaceRequestor* aCallbacks, nsDocShell* aDocShell,
const nsString* aInitiatorType, nsLoadFlags aLoadFlags, uint32_t aLoadType,
uint32_t aCacheKey, bool aIsActive, bool aIsTopLevelDoc, nsresult& aRv,
nsIChannel** aChannel) {
uint32_t aCacheKey, bool aIsActive, bool aIsTopLevelDoc,
bool aHasNonEmptySandboxingFlags, nsresult& aRv, nsIChannel** aChannel) {
if (StaticPrefs::browser_tabs_documentchannel() && XRE_IsContentProcess() &&
HasHttpScheme(aLoadState->URI())) {
RefPtr<DocumentChannelChild> child = new DocumentChannelChild(
aLoadState, aLoadInfo, aInitiatorType, aLoadFlags, aLoadType, aCacheKey,
aIsActive, aIsTopLevelDoc);
aIsActive, aIsTopLevelDoc, aHasNonEmptySandboxingFlags);
child->SetNotificationCallbacks(aCallbacks);
child.forget(aChannel);
aRv = NS_OK;
@ -9902,7 +9902,8 @@ static bool HasHttpScheme(nsIURI* aURI) {
/* static */ nsresult nsDocShell::ConfigureChannel(
nsIChannel* aChannel, nsDocShellLoadState* aLoadState,
const nsString* aInitiatorType, uint32_t aLoadType, uint32_t aCacheKey) {
const nsString* aInitiatorType, uint32_t aLoadType, uint32_t aCacheKey,
bool aHasNonEmptySandboxingFlags) {
nsCOMPtr<nsIWritablePropertyBag2> props(do_QueryInterface(aChannel));
if (props) {
nsCOMPtr<nsIURI> referrer;
@ -10075,6 +10076,14 @@ static bool HasHttpScheme(nsIURI* aURI) {
return NS_ERROR_CSP_NAVIGATE_TO_VIOLATION;
}
}
if (aHasNonEmptySandboxingFlags) {
nsCOMPtr<nsIHttpChannelInternal> httpChannel(do_QueryInterface(aChannel));
if (httpChannel) {
httpChannel->SetHasNonEmptySandboxingFlag(true);
}
}
return rv;
}
@ -10375,9 +10384,10 @@ nsresult nsDocShell::DoURILoad(nsDocShellLoadState* aLoadState,
bool isActive =
mIsActive || (mLoadType & (LOAD_CMD_NORMAL | LOAD_CMD_HISTORY));
if (!CreateChannelForLoadState(
aLoadState, loadInfo, this, this, initiatorType, loadFlags, mLoadType,
cacheKey, isActive, isTopLevelDoc, rv, getter_AddRefs(channel))) {
if (!CreateChannelForLoadState(aLoadState, loadInfo, this, this,
initiatorType, loadFlags, mLoadType, cacheKey,
isActive, isTopLevelDoc, mSandboxFlags, rv,
getter_AddRefs(channel))) {
return rv;
}
@ -10387,8 +10397,8 @@ nsresult nsDocShell::DoURILoad(nsDocShellLoadState* aLoadState,
NS_ADDREF(*aRequest = channel);
}
rv =
ConfigureChannel(channel, aLoadState, initiatorType, mLoadType, cacheKey);
rv = ConfigureChannel(channel, aLoadState, initiatorType, mLoadType, cacheKey,
mSandboxFlags);
NS_ENSURE_SUCCESS(rv, rv);
const nsACString& typeHint = aLoadState->TypeHint();
@ -10520,13 +10530,6 @@ nsresult nsDocShell::DoChannelLoad(nsIChannel* aChannel,
loadFlags |= nsIRequest::LOAD_DOCUMENT_NEEDS_COOKIE;
}
if (mSandboxFlags) {
nsCOMPtr<nsIHttpChannelInternal> httpChannel(do_QueryInterface(aChannel));
if (httpChannel) {
httpChannel->SetHasNonEmptySandboxingFlag(true);
}
}
// Load attributes depend on load type...
switch (mLoadType) {
case LOAD_HISTORY: {

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

@ -479,12 +479,14 @@ class nsDocShell final : public nsDocLoader,
nsIInterfaceRequestor* aCallbacks, nsDocShell* aDocShell,
const nsString* aInitiatorType, nsLoadFlags aLoadFlags,
uint32_t aLoadType, uint32_t aCacheKey, bool aIsActive,
bool aIsTopLevelDoc, nsresult& rv, nsIChannel** aChannel);
bool aIsTopLevelDoc, bool aHasNonEmptySandboxingFlags, nsresult& rv,
nsIChannel** aChannel);
static nsresult ConfigureChannel(nsIChannel* aChannel,
nsDocShellLoadState* aLoadState,
const nsString* aInitiatorType,
uint32_t aLoadType, uint32_t aCacheKey);
uint32_t aLoadType, uint32_t aCacheKey,
bool aHasNonEmptySandboxingFlags);
// Notify consumers of a search being loaded through the observer service:
static void MaybeNotifyKeywordSearchLoading(const nsString& aProvider,

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

@ -51,13 +51,15 @@ NS_IMPL_RELEASE_INHERITED(DocumentChannelChild, nsBaseChannel)
DocumentChannelChild::DocumentChannelChild(
nsDocShellLoadState* aLoadState, net::LoadInfo* aLoadInfo,
const nsString* aInitiatorType, nsLoadFlags aLoadFlags, uint32_t aLoadType,
uint32_t aCacheKey, bool aIsActive, bool aIsTopLevelDoc)
uint32_t aCacheKey, bool aIsActive, bool aIsTopLevelDoc,
bool aHasNonEmptySandboxingFlags)
: mLoadState(aLoadState),
mInitiatorType(aInitiatorType ? Some(*aInitiatorType) : Nothing()),
mLoadType(aLoadType),
mCacheKey(aCacheKey),
mIsActive(aIsActive),
mIsTopLevelDoc(aIsTopLevelDoc) {
mIsTopLevelDoc(aIsTopLevelDoc),
mHasNonEmptySandboxingFlags(aHasNonEmptySandboxingFlags) {
mEventQueue = new ChannelEventQueue(static_cast<nsIChannel*>(this));
SetURI(aLoadState->URI());
SetLoadInfo(aLoadInfo);
@ -147,6 +149,7 @@ DocumentChannelChild::AsyncOpen(nsIStreamListener* aListener) {
args.cacheKey() = mCacheKey;
args.isActive() = mIsActive;
args.isTopLevelDoc() = mIsTopLevelDoc;
args.hasNonEmptySandboxingFlags() = mHasNonEmptySandboxingFlags;
args.channelId() = *mChannelId;
nsCOMPtr<nsILoadContext> loadContext;

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

@ -32,7 +32,7 @@ class DocumentChannelChild final : public PDocumentChannelChild,
class LoadInfo* aLoadInfo,
const nsString* aInitiatorType, nsLoadFlags aLoadFlags,
uint32_t aLoadType, uint32_t aCacheKey, bool aIsActive,
bool aIsTopLevelDoc);
bool aIsTopLevelDoc, bool aHasNonEmptySandboxingFlags);
NS_DECL_ISUPPORTS_INHERITED;
NS_DECL_NSIASYNCVERIFYREDIRECTCALLBACK
@ -120,6 +120,7 @@ class DocumentChannelChild final : public PDocumentChannelChild,
const uint32_t mCacheKey;
const bool mIsActive;
const bool mIsTopLevelDoc;
const bool mHasNonEmptySandboxingFlags;
bool mCanceled = false;
uint32_t mSuspendCount = 0;

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

@ -69,15 +69,15 @@ bool DocumentChannelParent::Init(const DocumentChannelCreationArgs& aArgs) {
bool result = nsDocShell::CreateChannelForLoadState(
loadState, loadInfo, mListener, nullptr,
aArgs.initiatorType().ptrOr(nullptr), aArgs.loadFlags(), aArgs.loadType(),
aArgs.cacheKey(), aArgs.isActive(), aArgs.isTopLevelDoc(), rv,
getter_AddRefs(mChannel));
aArgs.cacheKey(), aArgs.isActive(), aArgs.isTopLevelDoc(),
aArgs.hasNonEmptySandboxingFlags(), rv, getter_AddRefs(mChannel));
if (!result) {
return SendFailedAsyncOpen(rv);
}
nsDocShell::ConfigureChannel(mChannel, loadState,
aArgs.initiatorType().ptrOr(nullptr),
aArgs.loadType(), aArgs.cacheKey());
nsDocShell::ConfigureChannel(
mChannel, loadState, aArgs.initiatorType().ptrOr(nullptr),
aArgs.loadType(), aArgs.cacheKey(), aArgs.hasNonEmptySandboxingFlags());
// Computation of the top window uses the docshell tree, so only
// works in the source process. We compute it manually and override

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

@ -365,6 +365,7 @@ struct DocumentChannelCreationArgs {
uint32_t cacheKey;
bool isActive;
bool isTopLevelDoc;
bool hasNonEmptySandboxingFlags;
};