Bug 1661280 - Remove principal.uri in BrowserUtils.jsm r=ckerschb

Differential Revision: https://phabricator.services.mozilla.com/D82918
This commit is contained in:
Sebastian Streich 2020-10-21 17:31:32 +00:00
Родитель 36f042392a
Коммит 6903ee252a
1 изменённых файлов: 22 добавлений и 23 удалений

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

@ -87,29 +87,28 @@ var BrowserUtils = {
}
let contentPrincipal = browser.contentPrincipal;
// Not all principals have URIs...
if (contentPrincipal.URI) {
// There are two special-cases involving about:blank. One is where
// the user has manually loaded it and it got created with a null
// principal. The other involves the case where we load
// some other empty page in a browser and the current page is the
// initial about:blank page (which has that as its principal, not
// just URI in which case it could be web-based). Especially in
// e10s, we need to tackle that case specifically to avoid race
// conditions when updating the URL bar.
//
// Note that we check the documentURI here, since the currentURI on
// the browser might have been set by SessionStore in order to
// support switch-to-tab without having actually loaded the content
// yet.
let uriToCheck = browser.documentURI || uri;
if (
(uriToCheck.spec == "about:blank" &&
contentPrincipal.isNullPrincipal) ||
contentPrincipal.spec == "about:blank"
) {
return true;
}
return contentPrincipal.URI.equals(uri);
// There are two special-cases involving about:blank. One is where
// the user has manually loaded it and it got created with a null
// principal. The other involves the case where we load
// some other empty page in a browser and the current page is the
// initial about:blank page (which has that as its principal, not
// just URI in which case it could be web-based). Especially in
// e10s, we need to tackle that case specifically to avoid race
// conditions when updating the URL bar.
//
// Note that we check the documentURI here, since the currentURI on
// the browser might have been set by SessionStore in order to
// support switch-to-tab without having actually loaded the content
// yet.
let uriToCheck = browser.documentURI || uri;
if (
(uriToCheck.spec == "about:blank" && contentPrincipal.isNullPrincipal) ||
contentPrincipal.spec == "about:blank"
) {
return true;
}
if (contentPrincipal.isContentPrincipal) {
return contentPrincipal.equalsURI(uri);
}
// ... so for those that don't have them, enforce that the page has the
// system principal (this matches e.g. on about:newtab).