Backed out 4 changesets (bug 1561079, bug 1561913) for apilint and checkstyle failures CLOSED TREE

Backed out changeset 50244d8132f9 (bug 1561913)
Backed out changeset 9abb44cca93b (bug 1561079)
Backed out changeset e6e23c902808 (bug 1561079)
Backed out changeset e48cf42b707f (bug 1561079)
This commit is contained in:
Bogdan Tara 2019-07-24 19:23:44 +03:00
Родитель f78b8d0022
Коммит e82c5fe738
9 изменённых файлов: 34 добавлений и 151 удалений

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

@ -4405,6 +4405,11 @@ nsDocShell::DisplayLoadError(nsresult aError, nsIURI* aURI,
}
}
// Test if the error should be displayed
if (!error) {
return NS_OK;
}
if (mLoadURIDelegate) {
nsCOMPtr<nsIURI> errorPageURI;
rv = mLoadURIDelegate->HandleLoadError(aURI, aError,
@ -4422,11 +4427,6 @@ nsDocShell::DisplayLoadError(nsresult aError, nsIURI* aURI,
}
}
// Test if the error should be displayed
if (!error) {
return NS_OK;
}
if (!errorDescriptionID) {
errorDescriptionID = error;
}

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

@ -7,7 +7,6 @@ interface nsIContentSecurityPolicy;
interface nsIPrincipal;
interface nsIURI;
interface nsIWebProgress;
interface nsIReferrerInfo;
webidl FrameLoader;
@ -82,7 +81,6 @@ interface nsIBrowser : nsISupports
readonly attribute nsIPrincipal contentPrincipal;
readonly attribute nsIContentSecurityPolicy csp;
readonly attribute nsIReferrerInfo referrerInfo;
/**
* Whether or not the browser is in the process of an nsIWebNavigation
@ -138,7 +136,6 @@ interface nsIBrowser : nsISupports
* @param aContentStoragePrincipal the security principal for the new
* document's storage
* @param aCSP the content security policy of the new document
* @param aReferrerInfo the referrer info of the new document
* @param aIsSynthetic whether or not the document is synthetic
* @param aInnerWindowID the inner window ID of the document
* @param aHasRequestContextID whether or not the the request context has a
@ -155,7 +152,6 @@ interface nsIBrowser : nsISupports
in nsIPrincipal aContentPrincipal,
in nsIPrincipal aContentStoragePrincipal,
in nsIContentSecurityPolicy aCSP,
in nsIReferrerInfo aReferrerInfo,
in boolean aIsSynthetic,
in uint64_t aInnerWindowID,
in boolean aHasRequestContextID,

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

@ -3616,7 +3616,6 @@ NS_IMETHODIMP BrowserChild::OnLocationChange(nsIWebProgress* aWebProgress,
MOZ_TRY(CSPToCSPInfo(csp, &locationChangeData->csp().ref()));
}
locationChangeData->referrerInfo() = document->ReferrerInfo();
locationChangeData->isSyntheticDocument() = document->IsSyntheticDocument();
if (nsCOMPtr<nsILoadGroup> loadGroup = document->GetDocumentLoadGroup()) {

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

@ -2494,8 +2494,6 @@ mozilla::ipc::IPCResult BrowserParent::RecvOnLocationChange(
PrincipalInfoToPrincipal(aLocationChangeData->contentPrincipal());
nsCOMPtr<nsIPrincipal> contentStoragePrincipal = PrincipalInfoToPrincipal(
aLocationChangeData->contentStoragePrincipal());
nsCOMPtr<nsIReferrerInfo> referrerInfo =
aLocationChangeData->referrerInfo();
Unused << browser->SetIsNavigating(aLocationChangeData->isNavigating());
Unused << browser->UpdateForLocationChange(
@ -2503,7 +2501,7 @@ mozilla::ipc::IPCResult BrowserParent::RecvOnLocationChange(
aLocationChangeData->mayEnableCharacterEncodingMenu(),
aLocationChangeData->charsetAutodetected(),
aLocationChangeData->documentURI(), aLocationChangeData->title(),
contentPrincipal, contentStoragePrincipal, csp, referrerInfo,
contentPrincipal, contentStoragePrincipal, csp,
aLocationChangeData->isSyntheticDocument(),
aWebProgressData->innerDOMWindowID(),
aLocationChangeData->requestContextID().isSome(),

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

@ -153,7 +153,6 @@ struct WebProgressLocationChangeData
PrincipalInfo contentPrincipal;
PrincipalInfo contentStoragePrincipal;
CSPInfo? csp;
nsIReferrerInfo referrerInfo;
uint64_t? requestContextID;
};

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

@ -1174,40 +1174,6 @@ class NavigationDelegateTest : BaseSessionTest() {
equalTo(referrer))
}
@Test fun loadUriReferrerSession() {
val uri = "https://example.com/bar"
val referrer = "https://example.org/foo"
sessionRule.session.loadUri(referrer)
sessionRule.session.waitForPageStop()
val newSession = sessionRule.createOpenSession()
newSession.loadUri(uri, sessionRule.session, GeckoSession.LOAD_FLAGS_NONE)
newSession.waitForPageStop()
assertThat("Referrer should match",
newSession.evaluateJS("document.referrer") as String,
equalTo(referrer))
}
@Test fun loadUriReferrerSessionFileUrl() {
val uri = "file:///system/etc/fonts.xml"
val referrer = "https://example.org"
sessionRule.session.loadUri(referrer)
sessionRule.session.waitForPageStop()
val newSession = sessionRule.createOpenSession()
newSession.loadUri(uri, sessionRule.session, GeckoSession.LOAD_FLAGS_NONE)
newSession.waitUntilCalled(object : Callbacks.NavigationDelegate {
@AssertCalled
override fun onLoadError(session: GeckoSession, uri: String?, error: WebRequestError): GeckoResult<String>? {
return null
}
})
}
@Test(expected = GeckoResult.UncaughtException::class)
fun onNewSession_doesNotAllowOpened() {
// Disable popup blocker.

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

@ -1534,7 +1534,7 @@ public class GeckoSession implements Parcelable {
*/
@AnyThread
public void loadUri(final @NonNull String uri) {
loadUri(uri, (GeckoSession)null, LOAD_FLAGS_NONE);
loadUri(uri, null, LOAD_FLAGS_NONE);
}
/**
@ -1545,7 +1545,7 @@ public class GeckoSession implements Parcelable {
*/
@AnyThread
public void loadUri(final @NonNull String uri, final @LoadFlags int flags) {
loadUri(uri, (GeckoSession)null, flags);
loadUri(uri, null, flags);
}
/**
@ -1563,29 +1563,7 @@ public class GeckoSession implements Parcelable {
msg.putInt("flags", flags);
if (referrer != null) {
msg.putString("referrerUri", referrer);
}
mEventDispatcher.dispatch("GeckoView:LoadUri", msg);
}
/**
* Load the given URI with the specified referrer and load type. This method will also do any
* applicable checks to ensure that the specified URI is both safe and allowable
* according to the referring GeckoSession.
*
* @param uri the URI to load
* @param referrer the referring GeckoSession, may be null
* @param flags the load flags to use, an OR-ed value of {@link #LOAD_FLAGS_NONE LOAD_FLAGS_*}
*/
@AnyThread
public void loadUri(final @NonNull String uri, final @Nullable GeckoSession referrer,
final @LoadFlags int flags) {
final GeckoBundle msg = new GeckoBundle();
msg.putString("uri", uri);
msg.putInt("flags", flags);
if (referrer != null) {
msg.putString("referrerSessionId", referrer.mId);
msg.putString("referrer", referrer);
}
mEventDispatcher.dispatch("GeckoView:LoadUri", msg);
}
@ -1606,7 +1584,7 @@ public class GeckoSession implements Parcelable {
*/
@AnyThread
public void loadUri(final @NonNull Uri uri, final @LoadFlags int flags) {
loadUri(uri.toString(), (GeckoSession)null, flags);
loadUri(uri.toString(), null, flags);
}
/**
@ -1635,7 +1613,7 @@ public class GeckoSession implements Parcelable {
throw new IllegalArgumentException("data cannot be null");
}
loadUri(createDataUri(data, mimeType), (GeckoSession)null, LOAD_FLAGS_NONE);
loadUri(createDataUri(data, mimeType), null, LOAD_FLAGS_NONE);
}
/**
@ -1650,8 +1628,8 @@ public class GeckoSession implements Parcelable {
if (bytes == null) {
throw new IllegalArgumentException("data cannot be null");
}
loadUri(createDataUri(bytes, mimeType), (GeckoSession)null, LOAD_FLAGS_FORCE_ALLOW_DATA_URI);
loadUri(createDataUri(bytes, mimeType), null, LOAD_FLAGS_FORCE_ALLOW_DATA_URI);
}
/**

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

@ -105,7 +105,7 @@ class GeckoViewNavigation extends GeckoViewModule {
this.browser.gotoIndex(aData.index);
break;
case "GeckoView:LoadUri":
const { uri, referrerUri, referrerSessionId, flags } = aData;
const { uri, referrer, flags } = aData;
let navFlags = 0;
@ -138,72 +138,34 @@ class GeckoViewNavigation extends GeckoViewModule {
this.moduleManager.updateRemoteTypeForURI(uri);
}
let triggeringPrincipal, referrerInfo, csp;
if (referrerSessionId) {
const referrerWindow = Services.ww.getWindowByName(
referrerSessionId,
this.window
);
triggeringPrincipal = referrerWindow.browser.contentPrincipal;
csp = referrerWindow.browser.csp;
const referrerPolicy = referrerWindow.browser.referrerInfo
? referrerWindow.browser.referrerInfo.referrerPolicy
: Ci.nsIHttpChannel.REFERRER_POLICY_UNSET;
referrerInfo = new ReferrerInfo(
referrerPolicy,
true,
referrerWindow.browser.documentURI
);
} else {
try {
const parsedUri = Services.io.newURI(uri);
if (
parsedUri.schemeIs("about") ||
parsedUri.schemeIs("data") ||
parsedUri.schemeIs("file") ||
parsedUri.schemeIs("resource") ||
parsedUri.schemeIs("moz-extension")
) {
// Only allow privileged loading for certain URIs.
triggeringPrincipal = Services.scriptSecurityManager.createContentPrincipal(
parsedUri,
{}
);
}
} catch (ignored) {}
referrerInfo = createReferrerInfo(referrerUri);
}
let parsedUri;
let triggeringPrincipal;
try {
parsedUri = Services.io.newURI(uri);
if (
parsedUri.schemeIs("about") ||
parsedUri.schemeIs("data") ||
parsedUri.schemeIs("file") ||
parsedUri.schemeIs("resource") ||
parsedUri.schemeIs("moz-extension")
) {
// Only allow privileged loading for certain URIs.
triggeringPrincipal = Services.scriptSecurityManager.createContentPrincipal(
parsedUri,
{}
);
}
} catch (ignored) {}
if (!triggeringPrincipal) {
triggeringPrincipal = Services.scriptSecurityManager.createNullPrincipal(
{}
);
}
// For any navigation here, we should have an appropriate triggeringPrincipal:
//
// 1) If we have a referring session, triggeringPrincipal is the contentPrincipal from the
// referring document.
// 2) For certain URI schemes listed above, we will have a codebase principal.
// 3) In all other cases, we create a NullPrincipal.
//
// The navigation flags are driven by the app. We purposely do not propagate these from
// the referring document, but expect that the app will in most cases.
//
// The referrerInfo is derived from the referring document, if present, by propagating any
// referrer policy. If we only have the referrerUri from the app, we create a referrerInfo
// with the specified URI and no policy set. If no referrerUri is present and we have no
// referring session, the referrerInfo is null.
//
// csp is only present if we have a referring document, null otherwise.
this.browser.loadURI(uri, {
this.browser.loadURI(parsedUri ? parsedUri.spec : uri, {
flags: navFlags,
referrerInfo,
referrerInfo: createReferrerInfo(referrer),
triggeringPrincipal,
csp,
});
break;
case "GeckoView:Reload":
@ -413,7 +375,6 @@ class GeckoViewNavigation extends GeckoViewModule {
aFlags,
aTriggeringPrincipal,
aCsp,
aReferrerInfo,
aNextRemoteTabId
) {
debug`handleOpenUri: uri=${aUri && aUri.spec}
@ -453,11 +414,9 @@ class GeckoViewNavigation extends GeckoViewModule {
return null;
}
// 3) We have a new session and a browser element, load the requested URI.
browser.loadURI(aUri.spec, {
triggeringPrincipal: aTriggeringPrincipal,
csp: aCsp,
referrerInfo: aReferrerInfo,
});
return browser;
}
@ -471,7 +430,6 @@ class GeckoViewNavigation extends GeckoViewModule {
aFlags,
aTriggeringPrincipal,
aCsp,
null,
null
);
return browser && browser.contentWindow;
@ -486,7 +444,6 @@ class GeckoViewNavigation extends GeckoViewModule {
aFlags,
aParams.triggeringPrincipal,
aParams.csp,
aParams.referrerInfo,
aNextRemoteTabId
);
return browser;

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

@ -306,8 +306,6 @@
this._csp = null;
this._referrerInfo = null;
this._contentRequestContextID = null;
this._fullZoom = 1;
@ -805,12 +803,6 @@
}
}
get referrerInfo() {
return this.isRemoteBrowser
? this._referrerInfo
: this.contentDocument.referrerInfo;
}
get fullZoom() {
if (this.isRemoteBrowser) {
return this._fullZoom;
@ -1568,7 +1560,6 @@
aContentPrincipal,
aContentStoragePrincipal,
aCSP,
aReferrerInfo,
aIsSynthetic,
aInnerWindowID,
aHaveRequestContextID,
@ -1593,7 +1584,6 @@
this._contentPrincipal = aContentPrincipal;
this._contentStoragePrincipal = aContentStoragePrincipal;
this._csp = aCSP;
this._referrerInfo = aReferrerInfo;
this._isSyntheticDocument = aIsSynthetic;
this._innerWindowID = aInnerWindowID;
this._contentRequestContextID = aHaveRequestContextID