summaryrefslogtreecommitdiffstats
path: root/docshell/base/nsDocShell.cpp
diff options
context:
space:
mode:
authorSamael Wang <freesamael@gmail.com>2018-02-06 13:28:30 -0500
committerwolfbeast <mcwerewolf@gmail.com>2018-03-14 10:57:15 +0100
commita0892817409177372d61a2d65ca242b8ef2c320d (patch)
treef67e36ccd75d8ab2a5a14d4e9caba9a7255788f3 /docshell/base/nsDocShell.cpp
parentf56791f643f8fa547805d99ec938b135d665a9c6 (diff)
downloadUXP-a0892817409177372d61a2d65ca242b8ef2c320d.tar
UXP-a0892817409177372d61a2d65ca242b8ef2c320d.tar.gz
UXP-a0892817409177372d61a2d65ca242b8ef2c320d.tar.lz
UXP-a0892817409177372d61a2d65ca242b8ef2c320d.tar.xz
UXP-a0892817409177372d61a2d65ca242b8ef2c320d.zip
Bug 1416307 - Set triggeringPrincipal to current document's principal, if aPrincipal is not given. r=bz, a=ritu
MozReview-Commit-ID: 8lxKFeUlyzq --HG-- extra : rebase_source : 5f364f5cf84c12717bee021d752aa0f9ba4619dd extra : intermediate-source : 9df27a7142ffb065fb56c3fc873298988deacb98 extra : source : 9fcf48189000ab8ee16f236be57c9659c7243b42
Diffstat (limited to 'docshell/base/nsDocShell.cpp')
-rw-r--r--docshell/base/nsDocShell.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp
index 2e08e6720..50641508d 100644
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -6806,9 +6806,17 @@ nsDocShell::ForceRefreshURI(nsIURI* aURI, int32_t aDelay, bool aMetaRefresh, nsI
*/
loadInfo->SetReferrer(mCurrentURI);
- /* Don't ever "guess" on which principal to use to avoid picking
- * the current principal.
- */
+ // Set the triggering pricipal to aPrincipal if available, or current
+ // document's principal otherwise.
+ nsCOMPtr<nsIPrincipal> principal = aPrincipal;
+ if (!principal) {
+ nsCOMPtr<nsIDocument> doc = GetDocument();
+ if (!doc) {
+ return NS_ERROR_FAILURE;
+ }
+ principal = doc->NodePrincipal();
+ }
+ loadInfo->SetTriggeringPrincipal(principal);
loadInfo->SetPrincipalIsExplicit(true);
/* Check if this META refresh causes a redirection
@@ -6836,13 +6844,6 @@ nsDocShell::ForceRefreshURI(nsIURI* aURI, int32_t aDelay, bool aMetaRefresh, nsI
loadInfo->SetLoadType(nsIDocShellLoadInfo::loadRefresh);
}
- // If the principal is null, the refresh will have a triggeringPrincipal
- // derived from the referrer URI, or will be set to the system principal
- // if there is no refererrer. See LoadURI()
- if (aPrincipal) {
- loadInfo->SetTriggeringPrincipal(aPrincipal);
- }
-
/*
* LoadURI(...) will cancel all refresh timers... This causes the
* Timer and its refreshData instance to be released...