Bug 1580596 - Fix usage of nsIDocShellTreeItem in nsDocShell::CheckLoadingPermission r=kmag

Differential Revision: https://phabricator.services.mozilla.com/D56004
This commit is contained in:
Steven MacLeod 2020-08-10 19:36:35 +00:00
Родитель bd0bbd881d
Коммит 560478715a
1 изменённых файлов: 12 добавлений и 8 удалений

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

@ -7957,9 +7957,17 @@ nsresult nsDocShell::CheckLoadingPermissions() {
// Check if the caller is from the same origin as this docshell,
// or any of its ancestors.
nsCOMPtr<nsIDocShellTreeItem> item(this);
do {
nsCOMPtr<nsIScriptGlobalObject> sgo = do_GetInterface(item);
for (RefPtr<BrowsingContext> bc = mBrowsingContext; bc;
bc = bc->GetParent()) {
// If the BrowsingContext is not in process, then it
// is true by construction that its principal will not
// subsume the current docshell principal.
if (!bc->IsInProcess()) {
continue;
}
nsCOMPtr<nsIScriptGlobalObject> sgo =
bc->GetDocShell()->GetScriptGlobalObject();
nsCOMPtr<nsIScriptObjectPrincipal> sop(do_QueryInterface(sgo));
nsIPrincipal* p;
@ -7971,11 +7979,7 @@ nsresult nsDocShell::CheckLoadingPermissions() {
// Same origin, permit load
return NS_OK;
}
nsCOMPtr<nsIDocShellTreeItem> tmp;
item->GetInProcessSameTypeParent(getter_AddRefs(tmp));
item.swap(tmp);
} while (item);
}
return NS_ERROR_DOM_PROP_ACCESS_DENIED;
}