Bug 1580348 - Port |Bug 906190 - Persist "disable protection" option for Mixed Content Blocker in child tabs| to SeaMonkey. r=frg DONTBUILD

This commit is contained in:
Ian Neal 2019-11-11 20:44:10 +01:00
Родитель 80f21e89a7
Коммит f6b978c6c1
4 изменённых файлов: 49 добавлений и 8 удалений

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

@ -109,10 +109,27 @@ function handleLinkClick(event, href, linkNode) {
return true;
}
var referrerURI = doc.documentURIObject;
// if the mixedContentChannel is present and the referring URI passes
// a same origin check with the target URI, we can preserve the users
// decision of disabling MCB on a page for it's child tabs.
var persistAllowMixedContentInChildTab = false;
if (where == "tab" && getBrowser().docShell.mixedContentChannel) {
const sm = Services.scriptSecurityManager;
try {
var targetURI = makeURI(href);
sm.checkSameOriginURI(referrerURI, targetURI, false);
persistAllowMixedContentInChildTab = true;
}
catch (e) { }
}
urlSecurityCheck(href, doc.nodePrincipal);
openLinkIn(href, where, { referrerURI: doc.documentURIObject,
openLinkIn(href, where, { referrerURI: referrerURI,
charset: doc.characterSet,
private: gPrivate ? true : false });
private: gPrivate ? true : false,
allowMixedContent: persistAllowMixedContentInChildTab });
event.preventDefault();
return true;
}

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

@ -978,10 +978,28 @@ nsContextMenu.prototype = {
openLinkInTab: function(aEvent) {
var doc = this.target.ownerDocument;
urlSecurityCheck(this.linkURL, doc.nodePrincipal);
var referrerURI = doc.documentURIObject;
// if the mixedContentChannel is present and the referring URI passes
// a same origin check with the target URI, we can preserve the users
// decision of disabling MCB on a page for it's child tabs.
var persistAllowMixedContentInChildTab = false;
if (this.browser.docShell.mixedContentChannel) {
const sm = Services.scriptSecurityManager;
try {
var targetURI = this.linkURI;
sm.checkSameOriginURI(referrerURI, targetURI, false);
persistAllowMixedContentInChildTab = true;
}
catch (e) { }
}
openLinkIn(this.linkURL,
aEvent && aEvent.shiftKey ? "tabshifted" : "tab",
{ charset: doc.characterSet,
referrerURI: doc.documentURIObject });
referrerURI: referrerURI,
allowMixedContent: persistAllowMixedContentInChildTab });
},
// Open linked-to URL in a new window.

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

@ -1483,6 +1483,7 @@ function openLinkIn(url, where, params)
var aReferrerPolicy = ("referrerPolicy" in params ?
params.referrerPolicy : Ci.nsIHttpChannel.REFERRER_POLICY_UNSET);
var aRelatedToCurrent = params.relatedToCurrent;
var aAllowMixedContent = params.allowMixedContent;
var aInBackground = params.inBackground;
var aDisallowInheritPrincipal = params.disallowInheritPrincipal;
var aInitiatingDoc = params.initiatingDoc ? params.initiatingDoc : document;
@ -1627,6 +1628,7 @@ function openLinkIn(url, where, params)
postData: aPostData,
allowThirdPartyFixup: aAllowThirdPartyFixup,
relatedToCurrent: aRelatedToCurrent,
allowMixedContent: aAllowMixedContent,
userContextId: aUserContextId,
originPrincipal: aPrincipal,
triggeringPrincipal: aTriggeringPrincipal,

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

@ -1413,6 +1413,7 @@
postData: aPostData,
inBackground: aLoadInBackground,
allowThirdPartyFixup: aAllowThirdPartyFixup,
allowMixedContent: false,
userContextId: null,
opener: null,
};
@ -1534,6 +1535,7 @@
var aReferrerPolicy;
var aFromExternal;
var aRelatedToCurrent;
var aAllowMixedContent;
var aUserContextId;
var aOpener;
if (arguments.length == 2 &&
@ -1550,6 +1552,7 @@
aAllowThirdPartyFixup = params.allowThirdPartyFixup;
aFromExternal = params.fromExternal;
aRelatedToCurrent = params.relatedToCurrent;
aAllowMixedContent = params.allowMixedContent;
aUserContextId = params.userContextId;
aOpener = params.opener;
}
@ -1628,13 +1631,14 @@
// the document successfully loads
b.userTypedValue = aURI;
let nsIWebNavigation = Ci.nsIWebNavigation;
let flags = nsIWebNavigation.LOAD_FLAGS_NONE;
let flags = Ci.nsIWebNavigation.LOAD_FLAGS_NONE;
if (aAllowThirdPartyFixup)
flags = nsIWebNavigation.LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP |
nsIWebNavigation.LOAD_FLAGS_FIXUP_SCHEME_TYPOS;
flags = Ci.nsIWebNavigation.LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP |
Ci.nsIWebNavigation.LOAD_FLAGS_FIXUP_SCHEME_TYPOS;
if (aFromExternal)
flags |= nsIWebNavigation.LOAD_FLAGS_FROM_EXTERNAL;
flags |= Ci.nsIWebNavigation.LOAD_FLAGS_FROM_EXTERNAL;
if (aAllowMixedContent)
flags |= Ci.nsIWebNavigation.LOAD_FLAGS_ALLOW_MIXED_CONTENT;
try {
b.loadURIWithFlags(aURI, {
flags,