Bug 1770944 - Remove `isInIsolatedMozBrowserElement`. r=smaug,necko-reviewers,kershaw,valentin

Depends on D183229

Differential Revision: https://phabricator.services.mozilla.com/D183230
This commit is contained in:
Artur Iunusov 2024-02-22 10:13:14 +00:00
Родитель 0e02ba5464
Коммит 8a817efa45
5 изменённых файлов: 17 добавлений и 59 удалений

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

@ -1190,13 +1190,6 @@ BasePrincipal::GetPrivateBrowsingId(uint32_t* aPrivateBrowsingId) {
return NS_OK;
}
NS_IMETHODIMP
BasePrincipal::GetIsInIsolatedMozBrowserElement(
bool* aIsInIsolatedMozBrowserElement) {
*aIsInIsolatedMozBrowserElement = IsInIsolatedMozBrowserElement();
return NS_OK;
}
nsresult BasePrincipal::GetAddonPolicy(
extensions::WebExtensionPolicy** aResult) {
AssertIsOnMainThread();

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

@ -163,8 +163,6 @@ class BasePrincipal : public nsJSPrincipals {
NS_IMETHOD GetIsIpAddress(bool* aIsIpAddress) override;
NS_IMETHOD GetIsLocalIpAddress(bool* aIsIpAddress) override;
NS_IMETHOD GetIsOnion(bool* aIsOnion) override;
NS_IMETHOD GetIsInIsolatedMozBrowserElement(
bool* aIsInIsolatedMozBrowserElement) final;
NS_IMETHOD GetUserContextId(uint32_t* aUserContextId) final;
NS_IMETHOD GetPrivateBrowsingId(uint32_t* aPrivateBrowsingId) final;
NS_IMETHOD GetSiteOrigin(nsACString& aSiteOrigin) final;
@ -250,9 +248,6 @@ class BasePrincipal : public nsJSPrincipals {
uint32_t PrivateBrowsingId() const {
return mOriginAttributes.mPrivateBrowsingId;
}
bool IsInIsolatedMozBrowserElement() const {
return mOriginAttributes.mInIsolatedMozBrowser;
}
PrincipalKind Kind() const { return mKind; }

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

@ -586,17 +586,6 @@ interface nsIPrincipal : nsISupports
*/
[infallible] readonly attribute unsigned long privateBrowsingId;
/**
* Returns true iff the principal is inside an isolated mozbrowser element.
* <xul:browser> is not considered to be a mozbrowser element.
* <iframe mozbrowser noisolation> does not count as isolated since
* isolation is disabled. Isolation can only be disabled if the
* containing document is chrome.
*
* May be called from any thread.
*/
[infallible] readonly attribute boolean isInIsolatedMozBrowserElement;
/**
* Returns true iff this is a null principal (corresponding to an
* unknown, hence assumed minimally privileged, security context).

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

@ -308,17 +308,6 @@ nsresult GetPrincipalFromOrigin(const nsACString& aOrigin, bool aForceStripOA,
return NS_OK;
}
nsresult GetPrincipal(nsIURI* aURI, bool aIsInIsolatedMozBrowserElement,
nsIPrincipal** aPrincipal) {
OriginAttributes attrs(aIsInIsolatedMozBrowserElement);
nsCOMPtr<nsIPrincipal> principal =
BasePrincipal::CreateContentPrincipal(aURI, attrs);
NS_ENSURE_TRUE(principal, NS_ERROR_FAILURE);
principal.forget(aPrincipal);
return NS_OK;
}
nsresult GetPrincipal(nsIURI* aURI, nsIPrincipal** aPrincipal) {
OriginAttributes attrs;
nsCOMPtr<nsIPrincipal> principal =
@ -369,7 +358,6 @@ already_AddRefed<nsIURI> GetNextSubDomainURI(nsIURI* aURI) {
nsresult UpgradeHostToOriginAndInsert(
const nsACString& aHost, const nsCString& aType, uint32_t aPermission,
uint32_t aExpireType, int64_t aExpireTime, int64_t aModificationTime,
bool aIsInIsolatedMozBrowserElement,
std::function<nsresult(const nsACString& aOrigin, const nsCString& aType,
uint32_t aPermission, uint32_t aExpireType,
int64_t aExpireTime, int64_t aModificationTime)>&&
@ -396,8 +384,7 @@ nsresult UpgradeHostToOriginAndInsert(
}
nsCOMPtr<nsIPrincipal> principal;
rv = GetPrincipal(uri, aIsInIsolatedMozBrowserElement,
getter_AddRefs(principal));
rv = GetPrincipal(uri, getter_AddRefs(principal));
NS_ENSURE_SUCCESS(rv, rv);
nsAutoCString origin;
@ -512,8 +499,7 @@ nsresult UpgradeHostToOriginAndInsert(
// We now have a URI which we can make a nsIPrincipal out of
nsCOMPtr<nsIPrincipal> principal;
rv = GetPrincipal(uri, aIsInIsolatedMozBrowserElement,
getter_AddRefs(principal));
rv = GetPrincipal(uri, getter_AddRefs(principal));
if (NS_WARN_IF(NS_FAILED(rv))) continue;
nsAutoCString origin;
@ -560,8 +546,7 @@ nsresult UpgradeHostToOriginAndInsert(
rv = NS_NewURI(getter_AddRefs(uri), "http://"_ns + hostSegment);
NS_ENSURE_SUCCESS(rv, rv);
rv = GetPrincipal(uri, aIsInIsolatedMozBrowserElement,
getter_AddRefs(principal));
rv = GetPrincipal(uri, getter_AddRefs(principal));
NS_ENSURE_SUCCESS(rv, rv);
rv = GetOriginFromPrincipal(principal, IsOAForceStripPermission(aType),
@ -575,8 +560,7 @@ nsresult UpgradeHostToOriginAndInsert(
rv = NS_NewURI(getter_AddRefs(uri), "https://"_ns + hostSegment);
NS_ENSURE_SUCCESS(rv, rv);
rv = GetPrincipal(uri, aIsInIsolatedMozBrowserElement,
getter_AddRefs(principal));
rv = GetPrincipal(uri, getter_AddRefs(principal));
NS_ENSURE_SUCCESS(rv, rv);
rv = GetOriginFromPrincipal(principal, IsOAForceStripPermission(aType),
@ -3068,7 +3052,7 @@ void PermissionManager::CompleteMigrations() {
for (const MigrationEntry& entry : entries) {
rv = UpgradeHostToOriginAndInsert(
entry.mHost, entry.mType, entry.mPermission, entry.mExpireType,
entry.mExpireTime, entry.mModificationTime, entry.mIsInBrowserElement,
entry.mExpireTime, entry.mModificationTime,
[&](const nsACString& aOrigin, const nsCString& aType,
uint32_t aPermission, uint32_t aExpireType, int64_t aExpireTime,
int64_t aModificationTime) {
@ -3689,7 +3673,7 @@ nsresult PermissionManager::ImportLatestDefaults() {
rv = UpgradeHostToOriginAndInsert(
entry.mHostOrOrigin, entry.mType, entry.mPermission,
nsIPermissionManager::EXPIRE_NEVER, 0, modificationTime, false,
nsIPermissionManager::EXPIRE_NEVER, 0, modificationTime,
[&](const nsACString& aOrigin, const nsCString& aType,
uint32_t aPermission, uint32_t aExpireType, int64_t aExpireTime,
int64_t aModificationTime) {

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

@ -20,27 +20,24 @@ function cached_handler(metadata, response) {
handlers_called++;
}
function makeChan(url, inIsolatedMozBrowser, userContextId) {
function makeChan(url, userContextId) {
var chan = NetUtil.newChannel({
uri: url,
loadUsingSystemPrincipal: true,
}).QueryInterface(Ci.nsIHttpChannel);
chan.loadInfo.originAttributes = { inIsolatedMozBrowser, userContextId };
chan.loadInfo.originAttributes = { userContextId };
return chan;
}
// [inIsolatedMozBrowser, userContextId, expected_handlers_called]
// [userContextId, expected_handlers_called]
var firstTests = [
[false, 0, 1],
[true, 0, 1],
[false, 1, 1],
[true, 1, 1],
[0, 1],
[1, 1],
];
var secondTests = [
[false, 0, 0],
[true, 0, 0],
[false, 1, 1],
[true, 1, 0],
[0, 0],
[1, 1],
[1, 0],
];
async function run_all_tests() {
@ -81,9 +78,9 @@ function run_test() {
});
}
function test_channel(inIsolatedMozBrowser, userContextId, expected) {
function test_channel(userContextId, expected) {
return new Promise(resolve => {
var chan = makeChan(URL, inIsolatedMozBrowser, userContextId);
var chan = makeChan(URL, userContextId);
chan.asyncOpen(
new ChannelListener(doneFirstLoad.bind(null, resolve), expected)
);
@ -93,7 +90,7 @@ function test_channel(inIsolatedMozBrowser, userContextId, expected) {
function doneFirstLoad(resolve, req, buffer, expected) {
// Load it again, make sure it hits the cache
var oa = req.loadInfo.originAttributes;
var chan = makeChan(URL, oa.isInIsolatedMozBrowserElement, oa.userContextId);
var chan = makeChan(URL, oa.userContextId);
chan.asyncOpen(
new ChannelListener(doneSecondLoad.bind(null, resolve), expected)
);