Bug 1630884 - Handle locked prefs in page info dialog. r=Gijs

Differential Revision: https://phabricator.services.mozilla.com/D74477
This commit is contained in:
Michael Kaply
2020-05-12 13:48:38 +00:00
parent 85535579f8
commit 02f5fc8729
3 changed files with 99 additions and 0 deletions

View File

@@ -44,6 +44,7 @@ skip-if = (verify && debug && (os == 'mac'))
[browser_policy_extensionsettings.js]
[browser_policy_firefoxhome.js]
[browser_policy_override_postupdatepage.js]
[browser_policy_pageinfo_permissions.js]
[browser_policy_passwordmanager.js]
[browser_policy_search_engine.js]
[browser_policy_searchbar.js]

View File

@@ -0,0 +1,71 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
const TEST_ORIGIN = "https://example.com";
/* Verifies that items on the page info page are properly disabled
when the corresponding policies are locked */
add_task(async function test_pageinfo_permissions() {
await setupPolicyEngineWithJson({
policies: {
Permissions: {
Camera: {
BlockNewRequests: true,
Locked: true,
},
Microphone: {
BlockNewRequests: true,
Locked: true,
},
Location: {
BlockNewRequests: true,
Locked: true,
},
Notifications: {
BlockNewRequests: true,
Locked: true,
},
Autoplay: {
Default: "block-audio",
Locked: true,
},
},
InstallAddonsPermission: {
Default: false,
},
PopupBlocking: {
Locked: true,
},
Cookies: {
Locked: true,
},
},
});
let permissions = [
"geo",
"autoplay-media",
"install",
"popup",
"desktop-notification",
"cookie",
"camera",
"microphone",
];
await BrowserTestUtils.withNewTab(TEST_ORIGIN, async function(browser) {
let pageInfo = BrowserPageInfo(TEST_ORIGIN, "permTab");
await BrowserTestUtils.waitForEvent(pageInfo, "load");
for (let i = 0; i < permissions.length; i++) {
let permission = permissions[i];
let checkbox = await TestUtils.waitForCondition(() =>
pageInfo.document.getElementById(`${permission}Def`)
);
ok(checkbox.disabled, `${permission} checkbox should be disabled`);
}
pageInfo.close();
});
});