Bug 1426979 P1 Ignore about:blank and about:srcdoc channels when determining if a window ClientSource is controlled or not. r=asuth

This commit is contained in:
Ben Kelly 2018-01-10 13:59:29 -05:00
Родитель aab2ca8e2b
Коммит 7310720f04
1 изменённых файлов: 25 добавлений и 1 удалений

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

@ -1750,8 +1750,32 @@ nsGlobalWindowInner::EnsureClientSource()
bool newClientSource = false;
// Get the load info for the document if we performed a load. Be careful
// not to look at about:blank or about:srcdoc loads, though. They will have
// a channel and loadinfo, but their loadinfo will never be controlled. This
// would in turn inadvertantly trigger the logic below to clear the inherited
// controller.
nsCOMPtr<nsILoadInfo> loadInfo;
nsCOMPtr<nsIChannel> channel = mDoc->GetChannel();
nsCOMPtr<nsILoadInfo> loadInfo = channel ? channel->GetLoadInfo() : nullptr;
if (channel) {
nsCOMPtr<nsIURI> uri;
Unused << channel->GetURI(getter_AddRefs(uri));
bool ignoreLoadInfo = false;
// Note, this is mostly copied from NS_IsAboutBlank(). Its duplicated
// here so we can efficiently check about:srcdoc as well.
bool isAbout = false;
if (NS_SUCCEEDED(uri->SchemeIs("about", &isAbout)) && isAbout) {
nsCString spec = uri->GetSpecOrDefault();
ignoreLoadInfo = spec.EqualsLiteral("about:blank") ||
spec.EqualsLiteral("about:srcdoc");
}
if (!ignoreLoadInfo) {
loadInfo = channel->GetLoadInfo();
}
}
// Take the initial client source from the docshell immediately. Even if we
// don't end up using it here we should consume it.