Bug 1118502 - part 2 - ensure addOneTab sees a referrer URI if it was available; r=mconley

addOneTab uses the existence of a referrer URI to determine where to
position the newly opened tab.  Bug 1031264 changed callsites so that a
referrer URI was no longer passed in if the opening link had
rel=noreferrer set on it.  This change, then, broke placement of newly
opened tabs if their opening link had rel=noreferrer on it.

Instead of not passing in the referrer URI if rel=noreferrer, let's
instead explicitly tell addOneTab whether rel=noreferrer was present on
the opening link.  Then addOneTab can hide the referrer URI from the
actual network request, while still using the referrer URI to determine
tab placement.
This commit is contained in:
Nathan Froyd 2015-02-06 14:00:45 -05:00
parent 91a0018d2e
commit cdc1157352
5 changed files with 21 additions and 12 deletions

View File

@ -5818,9 +5818,9 @@ function handleLinkClick(event, href, linkNode) {
urlSecurityCheck(href, doc.nodePrincipal);
let params = { charset: doc.characterSet,
allowMixedContent: persistAllowMixedContentInChildTab };
if (!BrowserUtils.linkHasNoReferrer(linkNode))
params.referrerURI = referrerURI;
allowMixedContent: persistAllowMixedContentInChildTab,
referrerURI: referrerURI,
noReferrer: BrowserUtils.linkHasNoReferrer(linkNode) };
openLinkIn(href, where, params);
event.preventDefault();
return true;

View File

@ -856,9 +856,9 @@ nsContextMenu.prototype = {
},
_openLinkInParameters : function (doc, extra) {
let params = { charset: doc.characterSet };
if (!BrowserUtils.linkHasNoReferrer(this.link))
params.referrerURI = doc.documentURIObject;
let params = { charset: doc.characterSet,
referrerURI: doc.documentURIObject,
noReferrer: BrowserUtils.linkHasNoReferrer(this.link) };
for (let p in extra)
params[p] = extra[p];
return params;

View File

@ -1367,6 +1367,7 @@
var aAllowMixedContent;
var aSkipAnimation;
var aForceNotRemote;
var aNoReferrer;
if (arguments.length == 2 &&
typeof arguments[1] == "object" &&
!(arguments[1] instanceof Ci.nsIURI)) {
@ -1381,6 +1382,7 @@
aAllowMixedContent = params.allowMixedContent;
aSkipAnimation = params.skipAnimation;
aForceNotRemote = params.forceNotRemote;
aNoReferrer = params.noReferrer;
}
var bgLoad = (aLoadInBackground != null) ? aLoadInBackground :
@ -1396,7 +1398,8 @@
relatedToCurrent: aRelatedToCurrent,
skipAnimation: aSkipAnimation,
allowMixedContent: aAllowMixedContent,
forceNotRemote: aForceNotRemote });
forceNotRemote: aForceNotRemote,
noReferrer: aNoReferrer });
if (!bgLoad)
this.selectedTab = tab;
@ -1676,6 +1679,7 @@
var aSkipAnimation;
var aAllowMixedContent;
var aForceNotRemote;
var aNoReferrer;
if (arguments.length == 2 &&
typeof arguments[1] == "object" &&
!(arguments[1] instanceof Ci.nsIURI)) {
@ -1690,6 +1694,7 @@
aSkipAnimation = params.skipAnimation;
aAllowMixedContent = params.allowMixedContent;
aForceNotRemote = params.forceNotRemote;
aNoReferrer = params.noReferrer;
}
// if we're adding tabs, we're past interrupt mode, ditch the owner
@ -1826,7 +1831,9 @@
if (aAllowMixedContent)
flags |= Ci.nsIWebNavigation.LOAD_FLAGS_ALLOW_MIXED_CONTENT;
try {
b.loadURIWithFlags(aURI, flags, aReferrerURI, aCharset, aPostData);
b.loadURIWithFlags(aURI, flags,
aNoReferrer ? null : aReferrerURI,
aCharset, aPostData);
} catch (ex) {
Cu.reportError(ex);
}

View File

@ -223,6 +223,7 @@ function openLinkIn(url, where, params) {
var aIsPrivate = params.private;
var aSkipTabAnimation = params.skipTabAnimation;
var aAllowPinnedTabHostChange = !!params.allowPinnedTabHostChange;
var aNoReferrer = params.noReferrer;
if (where == "save") {
if (!aInitiatingDoc) {
@ -340,7 +341,8 @@ function openLinkIn(url, where, params) {
allowThirdPartyFixup: aAllowThirdPartyFixup,
relatedToCurrent: aRelatedToCurrent,
skipAnimation: aSkipTabAnimation,
allowMixedContent: aAllowMixedContent
allowMixedContent: aAllowMixedContent,
noReferrer: aNoReferrer
});
break;
}

View File

@ -68,9 +68,9 @@ let ContentClick = {
// Todo(903022): code for where == save
let params = { charset: browser.characterSet };
if (!json.noReferrer)
params.referrerURI = browser.documentURI;
let params = { charset: browser.characterSet,
referrerURI: browser.documentURI,
noReferrer: json.noReferrer };
window.openLinkIn(json.href, where, params);
// Mark the page as a user followed link. This is done so that history can