Skip to content

Commit

Permalink
Bug 1770944: Fixed permission manager tests, r=smaug
Browse files Browse the repository at this point in the history
Depends on D192485

Differential Revision: https://phabricator.services.mozilla.com/D192502
  • Loading branch information
aiunusov485 committed Feb 20, 2024
1 parent 5191fef commit 8140032
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 45 deletions.
17 changes: 1 addition & 16 deletions extensions/permissions/test/unit/test_permmanager_cleardata.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,7 @@ function run_test() {

pm = Services.perms;

let entries = [
{ origin: "http://example.com", originAttributes: {} },
{
origin: "http://example.com",
originAttributes: { inIsolatedMozBrowser: true },
},
];
let entries = [{ origin: "http://example.com", originAttributes: {} }];

// In that case, all permissions should be removed.
test(entries, getData({}), [
Expand All @@ -81,13 +75,4 @@ function run_test() {
pm.ALLOW_ACTION,
pm.ALLOW_ACTION,
]);

// In that case, only the permissions related to a browserElement should be removed.
// All the other permissions should stay.
test(entries, getData({ inIsolatedMozBrowser: true }), [
pm.ALLOW_ACTION,
pm.UNKNOWN_ACTION,
pm.ALLOW_ACTION,
pm.ALLOW_ACTION,
]);
}
30 changes: 1 addition & 29 deletions extensions/permissions/test/unit/test_permmanager_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,7 @@ add_task(async function do_test() {
{}
);

let attrs = { inIsolatedMozBrowser: true };
let principal4 = Services.scriptSecurityManager.createContentPrincipal(
TEST_ORIGIN,
attrs
);
let principal5 = Services.scriptSecurityManager.createContentPrincipal(
TEST_ORIGIN_3,
attrs
);

attrs = { userContextId: 1 };
let attrs = { userContextId: 1 };
let principal1UserContext =
Services.scriptSecurityManager.createContentPrincipal(TEST_ORIGIN, attrs);
attrs = { privateBrowsingId: 1 };
Expand Down Expand Up @@ -140,10 +130,6 @@ add_task(async function do_test() {
Ci.nsIPermissionManager.ALLOW_ACTION,
pm.testPermissionFromPrincipal(principal3, TEST_PERMISSION)
);
Assert.equal(
Ci.nsIPermissionManager.ALLOW_ACTION,
pm.testPermissionFromPrincipal(principal4, TEST_PERMISSION)
);
// Depending on the prefs there are two scenarios here:
// 1. We isolate by private browsing: The permission mgr should
// add default permissions for these principals too.
Expand All @@ -155,12 +141,6 @@ add_task(async function do_test() {
pm.testPermissionFromPrincipal(principal1PrivateBrowsing, TEST_PERMISSION)
);

// Didn't add
Assert.equal(
Ci.nsIPermissionManager.UNKNOWN_ACTION,
pm.testPermissionFromPrincipal(principal5, TEST_PERMISSION)
);

// the permission should exist in the enumerator.
Assert.equal(
Ci.nsIPermissionManager.ALLOW_ACTION,
Expand Down Expand Up @@ -189,10 +169,6 @@ add_task(async function do_test() {
Ci.nsIPermissionManager.ALLOW_ACTION,
pm.testPermissionFromPrincipal(principal3, TEST_PERMISSION)
);
Assert.equal(
Ci.nsIPermissionManager.ALLOW_ACTION,
pm.testPermissionFromPrincipal(principal4, TEST_PERMISSION)
);

// remove all should not throw and the default should remain
pm.removeAll();
Expand All @@ -209,10 +185,6 @@ add_task(async function do_test() {
Ci.nsIPermissionManager.ALLOW_ACTION,
pm.testPermissionFromPrincipal(principal3, TEST_PERMISSION)
);
Assert.equal(
Ci.nsIPermissionManager.ALLOW_ACTION,
pm.testPermissionFromPrincipal(principal4, TEST_PERMISSION)
);
// Default permission should have also been added for private browsing.
Assert.equal(
Ci.nsIPermissionManager.ALLOW_ACTION,
Expand Down

0 comments on commit 8140032

Please sign in to comment.