Bug 822367 - Since document.open() creates a new channel, set nsDocShell:mMixedContentChannel to the newly created channel if the user has decided to allow mixed content on the page. r=smaug

This commit is contained in:
Tanvi Vyas
2013-01-30 00:04:34 -08:00
parent db95f610e2
commit a3ffccd05b
8 changed files with 54 additions and 30 deletions

View File

@@ -663,6 +663,7 @@ ConvertLoadTypeToNavigationType(uint32_t aLoadType)
case LOAD_RELOAD_BYPASS_CACHE:
case LOAD_RELOAD_BYPASS_PROXY:
case LOAD_RELOAD_BYPASS_PROXY_AND_CACHE:
case LOAD_RELOAD_ALLOW_MIXED_CONTENT:
result = dom::PerformanceNavigation::TYPE_RELOAD;
break;
case LOAD_STOP_CONTENT_AND_REPLACE:
@@ -1148,7 +1149,7 @@ ConvertDocShellLoadInfoToLoadType(nsDocShellInfoLoadType aDocShellLoadType)
loadType = LOAD_REPLACE_BYPASS_CACHE;
break;
case nsIDocShellLoadInfo::loadMixedContent:
loadType = LOAD_MIXED_CONTENT;
loadType = LOAD_RELOAD_ALLOW_MIXED_CONTENT;
break;
default:
NS_NOTREACHED("Unexpected nsDocShellInfoLoadType value");
@@ -1221,7 +1222,7 @@ nsDocShell::ConvertLoadTypeToDocShellLoadInfo(uint32_t aLoadType)
case LOAD_REPLACE_BYPASS_CACHE:
docShellLoadType = nsIDocShellLoadInfo::loadReplaceBypassCache;
break;
case LOAD_MIXED_CONTENT:
case LOAD_RELOAD_ALLOW_MIXED_CONTENT:
docShellLoadType = nsIDocShellLoadInfo::loadMixedContent;
break;
default:
@@ -5330,13 +5331,16 @@ NS_IMETHODIMP
nsDocShell::SetMixedContentChannel(nsIChannel* aMixedContentChannel)
{
#ifdef DEBUG
// Get the root docshell.
nsCOMPtr<nsIDocShellTreeItem> root;
GetSameTypeRootTreeItem(getter_AddRefs(root));
NS_WARN_IF_FALSE(
root.get() == static_cast<nsIDocShellTreeItem *>(this),
"Setting mMixedContentChannel on a docshell that is not the root docshell"
);
// if the channel is non-null
if (aMixedContentChannel) {
// Get the root docshell.
nsCOMPtr<nsIDocShellTreeItem> root;
GetSameTypeRootTreeItem(getter_AddRefs(root));
NS_WARN_IF_FALSE(
root.get() == static_cast<nsIDocShellTreeItem *>(this),
"Setting mMixedContentChannel on a docshell that is not the root docshell"
);
}
#endif
mMixedContentChannel = aMixedContentChannel;
return NS_OK;
@@ -5351,31 +5355,33 @@ nsDocShell::GetMixedContentChannel(nsIChannel **aMixedContentChannel)
}
NS_IMETHODIMP
nsDocShell::GetAllowMixedContentAndConnectionData(bool* aRootHasSecureConnection, bool* aAllowMixedContent)
nsDocShell::GetAllowMixedContentAndConnectionData(bool* aRootHasSecureConnection, bool* aAllowMixedContent, bool* aIsRootDocShell)
{
*aRootHasSecureConnection = false;
*aAllowMixedContent = false;
nsCOMPtr<nsIDocShellTreeItem> currentDocShellTreeItem = static_cast<nsIDocShellTreeItem *>(this);
NS_ASSERTION(currentDocShellTreeItem, "No DocShellTreeItem from docshell");
*aIsRootDocShell = false;
nsCOMPtr<nsIDocShellTreeItem> sameTypeRoot;
currentDocShellTreeItem->GetSameTypeRootTreeItem(getter_AddRefs(sameTypeRoot));
GetSameTypeRootTreeItem(getter_AddRefs(sameTypeRoot));
NS_ASSERTION(sameTypeRoot, "No document shell root tree item from document shell tree item!");
*aIsRootDocShell = sameTypeRoot.get() == static_cast<nsIDocShellTreeItem *>(this);
// now get the document from sameTypeRoot
nsCOMPtr<nsIDocument> rootDoc = do_GetInterface(sameTypeRoot);
NS_ASSERTION(rootDoc, "No root document from document shell root tree item.");
// nsCOMPtr<nsIScriptObjectPrincipal> prin = do_QueryInterface(rootDoc);
// nsCOMPtr<nsIPrincipal> rootPrincipal = prin->GetPrincipal();
nsCOMPtr<nsIPrincipal> rootPrincipal = rootDoc->NodePrincipal();
NS_ASSERTION(rootPrincipal, "No root principal from root document");
nsCOMPtr<nsIURI> rootUri;
rootPrincipal->GetURI(getter_AddRefs(rootUri));
NS_ASSERTION(rootUri, "No root uri from root principal");
nsresult rv = rootUri->SchemeIs("https", aRootHasSecureConnection);
NS_ENSURE_SUCCESS(rv, rv);
// For things with system principal (e.g. scratchpad) there is no uri
// aRootHasSecureConnection should remain false.
if (!nsContentUtils::IsSystemPrincipal(rootPrincipal)) {
nsCOMPtr<nsIURI> rootUri;
rootPrincipal->GetURI(getter_AddRefs(rootUri));
NS_ASSERTION(rootUri, "No root uri from root principal");
nsresult rv = rootUri->SchemeIs("https", aRootHasSecureConnection);
NS_ENSURE_SUCCESS(rv, rv);
}
// Check the root doc's channel against the root docShell's mMixedContentChannel to see
// if they are the same. If they are the same, the user has overriden
@@ -9406,7 +9412,7 @@ nsDocShell::DoURILoad(nsIURI * aURI,
}
}
if (mLoadType == LOAD_MIXED_CONTENT) {
if (mLoadType == LOAD_RELOAD_ALLOW_MIXED_CONTENT) {
rv = SetMixedContentChannel(channel);
NS_ENSURE_SUCCESS(rv, rv);
} else {
@@ -9681,6 +9687,7 @@ nsresult nsDocShell::DoChannelLoad(nsIChannel * aChannel,
case LOAD_RELOAD_BYPASS_CACHE:
case LOAD_RELOAD_BYPASS_PROXY:
case LOAD_RELOAD_BYPASS_PROXY_AND_CACHE:
case LOAD_RELOAD_ALLOW_MIXED_CONTENT:
case LOAD_REPLACE_BYPASS_CACHE:
loadFlags |= nsIRequest::LOAD_BYPASS_CACHE |
nsIRequest::LOAD_FRESH_CONNECTION;
@@ -9978,7 +9985,8 @@ nsDocShell::OnNewURI(nsIURI * aURI, nsIChannel * aChannel, nsISupports* aOwner,
if (aChannel &&
(aLoadType == LOAD_RELOAD_BYPASS_CACHE ||
aLoadType == LOAD_RELOAD_BYPASS_PROXY ||
aLoadType == LOAD_RELOAD_BYPASS_PROXY_AND_CACHE)) {
aLoadType == LOAD_RELOAD_BYPASS_PROXY_AND_CACHE ||
aLoadType == LOAD_RELOAD_ALLOW_MIXED_CONTENT)) {
NS_ASSERTION(!updateSHistory,
"We shouldn't be updating session history for forced"
" reloads!");