зеркало из https://github.com/mozilla/gecko-dev.git
Bug 836567 - Part 1: Set ResultPrincipalURI to active document's URI before evaluating a javascript: URL. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D59464 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
b8a41d0a49
Коммит
dfa554dd6e
|
@ -155,12 +155,28 @@ nsresult nsJSThunk::EvaluateScript(
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_ENSURE_ARG_POINTER(aChannel);
|
NS_ENSURE_ARG_POINTER(aChannel);
|
||||||
|
MOZ_ASSERT(aOriginalInnerWindow,
|
||||||
|
"We should not have gotten here if this was null!");
|
||||||
|
|
||||||
|
// Set the channel's resultPrincipalURI to the active document's URI. This
|
||||||
|
// corresponds to treating that URI as the URI of our channel's response. In
|
||||||
|
// the spec we're supposed to use the URL of the active document, but since
|
||||||
|
// we bail out of here if the inner window has changed, and GetDocumentURI()
|
||||||
|
// on the inner window returns the URL of the active document if the inner
|
||||||
|
// window is current, this is equivalent to the spec behavior.
|
||||||
|
nsCOMPtr<nsIURI> docURI = aOriginalInnerWindow->GetDocumentURI();
|
||||||
|
if (!docURI) {
|
||||||
|
// We're not going to be able to have a sane URL, so just don't run the
|
||||||
|
// script at all.
|
||||||
|
return NS_ERROR_DOM_RETVAL_UNDEFINED;
|
||||||
|
}
|
||||||
|
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
|
||||||
|
loadInfo->SetResultPrincipalURI(docURI);
|
||||||
|
|
||||||
// Get principal of code for execution
|
// Get principal of code for execution
|
||||||
nsCOMPtr<nsISupports> owner;
|
nsCOMPtr<nsISupports> owner;
|
||||||
aChannel->GetOwner(getter_AddRefs(owner));
|
aChannel->GetOwner(getter_AddRefs(owner));
|
||||||
nsCOMPtr<nsIPrincipal> principal = do_QueryInterface(owner);
|
nsCOMPtr<nsIPrincipal> principal = do_QueryInterface(owner);
|
||||||
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
|
|
||||||
if (!principal) {
|
if (!principal) {
|
||||||
if (loadInfo->GetForceInheritPrincipal()) {
|
if (loadInfo->GetForceInheritPrincipal()) {
|
||||||
principal = loadInfo->FindPrincipalToInherit(aChannel);
|
principal = loadInfo->FindPrincipalToInherit(aChannel);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче