summaryrefslogtreecommitdiffstats
path: root/application/palemoon/base/content/utilityOverlay.js
diff options
context:
space:
mode:
authorjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-04-29 08:37:49 +0200
committerjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-04-29 08:37:49 +0200
commitc21420c94ac59b79b1935a2240dfc09a4720f443 (patch)
treec33a1cb5c196dfd73d199f114baaef901c8f4a83 /application/palemoon/base/content/utilityOverlay.js
parentde057c7a5635e65f45ce47162d226b1ddf24e8aa (diff)
downloadUXP-c21420c94ac59b79b1935a2240dfc09a4720f443.tar
UXP-c21420c94ac59b79b1935a2240dfc09a4720f443.tar.gz
UXP-c21420c94ac59b79b1935a2240dfc09a4720f443.tar.lz
UXP-c21420c94ac59b79b1935a2240dfc09a4720f443.tar.xz
UXP-c21420c94ac59b79b1935a2240dfc09a4720f443.zip
[PALEMOON] [frontend and backend] Added support for "referrerPolicy"
Issue #121 https://bugzilla.mozilla.org/show_bug.cgi?id=1113431
Diffstat (limited to 'application/palemoon/base/content/utilityOverlay.js')
-rw-r--r--application/palemoon/base/content/utilityOverlay.js52
1 files changed, 41 insertions, 11 deletions
diff --git a/application/palemoon/base/content/utilityOverlay.js b/application/palemoon/base/content/utilityOverlay.js
index 86cc5cea5..9763891ba 100644
--- a/application/palemoon/base/content/utilityOverlay.js
+++ b/application/palemoon/base/content/utilityOverlay.js
@@ -104,7 +104,8 @@ function openUILink(url, event, aIgnoreButton, aIgnoreAlt, aAllowThirdPartyFixup
allowThirdPartyFixup: aAllowThirdPartyFixup,
postData: aPostData,
referrerURI: aReferrerURI,
- initiatingDoc: event ? event.target.ownerDocument : null
+ referrerPolicy: Components.interfaces.nsIHttpChannel.REFERRER_POLICY_DEFAULT,
+ initiatingDoc: event ? event.target.ownerDocument : null,
};
}
@@ -196,7 +197,8 @@ function openUILinkIn(url, where, aAllowThirdPartyFixup, aPostData, aReferrerURI
params = {
allowThirdPartyFixup: aAllowThirdPartyFixup,
postData: aPostData,
- referrerURI: aReferrerURI
+ referrerURI: aReferrerURI,
+ referrerPolicy: Components.interfaces.nsIHttpChannel.REFERRER_POLICY_DEFAULT,
};
}
@@ -209,12 +211,16 @@ function openUILinkIn(url, where, aAllowThirdPartyFixup, aPostData, aReferrerURI
function openLinkIn(url, where, params) {
if (!where || !url)
return;
+ const Cc = Components.classes;
+ const Ci = Components.interfaces;
var aFromChrome = params.fromChrome;
var aAllowThirdPartyFixup = params.allowThirdPartyFixup;
var aPostData = params.postData;
var aCharset = params.charset;
var aReferrerURI = params.referrerURI;
+ var aReferrerPolicy = ('referrerPolicy' in params ?
+ params.referrerPolicy : Ci.nsIHttpChannel.REFERRER_POLICY_DEFAULT);
var aRelatedToCurrent = params.relatedToCurrent;
var aForceAllowDataURI = params.forceAllowDataURI;
var aInBackground = params.inBackground;
@@ -229,11 +235,10 @@ function openLinkIn(url, where, params) {
"where == 'save' but without initiatingDoc. See bug 814264.");
return;
}
+ // TODO(1073187): propagate referrerPolicy.
saveURL(url, null, null, true, null, aReferrerURI, aInitiatingDoc);
return;
}
- const Cc = Components.classes;
- const Ci = Components.interfaces;
var w = getTopWin();
if ((where == "tab" || where == "tabshifted") &&
@@ -243,6 +248,7 @@ function openLinkIn(url, where, params) {
}
if (!w || where == "window") {
+ // This propagates to window.arguments.
// Strip referrer data when opening a new private window, to prevent
// regular browsing data from leaking into it.
if (aIsPrivate) {
@@ -267,12 +273,23 @@ function openLinkIn(url, where, params) {
createInstance(Ci.nsISupportsPRBool);
allowThirdPartyFixupSupports.data = aAllowThirdPartyFixup;
+ var referrerURISupports = null;
+ if (aReferrerURI && sendReferrerURI) {
+ referrerURISupports = Cc["@mozilla.org/supports-string;1"].
+ createInstance(Ci.nsISupportsString);
+ referrerURISupports.data = aReferrerURI.spec;
+ }
+
+ var referrerPolicySupports = Cc["@mozilla.org/supports-PRUint32;1"].
+ createInstance(Ci.nsISupportsPRUint32);
+ referrerPolicySupports.data = aReferrerPolicy;
+
sa.AppendElement(wuri);
sa.AppendElement(charset);
- if (sendReferrerURI)
- sa.AppendElement(aReferrerURI);
+ sa.AppendElement(referrerURISupports);
sa.AppendElement(aPostData);
sa.AppendElement(allowThirdPartyFixupSupports);
+ sa.AppendElement(referrerPolicySupports);
let features = "chrome,dialog=no,all";
if (aIsPrivate) {
@@ -320,7 +337,12 @@ function openLinkIn(url, where, params) {
if (aForceAllowDataURI) {
flags |= Ci.nsIWebNavigation.LOAD_FLAGS_FORCE_ALLOW_DATA_URI;
}
- w.gBrowser.loadURIWithFlags(url, flags, aReferrerURI, null, aPostData);
+ w.gBrowser.loadURIWithFlags(url, {
+ flags: flags,
+ referrerURI: aReferrerURI,
+ referrerPolicy: aReferrerPolicy,
+ postData: aPostData,
+ });
break;
case "tabshifted":
loadInBackground = !loadInBackground;
@@ -329,6 +351,7 @@ function openLinkIn(url, where, params) {
let browser = w.gBrowser;
browser.loadOneTab(url, {
referrerURI: aReferrerURI,
+ referrerPolicy: aReferrerPolicy,
charset: aCharset,
postData: aPostData,
inBackground: loadInBackground,
@@ -577,9 +600,11 @@ function makeURLAbsolute(aBase, aUrl)
* @param [optional] aReferrer
* If aDocument is null, then this will be used as the referrer.
* There will be no security check.
+ * @param [optional] aReferrerPolicy
+ * Referrer policy - Ci.nsIHttpChannel.REFERRER_POLICY_*.
*/
function openNewTabWith(aURL, aDocument, aPostData, aEvent,
- aAllowThirdPartyFixup, aReferrer) {
+ aAllowThirdPartyFixup, aReferrer, aReferrerPolicy) {
if (aDocument)
urlSecurityCheck(aURL, aDocument.nodePrincipal);
@@ -594,10 +619,13 @@ function openNewTabWith(aURL, aDocument, aPostData, aEvent,
{ charset: originCharset,
postData: aPostData,
allowThirdPartyFixup: aAllowThirdPartyFixup,
- referrerURI: aDocument ? aDocument.documentURIObject : aReferrer });
+ referrerURI: aDocument ? aDocument.documentURIObject : aReferrer,
+ referrerPolicy: aReferrerPolicy,
+ });
}
-function openNewWindowWith(aURL, aDocument, aPostData, aAllowThirdPartyFixup, aReferrer) {
+function openNewWindowWith(aURL, aDocument, aPostData, aAllowThirdPartyFixup,
+ aReferrer, aReferrerPolicy) {
if (aDocument)
urlSecurityCheck(aURL, aDocument.nodePrincipal);
@@ -614,7 +642,9 @@ function openNewWindowWith(aURL, aDocument, aPostData, aAllowThirdPartyFixup, aR
{ charset: originCharset,
postData: aPostData,
allowThirdPartyFixup: aAllowThirdPartyFixup,
- referrerURI: aDocument ? aDocument.documentURIObject : aReferrer });
+ referrerURI: aDocument ? aDocument.documentURIObject : aReferrer,
+ referrerPolicy: aReferrerPolicy,
+ });
}
/**