mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-03 22:07:30 +09:00
Bug 1329032 - Extend loadURIWithOptions by a triggeringPrincipal (without an hard e10s)
This commit is contained in:
parent
102550a483
commit
dee826b7ee
10 changed files with 56 additions and 22 deletions
|
|
@ -204,6 +204,9 @@ ContentRestoreInternal.prototype = {
|
||||||
: Ci.nsIHttpChannel.REFERRER_POLICY_DEFAULT);
|
: Ci.nsIHttpChannel.REFERRER_POLICY_DEFAULT);
|
||||||
let postData = loadArguments.postData ?
|
let postData = loadArguments.postData ?
|
||||||
Utils.makeInputStream(loadArguments.postData) : null;
|
Utils.makeInputStream(loadArguments.postData) : null;
|
||||||
|
let triggeringPrincipal = loadArguments.triggeringPrincipal
|
||||||
|
? Utils.deserializePrincipal(loadArguments.triggeringPrincipal)
|
||||||
|
: null;
|
||||||
|
|
||||||
if (loadArguments.userContextId) {
|
if (loadArguments.userContextId) {
|
||||||
webNavigation.setOriginAttributesBeforeLoading({ userContextId: loadArguments.userContextId });
|
webNavigation.setOriginAttributesBeforeLoading({ userContextId: loadArguments.userContextId });
|
||||||
|
|
@ -211,7 +214,7 @@ ContentRestoreInternal.prototype = {
|
||||||
|
|
||||||
webNavigation.loadURIWithOptions(loadArguments.uri, loadArguments.flags,
|
webNavigation.loadURIWithOptions(loadArguments.uri, loadArguments.flags,
|
||||||
referrer, referrerPolicy, postData,
|
referrer, referrerPolicy, postData,
|
||||||
null, null);
|
null, null, triggeringPrincipal);
|
||||||
} else if (tabData.userTypedValue && tabData.userTypedClear) {
|
} else if (tabData.userTypedValue && tabData.userTypedClear) {
|
||||||
// If the user typed a URL into the URL bar and hit enter right before
|
// If the user typed a URL into the URL bar and hit enter right before
|
||||||
// we crashed, we want to start loading that page again. A non-zero
|
// we crashed, we want to start loading that page again. A non-zero
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ const { Ci, Cu, Cr } = require("chrome");
|
||||||
const { XPCOMUtils } = require("resource://gre/modules/XPCOMUtils.jsm");
|
const { XPCOMUtils } = require("resource://gre/modules/XPCOMUtils.jsm");
|
||||||
const Services = require("Services");
|
const Services = require("Services");
|
||||||
const { NetUtil } = require("resource://gre/modules/NetUtil.jsm");
|
const { NetUtil } = require("resource://gre/modules/NetUtil.jsm");
|
||||||
|
const { Utils } = require("resource://gre/modules/sessionstore/Utils.jsm");
|
||||||
|
|
||||||
function readInputStreamToString(stream) {
|
function readInputStreamToString(stream) {
|
||||||
return NetUtil.readInputStreamToString(stream, stream.available());
|
return NetUtil.readInputStreamToString(stream, stream.available());
|
||||||
|
|
@ -61,11 +62,11 @@ BrowserElementWebNavigation.prototype = {
|
||||||
// No equivalent in the current BrowserElement API
|
// No equivalent in the current BrowserElement API
|
||||||
this.loadURIWithOptions(uri, flags, referrer,
|
this.loadURIWithOptions(uri, flags, referrer,
|
||||||
Ci.nsIHttpChannel.REFERRER_POLICY_DEFAULT,
|
Ci.nsIHttpChannel.REFERRER_POLICY_DEFAULT,
|
||||||
postData, headers, null);
|
postData, headers, null, null);
|
||||||
},
|
},
|
||||||
|
|
||||||
loadURIWithOptions(uri, flags, referrer, referrerPolicy, postData, headers,
|
loadURIWithOptions(uri, flags, referrer, referrerPolicy, postData, headers,
|
||||||
baseURI) {
|
baseURI, triggeringPrincipal) {
|
||||||
// No equivalent in the current BrowserElement API
|
// No equivalent in the current BrowserElement API
|
||||||
this._sendMessage("WebNavigation:LoadURI", {
|
this._sendMessage("WebNavigation:LoadURI", {
|
||||||
uri,
|
uri,
|
||||||
|
|
@ -75,6 +76,9 @@ BrowserElementWebNavigation.prototype = {
|
||||||
postData: postData ? readInputStreamToString(postData) : null,
|
postData: postData ? readInputStreamToString(postData) : null,
|
||||||
headers: headers ? readInputStreamToString(headers) : null,
|
headers: headers ? readInputStreamToString(headers) : null,
|
||||||
baseURI: baseURI ? baseURI.spec : null,
|
baseURI: baseURI ? baseURI.spec : null,
|
||||||
|
triggeringPrincipal: triggeringPrincipal
|
||||||
|
? Utils.serializePrincipal(triggeringPrincipal)
|
||||||
|
: null,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4732,7 +4732,7 @@ nsDocShell::LoadURI(const char16_t* aURI,
|
||||||
{
|
{
|
||||||
return LoadURIWithOptions(aURI, aLoadFlags, aReferringURI,
|
return LoadURIWithOptions(aURI, aLoadFlags, aReferringURI,
|
||||||
mozilla::net::RP_Default, aPostStream,
|
mozilla::net::RP_Default, aPostStream,
|
||||||
aHeaderStream, nullptr);
|
aHeaderStream, nullptr, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
|
@ -4742,7 +4742,8 @@ nsDocShell::LoadURIWithOptions(const char16_t* aURI,
|
||||||
uint32_t aReferrerPolicy,
|
uint32_t aReferrerPolicy,
|
||||||
nsIInputStream* aPostStream,
|
nsIInputStream* aPostStream,
|
||||||
nsIInputStream* aHeaderStream,
|
nsIInputStream* aHeaderStream,
|
||||||
nsIURI* aBaseURI)
|
nsIURI* aBaseURI,
|
||||||
|
nsIPrincipal* aTriggeringPrincipal)
|
||||||
{
|
{
|
||||||
NS_ASSERTION((aLoadFlags & 0xf) == 0, "Unexpected flags");
|
NS_ASSERTION((aLoadFlags & 0xf) == 0, "Unexpected flags");
|
||||||
|
|
||||||
|
|
@ -4861,6 +4862,7 @@ nsDocShell::LoadURIWithOptions(const char16_t* aURI,
|
||||||
loadInfo->SetReferrerPolicy(aReferrerPolicy);
|
loadInfo->SetReferrerPolicy(aReferrerPolicy);
|
||||||
loadInfo->SetHeadersStream(aHeaderStream);
|
loadInfo->SetHeadersStream(aHeaderStream);
|
||||||
loadInfo->SetBaseURI(aBaseURI);
|
loadInfo->SetBaseURI(aBaseURI);
|
||||||
|
loadInfo->SetTriggeringPrincipal(aTriggeringPrincipal);
|
||||||
loadInfo->SetForceAllowDataURI(forceAllowDataURI);
|
loadInfo->SetForceAllowDataURI(forceAllowDataURI);
|
||||||
|
|
||||||
if (fixupInfo) {
|
if (fixupInfo) {
|
||||||
|
|
@ -10606,7 +10608,7 @@ nsDocShell::InternalLoad(nsIURI* aURI,
|
||||||
}
|
}
|
||||||
bool shouldLoad;
|
bool shouldLoad;
|
||||||
rv = browserChrome3->ShouldLoadURI(this, uriForShouldLoadCheck, aReferrer,
|
rv = browserChrome3->ShouldLoadURI(this, uriForShouldLoadCheck, aReferrer,
|
||||||
&shouldLoad);
|
aTriggeringPrincipal, &shouldLoad);
|
||||||
if (NS_SUCCEEDED(rv) && !shouldLoad) {
|
if (NS_SUCCEEDED(rv) && !shouldLoad) {
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ interface nsIDOMDocument;
|
||||||
interface nsIInputStream;
|
interface nsIInputStream;
|
||||||
interface nsISHistory;
|
interface nsISHistory;
|
||||||
interface nsIURI;
|
interface nsIURI;
|
||||||
|
interface nsIPrincipal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The nsIWebNavigation interface defines an interface for navigating the web.
|
* The nsIWebNavigation interface defines an interface for navigating the web.
|
||||||
|
|
@ -288,14 +289,20 @@ interface nsIWebNavigation : nsISupports
|
||||||
* that at present this argument is only used with view-source aURIs
|
* that at present this argument is only used with view-source aURIs
|
||||||
* and cannot be used to resolve aURI.
|
* and cannot be used to resolve aURI.
|
||||||
* This parameter is optional and may be null.
|
* This parameter is optional and may be null.
|
||||||
|
* @param aTriggeringPrincipal
|
||||||
|
* The principal that initiated the load of aURI. If omitted docShell
|
||||||
|
* tries to create a codeBasePrincipal from aReferrer if not null. If
|
||||||
|
* aReferrer is also null docShell peforms a load using the
|
||||||
|
* SystemPrincipal as the triggeringPrincipal.
|
||||||
*/
|
*/
|
||||||
void loadURIWithOptions(in wstring aURI,
|
void loadURIWithOptions(in wstring aURI,
|
||||||
in unsigned long aLoadFlags,
|
in unsigned long aLoadFlags,
|
||||||
in nsIURI aReferrer,
|
in nsIURI aReferrer,
|
||||||
in unsigned long aReferrerPolicy,
|
in unsigned long aReferrerPolicy,
|
||||||
in nsIInputStream aPostData,
|
in nsIInputStream aPostData,
|
||||||
in nsIInputStream aHeaders,
|
in nsIInputStream aHeaders,
|
||||||
in nsIURI aBaseURI);
|
in nsIURI aBaseURI,
|
||||||
|
[optional] in nsIPrincipal aTriggeringPrincipal);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tells the Object to reload the current page. There may be cases where the
|
* Tells the Object to reload the current page. There may be cases where the
|
||||||
|
|
|
||||||
|
|
@ -1582,7 +1582,8 @@ nsSHistory::LoadURIWithOptions(const char16_t* aURI,
|
||||||
uint32_t aReferrerPolicy,
|
uint32_t aReferrerPolicy,
|
||||||
nsIInputStream* aPostStream,
|
nsIInputStream* aPostStream,
|
||||||
nsIInputStream* aExtraHeaderStream,
|
nsIInputStream* aExtraHeaderStream,
|
||||||
nsIURI* aBaseURI)
|
nsIURI* aBaseURI,
|
||||||
|
nsIPrincipal* aTriggeringPrincipal)
|
||||||
{
|
{
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9776,9 +9776,13 @@ nsContentUtils::AttemptLargeAllocationLoad(nsIHttpChannel* aChannel)
|
||||||
rv = aChannel->GetReferrer(getter_AddRefs(referrer));
|
rv = aChannel->GetReferrer(getter_AddRefs(referrer));
|
||||||
NS_ENSURE_SUCCESS(rv, false);
|
NS_ENSURE_SUCCESS(rv, false);
|
||||||
|
|
||||||
|
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
|
||||||
|
nsCOMPtr<nsIPrincipal> triggeringPrincipal = loadInfo->TriggeringPrincipal();
|
||||||
|
|
||||||
// Actually perform the cross process load
|
// Actually perform the cross process load
|
||||||
bool reloadSucceeded = false;
|
bool reloadSucceeded = false;
|
||||||
rv = wbc3->ReloadInFreshProcess(docShell, uri, referrer, &reloadSucceeded);
|
rv = wbc3->ReloadInFreshProcess(docShell, uri, referrer,
|
||||||
|
triggeringPrincipal, &reloadSucceeded);
|
||||||
NS_ENSURE_SUCCESS(rv, false);
|
NS_ENSURE_SUCCESS(rv, false);
|
||||||
|
|
||||||
return reloadSucceeded;
|
return reloadSucceeded;
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
interface nsIDocShell;
|
interface nsIDocShell;
|
||||||
interface nsIInputStream;
|
interface nsIInputStream;
|
||||||
|
interface nsIPrincipal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* nsIWebBrowserChrome3 is an extension to nsIWebBrowserChrome2.
|
* nsIWebBrowserChrome3 is an extension to nsIWebBrowserChrome2.
|
||||||
|
|
@ -43,10 +44,13 @@ interface nsIWebBrowserChrome3 : nsIWebBrowserChrome2
|
||||||
* The URI being loaded.
|
* The URI being loaded.
|
||||||
* @param aReferrer
|
* @param aReferrer
|
||||||
* The referrer of the load.
|
* The referrer of the load.
|
||||||
|
* @param aTriggeringPrincipal
|
||||||
|
* The principal that initiated the load of aURI.
|
||||||
*/
|
*/
|
||||||
bool shouldLoadURI(in nsIDocShell aDocShell,
|
bool shouldLoadURI(in nsIDocShell aDocShell,
|
||||||
in nsIURI aURI,
|
in nsIURI aURI,
|
||||||
in nsIURI aReferrer);
|
in nsIURI aReferrer,
|
||||||
|
in nsIPrincipal aTriggeringPrincipal);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to load the currently loaded page into a fresh process to increase
|
* Attempts to load the currently loaded page into a fresh process to increase
|
||||||
|
|
@ -57,5 +61,6 @@ interface nsIWebBrowserChrome3 : nsIWebBrowserChrome2
|
||||||
*/
|
*/
|
||||||
bool reloadInFreshProcess(in nsIDocShell aDocShell,
|
bool reloadInFreshProcess(in nsIDocShell aDocShell,
|
||||||
in nsIURI aURI,
|
in nsIURI aURI,
|
||||||
in nsIURI aReferrer);
|
in nsIURI aReferrer,
|
||||||
|
in nsIPrincipal aTriggeringPrincipal);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -654,13 +654,14 @@ nsWebBrowser::LoadURIWithOptions(const char16_t* aURI, uint32_t aLoadFlags,
|
||||||
uint32_t aReferrerPolicy,
|
uint32_t aReferrerPolicy,
|
||||||
nsIInputStream* aPostDataStream,
|
nsIInputStream* aPostDataStream,
|
||||||
nsIInputStream* aExtraHeaderStream,
|
nsIInputStream* aExtraHeaderStream,
|
||||||
nsIURI* aBaseURI)
|
nsIURI* aBaseURI,
|
||||||
|
nsIPrincipal* aTriggeringPrincipal)
|
||||||
{
|
{
|
||||||
NS_ENSURE_STATE(mDocShell);
|
NS_ENSURE_STATE(mDocShell);
|
||||||
|
|
||||||
return mDocShellAsNav->LoadURIWithOptions(
|
return mDocShellAsNav->LoadURIWithOptions(
|
||||||
aURI, aLoadFlags, aReferringURI, aReferrerPolicy, aPostDataStream,
|
aURI, aLoadFlags, aReferringURI, aReferrerPolicy, aPostDataStream,
|
||||||
aExtraHeaderStream, aBaseURI);
|
aExtraHeaderStream, aBaseURI, aTriggeringPrincipal);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
|
|
||||||
|
|
@ -390,6 +390,7 @@ NS_IMETHODIMP nsContentTreeOwner::OnBeforeLinkTraversal(const nsAString &origina
|
||||||
NS_IMETHODIMP nsContentTreeOwner::ShouldLoadURI(nsIDocShell *aDocShell,
|
NS_IMETHODIMP nsContentTreeOwner::ShouldLoadURI(nsIDocShell *aDocShell,
|
||||||
nsIURI *aURI,
|
nsIURI *aURI,
|
||||||
nsIURI *aReferrer,
|
nsIURI *aReferrer,
|
||||||
|
nsIPrincipal* aTriggeringPrincipal,
|
||||||
bool *_retval)
|
bool *_retval)
|
||||||
{
|
{
|
||||||
NS_ENSURE_STATE(mXULWindow);
|
NS_ENSURE_STATE(mXULWindow);
|
||||||
|
|
@ -398,7 +399,8 @@ NS_IMETHODIMP nsContentTreeOwner::ShouldLoadURI(nsIDocShell *aDocShell,
|
||||||
mXULWindow->GetXULBrowserWindow(getter_AddRefs(xulBrowserWindow));
|
mXULWindow->GetXULBrowserWindow(getter_AddRefs(xulBrowserWindow));
|
||||||
|
|
||||||
if (xulBrowserWindow)
|
if (xulBrowserWindow)
|
||||||
return xulBrowserWindow->ShouldLoadURI(aDocShell, aURI, aReferrer, _retval);
|
return xulBrowserWindow->ShouldLoadURI(aDocShell, aURI, aReferrer,
|
||||||
|
aTriggeringPrincipal, _retval);
|
||||||
|
|
||||||
*_retval = true;
|
*_retval = true;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
@ -407,6 +409,7 @@ NS_IMETHODIMP nsContentTreeOwner::ShouldLoadURI(nsIDocShell *aDocShell,
|
||||||
NS_IMETHODIMP nsContentTreeOwner::ReloadInFreshProcess(nsIDocShell* aDocShell,
|
NS_IMETHODIMP nsContentTreeOwner::ReloadInFreshProcess(nsIDocShell* aDocShell,
|
||||||
nsIURI* aURI,
|
nsIURI* aURI,
|
||||||
nsIURI* aReferrer,
|
nsIURI* aReferrer,
|
||||||
|
nsIPrincipal* aTriggeringPrincipal,
|
||||||
bool* aRetVal)
|
bool* aRetVal)
|
||||||
{
|
{
|
||||||
NS_WARNING("Cannot reload in fresh process from a nsContentTreeOwner!");
|
NS_WARNING("Cannot reload in fresh process from a nsContentTreeOwner!");
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ interface nsIDOMElement;
|
||||||
interface nsIInputStream;
|
interface nsIInputStream;
|
||||||
interface nsIDocShell;
|
interface nsIDocShell;
|
||||||
interface nsITabParent;
|
interface nsITabParent;
|
||||||
|
interface nsIPrincipal;
|
||||||
interface mozIDOMWindowProxy;
|
interface mozIDOMWindowProxy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -60,10 +61,13 @@ interface nsIXULBrowserWindow : nsISupports
|
||||||
* The URI being loaded.
|
* The URI being loaded.
|
||||||
* @param aReferrer
|
* @param aReferrer
|
||||||
* The referrer of the load.
|
* The referrer of the load.
|
||||||
|
* @param aTriggeringPrincipal
|
||||||
|
* The principal that initiated the load of aURI.
|
||||||
*/
|
*/
|
||||||
bool shouldLoadURI(in nsIDocShell aDocShell,
|
bool shouldLoadURI(in nsIDocShell aDocShell,
|
||||||
in nsIURI aURI,
|
in nsIURI aURI,
|
||||||
in nsIURI aReferrer);
|
in nsIURI aReferrer,
|
||||||
|
in nsIPrincipal aTriggeringPrincipal);
|
||||||
/**
|
/**
|
||||||
* Show/hide a tooltip (when the user mouses over a link, say).
|
* Show/hide a tooltip (when the user mouses over a link, say).
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue