Bug 266554 - Ensure document is non-null in nsDocShell::ForceRefreshURI. r=peterv,dom-core,smaug

This should be safe to do because Refreshes are applied only to
documents and not to subresources.

Differential Revision: https://phabricator.services.mozilla.com/D227448
This commit is contained in:
Zach Hoffman
2024-11-14 03:56:29 +00:00
parent cdef57f69d
commit 838ec2eb6a
3 changed files with 55 additions and 18 deletions

View File

@@ -5028,29 +5028,26 @@ nsDocShell::ForceRefreshURI(nsIURI* aURI, nsIPrincipal* aPrincipal,
loadState->SetKeepResultPrincipalURIIfSet(true);
loadState->SetIsMetaRefresh(true);
RefPtr<Document> doc = GetDocument();
NS_ENSURE_STATE(doc);
// Set the triggering pricipal to aPrincipal if available, or current
// document's principal otherwise.
nsCOMPtr<nsIPrincipal> principal = aPrincipal;
RefPtr<Document> doc = GetDocument();
if (!principal) {
if (!doc) {
return NS_ERROR_FAILURE;
}
principal = doc->NodePrincipal();
}
loadState->SetTriggeringPrincipal(principal);
if (doc) {
loadState->SetCsp(doc->GetCsp());
loadState->SetHasValidUserGestureActivation(
doc->HasValidTransientUserGestureActivation());
loadState->SetCsp(doc->GetCsp());
loadState->SetHasValidUserGestureActivation(
doc->HasValidTransientUserGestureActivation());
loadState->SetTextDirectiveUserActivation(
doc->ConsumeTextDirectiveUserActivation() ||
loadState->HasValidUserGestureActivation());
loadState->SetTriggeringSandboxFlags(doc->GetSandboxFlags());
loadState->SetTriggeringWindowId(doc->InnerWindowID());
loadState->SetTriggeringStorageAccess(doc->UsingStorageAccess());
}
loadState->SetTextDirectiveUserActivation(
doc->ConsumeTextDirectiveUserActivation() ||
loadState->HasValidUserGestureActivation());
loadState->SetTriggeringSandboxFlags(doc->GetSandboxFlags());
loadState->SetTriggeringWindowId(doc->InnerWindowID());
loadState->SetTriggeringStorageAccess(doc->UsingStorageAccess());
loadState->SetPrincipalIsExplicit(true);