From 89fb47a8d9fd68bd7d15f2a0c2df14ff4d2d5207 Mon Sep 17 00:00:00 2001 From: Paul Zuehlcke Date: Thu, 15 Aug 2019 14:32:48 +0000 Subject: [PATCH] Bug 1531303 - Refactored tests using PermissionManager URI methods to use PermissionTestUtils. r=johannh Differential Revision: https://phabricator.services.mozilla.com/D41029 --HG-- extra : moz-landing-system : lando --- .../test/alerts/browser_notification_close.js | 6 +- .../browser_notification_remove_permission.js | 8 +- .../browser_notification_tab_switching.js | 6 +- .../content/test/general/browser_bug578534.js | 9 +- .../general/browser_remoteTroubleshoot.js | 7 +- .../pageinfo/browser_pageinfo_permissions.js | 11 +- .../browser_permissions_event_telemetry.js | 29 ++--- .../browser_permissions_postPrompt.js | 4 +- browser/base/content/test/permissions/head.js | 3 + .../browser_popup_blocker_identity_block.js | 5 +- .../browser_cookiePermission_aboutURL.js | 4 +- .../browser_cookiePermission_subDomains.js | 16 ++- .../browser_sanitize-sitepermissions.js | 9 +- browser/base/content/test/sanitize/head.js | 5 +- .../browser_openPromptInBackgroundTab.js | 9 +- .../browser_trackingUI_trackers_subview.js | 12 +- .../browser_permissions_unsigned.js | 4 +- .../base/content/test/webextensions/head.js | 8 +- .../webrtc/browser_devices_get_user_media.js | 84 +++++++----- ...browser_devices_get_user_media_in_frame.js | 17 ++- browser/base/content/test/webrtc/head.js | 3 + .../enterprisepolicies/tests/xpcshell/head.js | 3 + .../tests/xpcshell/test_permissions.js | 68 +++++----- .../test_popups_cookies_addons_flash.js | 36 +++--- .../test/browser/browser_permissions.js | 8 +- .../tests/browser_cookies_exceptions.js | 16 ++- .../preferences/in-content/tests/head.js | 3 + .../test/browser_translation_exceptions.js | 28 +++- .../components/uitour/test/browser_no_tabs.js | 3 +- browser/components/uitour/test/head.js | 24 +++- .../modules/test/unit/test_SiteDataManager.js | 19 +-- .../test/unit/test_idle_maintenance.js | 6 +- .../test/unit/test_storageOption_pref.js | 11 +- .../browser/browser_permission_dismiss.js | 14 +- dom/push/test/xpcshell/head.js | 3 + dom/push/test/xpcshell/test_drop_expired.js | 6 +- dom/push/test/xpcshell/test_quota_observer.js | 4 +- dom/push/test/xpcshell/test_record.js | 4 +- .../test/browser_storage_permission.js | 28 ++-- netwerk/cookie/test/browser/head.js | 10 +- netwerk/test/unit/test_bug767025.js | 5 +- netwerk/test/unit/test_pinned_app_cache.js | 5 +- ...ListSeparationInPrivateAndNormalWindows.js | 6 +- .../browser_allowPermissionForTracker.js | 8 +- .../browser_denyPermissionForTracker.js | 8 +- .../browser_permissionInNormalWindows.js | 6 +- .../browser_permissionInPrivateWindows.js | 6 +- .../browser_storageAccessDoorHanger.js | 120 +++--------------- .../test/browser/browser_userInteraction.js | 2 +- .../antitracking/test/browser/head.js | 4 + .../test/browser/storageAccessAPIHelpers.js | 17 ++- .../test/unit/test_storage_mozStorage.js | 14 +- .../browser/browser_HybridContentTelemetry.js | 52 ++++++-- .../tests/xpcshell/test_PermissionsUtils.js | 11 +- .../tests/xpcshell/test_web_channel.js | 7 +- .../test/xpcshell/test_permissions.js | 8 +- .../xpinstall/browser_amosigned_trigger.js | 9 +- .../browser_amosigned_trigger_iframe.js | 9 +- .../extensions/test/xpinstall/browser_auth.js | 9 +- .../test/xpinstall/browser_auth2.js | 9 +- .../test/xpinstall/browser_auth3.js | 9 +- .../test/xpinstall/browser_auth4.js | 9 +- .../test/xpinstall/browser_badhash.js | 9 +- .../test/xpinstall/browser_badhashtype.js | 9 +- .../test/xpinstall/browser_bug540558.js | 9 +- .../test/xpinstall/browser_bug645699.js | 9 +- .../test/xpinstall/browser_bug672485.js | 9 +- .../test/xpinstall/browser_containers.js | 9 +- .../test/xpinstall/browser_cookies.js | 9 +- .../test/xpinstall/browser_cookies2.js | 9 +- .../test/xpinstall/browser_cookies3.js | 9 +- .../test/xpinstall/browser_cookies4.js | 9 +- .../test/xpinstall/browser_corrupt.js | 9 +- .../test/xpinstall/browser_datauri.js | 2 +- .../xpinstall/browser_doorhanger_installs.js | 47 ++++--- .../test/xpinstall/browser_empty.js | 9 +- .../extensions/test/xpinstall/browser_hash.js | 9 +- .../test/xpinstall/browser_hash2.js | 9 +- .../test/xpinstall/browser_httphash.js | 9 +- .../test/xpinstall/browser_httphash2.js | 9 +- .../test/xpinstall/browser_httphash3.js | 9 +- .../test/xpinstall/browser_httphash4.js | 9 +- .../test/xpinstall/browser_httphash5.js | 9 +- .../test/xpinstall/browser_httphash6.js | 9 +- .../test/xpinstall/browser_installchrome.js | 9 +- .../test/xpinstall/browser_newwindow.js | 5 +- .../test/xpinstall/browser_offline.js | 9 +- .../test/xpinstall/browser_privatebrowsing.js | 9 +- .../test/xpinstall/browser_relative.js | 9 +- .../test/xpinstall/browser_signed_trigger.js | 9 +- .../test/xpinstall/browser_softwareupdate.js | 9 +- .../xpinstall/browser_trigger_redirect.js | 9 +- .../xpinstall/browser_unsigned_trigger.js | 9 +- .../browser_unsigned_trigger_iframe.js | 9 +- .../browser_unsigned_trigger_xorigin.js | 9 +- .../mozapps/extensions/test/xpinstall/head.js | 4 + 96 files changed, 730 insertions(+), 484 deletions(-) diff --git a/browser/base/content/test/alerts/browser_notification_close.js b/browser/base/content/test/alerts/browser_notification_close.js index 98be92ff8460..6391b05a3ed8 100644 --- a/browser/base/content/test/alerts/browser_notification_close.js +++ b/browser/base/content/test/alerts/browser_notification_close.js @@ -4,6 +4,10 @@ const { PlacesTestUtils } = ChromeUtils.import( "resource://testing-common/PlacesTestUtils.jsm" ); +const { PermissionTestUtils } = ChromeUtils.import( + "resource://testing-common/PermissionTestUtils.jsm" +); + let notificationURL = "http://example.org/browser/browser/base/content/test/alerts/file_dom_notifications.html"; let oldShowFavicons; @@ -97,7 +101,7 @@ add_task(async function test_notificationClose() { }); add_task(async function cleanup() { - Services.perms.remove(makeURI(notificationURL), "desktop-notification"); + PermissionTestUtils.remove(notificationURL, "desktop-notification"); if (typeof oldShowFavicons == "boolean") { Services.prefs.setBoolPref("alerts.showFavicons", oldShowFavicons); } diff --git a/browser/base/content/test/alerts/browser_notification_remove_permission.js b/browser/base/content/test/alerts/browser_notification_remove_permission.js index c04d8556b88f..679b72debfc7 100644 --- a/browser/base/content/test/alerts/browser_notification_remove_permission.js +++ b/browser/base/content/test/alerts/browser_notification_remove_permission.js @@ -1,5 +1,9 @@ "use strict"; +const { PermissionTestUtils } = ChromeUtils.import( + "resource://testing-common/PermissionTestUtils.jsm" +); + var tab; var notificationURL = "http://example.org/browser/browser/base/content/test/alerts/file_dom_notifications.html"; @@ -35,8 +39,8 @@ function onAlertShowing() { return; } ok( - Services.perms.testExactPermission( - makeURI(notificationURL), + PermissionTestUtils.testExactPermission( + notificationURL, "desktop-notification" ), "Permission should exist prior to removal" diff --git a/browser/base/content/test/alerts/browser_notification_tab_switching.js b/browser/base/content/test/alerts/browser_notification_tab_switching.js index 125da8ac9427..2680593a66d3 100644 --- a/browser/base/content/test/alerts/browser_notification_tab_switching.js +++ b/browser/base/content/test/alerts/browser_notification_tab_switching.js @@ -4,6 +4,10 @@ "use strict"; +const { PermissionTestUtils } = ChromeUtils.import( + "resource://testing-common/PermissionTestUtils.jsm" +); + var tab; var notification; var notificationURL = @@ -104,5 +108,5 @@ add_task(async function test_notificationPreventDefaultAndSwitchTabs() { }); add_task(async function cleanup() { - Services.perms.remove(makeURI(notificationURL), "desktop-notification"); + PermissionTestUtils.remove(notificationURL, "desktop-notification"); }); diff --git a/browser/base/content/test/general/browser_bug578534.js b/browser/base/content/test/general/browser_bug578534.js index 2ef2abb1436d..841dae908832 100644 --- a/browser/base/content/test/general/browser_bug578534.js +++ b/browser/base/content/test/general/browser_bug578534.js @@ -2,13 +2,16 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +const { PermissionTestUtils } = ChromeUtils.import( + "resource://testing-common/PermissionTestUtils.jsm" +); + add_task(async function test() { let uriString = "http://example.com/"; let cookieBehavior = "network.cookie.cookieBehavior"; - let uriObj = Services.io.newURI(uriString); await SpecialPowers.pushPrefEnv({ set: [[cookieBehavior, 2]] }); - Services.perms.add(uriObj, "cookie", Services.perms.ALLOW_ACTION); + PermissionTestUtils.add(uriString, "cookie", Services.perms.ALLOW_ACTION); await BrowserTestUtils.withNewTab( { gBrowser, url: uriString }, @@ -23,5 +26,5 @@ add_task(async function test() { } ); - Services.perms.add(uriObj, "cookie", Services.perms.UNKNOWN_ACTION); + PermissionTestUtils.add(uriString, "cookie", Services.perms.UNKNOWN_ACTION); }); diff --git a/browser/base/content/test/general/browser_remoteTroubleshoot.js b/browser/base/content/test/general/browser_remoteTroubleshoot.js index 4c3c88b49294..0beb3cd1302f 100644 --- a/browser/base/content/test/general/browser_remoteTroubleshoot.js +++ b/browser/base/content/test/general/browser_remoteTroubleshoot.js @@ -5,6 +5,9 @@ var { WebChannel } = ChromeUtils.import( "resource://gre/modules/WebChannel.jsm" ); +const { PermissionTestUtils } = ChromeUtils.import( + "resource://testing-common/PermissionTestUtils.jsm" +); const TEST_URL_TAIL = "example.com/browser/browser/base/content/test/general/test_remoteTroubleshoot.html"; @@ -54,13 +57,13 @@ add_task(async function() { ); // Add a permission manager entry for our URI. - Services.perms.add( + PermissionTestUtils.add( TEST_URI_GOOD, "remote-troubleshooting", Services.perms.ALLOW_ACTION ); registerCleanupFunction(() => { - Services.perms.remove(TEST_URI_GOOD, "remote-troubleshooting"); + PermissionTestUtils.remove(TEST_URI_GOOD, "remote-troubleshooting"); }); // Try again - now we are expecting a response with the actual data. diff --git a/browser/base/content/test/pageinfo/browser_pageinfo_permissions.js b/browser/base/content/test/pageinfo/browser_pageinfo_permissions.js index a659407cc0e4..7232debff404 100644 --- a/browser/base/content/test/pageinfo/browser_pageinfo_permissions.js +++ b/browser/base/content/test/pageinfo/browser_pageinfo_permissions.js @@ -1,6 +1,9 @@ const { SitePermissions } = ChromeUtils.import( "resource:///modules/SitePermissions.jsm" ); +const { PermissionTestUtils } = ChromeUtils.import( + "resource://testing-common/PermissionTestUtils.jsm" +); const TEST_ORIGIN = "https://example.com"; const TEST_ORIGIN_CERT_ERROR = "https://expired.example.com"; @@ -209,7 +212,7 @@ add_task(async function test_cookie_permission() { defaultCheckbox.dispatchEvent(new Event("command")); is( - Services.perms.testPermission(gBrowser.currentURI, "cookie"), + PermissionTestUtils.testPermission(gBrowser.currentURI, "cookie"), SitePermissions.ALLOW, "Unchecking the default checkbox should pick the default permission." ); @@ -223,7 +226,7 @@ add_task(async function test_cookie_permission() { blockRadioButton.dispatchEvent(new Event("command")); is( - Services.perms.testPermission(gBrowser.currentURI, "cookie"), + PermissionTestUtils.testPermission(gBrowser.currentURI, "cookie"), SitePermissions.BLOCK, "Selecting a value in the radio group should set the corresponding permission" ); @@ -232,7 +235,7 @@ add_task(async function test_cookie_permission() { allowRadioButton.dispatchEvent(new Event("command")); is( - Services.perms.testPermission(gBrowser.currentURI, "cookie"), + PermissionTestUtils.testPermission(gBrowser.currentURI, "cookie"), SitePermissions.ALLOW, "Selecting a value in the radio group should set the corresponding permission" ); @@ -242,7 +245,7 @@ add_task(async function test_cookie_permission() { defaultCheckbox.dispatchEvent(new Event("command")); is( - Services.perms.testPermission(gBrowser.currentURI, "cookie"), + PermissionTestUtils.testPermission(gBrowser.currentURI, "cookie"), SitePermissions.UNKNOWN, "Checking the default checkbox should reset the permission." ); diff --git a/browser/base/content/test/permissions/browser_permissions_event_telemetry.js b/browser/base/content/test/permissions/browser_permissions_event_telemetry.js index f8270b5eb4d5..44be1ff80423 100644 --- a/browser/base/content/test/permissions/browser_permissions_event_telemetry.js +++ b/browser/base/content/test/permissions/browser_permissions_event_telemetry.js @@ -105,11 +105,15 @@ add_task(async function setup() { let uri = Services.io.newURI(PERMISSIONS_PAGE); let uri2 = Services.io.newURI("https://example.org"); let uri3 = Services.io.newURI("http://sub.example.org"); - Services.perms.add(uri, "geo", Services.perms.ALLOW_ACTION); - Services.perms.add(uri3, "desktop-notification", Services.perms.ALLOW_ACTION); - Services.perms.add(uri2, "microphone", Services.perms.DENY_ACTION); - Services.perms.add(uri, "camera", Services.perms.DENY_ACTION); - Services.perms.add(uri2, "geo", Services.perms.DENY_ACTION); + PermissionTestUtils.add(uri, "geo", Services.perms.ALLOW_ACTION); + PermissionTestUtils.add( + uri3, + "desktop-notification", + Services.perms.ALLOW_ACTION + ); + PermissionTestUtils.add(uri2, "microphone", Services.perms.DENY_ACTION); + PermissionTestUtils.add(uri, "camera", Services.perms.DENY_ACTION); + PermissionTestUtils.add(uri2, "geo", Services.perms.DENY_ACTION); registerCleanupFunction(() => { Services.perms.removeAll(); @@ -132,10 +136,7 @@ add_task(async function testAccept() { checkEventTelemetry("accept"); Services.telemetry.clearEvents(); - Services.perms.remove( - Services.io.newURI(PERMISSIONS_PAGE), - "desktop-notification" - ); + PermissionTestUtils.remove(PERMISSIONS_PAGE, "desktop-notification"); }); }); @@ -151,10 +152,7 @@ add_task(async function testDeny() { checkEventTelemetry("deny"); Services.telemetry.clearEvents(); - Services.perms.remove( - Services.io.newURI(PERMISSIONS_PAGE), - "desktop-notification" - ); + PermissionTestUtils.remove(PERMISSIONS_PAGE, "desktop-notification"); }); }); @@ -174,8 +172,5 @@ add_task(async function testLeave() { checkEventTelemetry("leave"); Services.telemetry.clearEvents(); - Services.perms.remove( - Services.io.newURI(PERMISSIONS_PAGE), - "desktop-notification" - ); + PermissionTestUtils.remove(PERMISSIONS_PAGE, "desktop-notification"); }); diff --git a/browser/base/content/test/permissions/browser_permissions_postPrompt.js b/browser/base/content/test/permissions/browser_permissions_postPrompt.js index a380ee6c07c2..bec57baabafa 100644 --- a/browser/base/content/test/permissions/browser_permissions_postPrompt.js +++ b/browser/base/content/test/permissions/browser_permissions_postPrompt.js @@ -41,12 +41,12 @@ function testPostPrompt(task) { EventUtils.synthesizeMouseAtCenter(notification.button, {}); is( - Services.perms.testPermission(uri, "desktop-notification"), + PermissionTestUtils.testPermission(uri, "desktop-notification"), Ci.nsIPermissionManager.ALLOW_ACTION, "User can override the default deny by using the prompt" ); - Services.perms.remove(uri, "desktop-notification"); + PermissionTestUtils.remove(uri, "desktop-notification"); }); } diff --git a/browser/base/content/test/permissions/head.js b/browser/base/content/test/permissions/head.js index 600045c48259..3143a824d42b 100644 --- a/browser/base/content/test/permissions/head.js +++ b/browser/base/content/test/permissions/head.js @@ -1 +1,4 @@ ChromeUtils.import("resource:///modules/SitePermissions.jsm", this); +const { PermissionTestUtils } = ChromeUtils.import( + "resource://testing-common/PermissionTestUtils.jsm" +); diff --git a/browser/base/content/test/popups/browser_popup_blocker_identity_block.js b/browser/base/content/test/popups/browser_popup_blocker_identity_block.js index c1aab2fb369b..e02278dbe8b8 100644 --- a/browser/base/content/test/popups/browser_popup_blocker_identity_block.js +++ b/browser/base/content/test/popups/browser_popup_blocker_identity_block.js @@ -7,6 +7,9 @@ const { SitePermissions } = ChromeUtils.import( "resource:///modules/SitePermissions.jsm" ); +const { PermissionTestUtils } = ChromeUtils.import( + "resource://testing-common/PermissionTestUtils.jsm" +); const baseURL = getRootDirectory(gTestPath).replace( "chrome://mochitests/content", @@ -209,7 +212,7 @@ add_task(async function check_explicit_default_permission() { // DENY only works if triggered through Services.perms (it's very edge-casey), // since SitePermissions.jsm considers setting default permissions to be removal. - Services.perms.add(URI, "popup", Ci.nsIPermissionManager.DENY_ACTION); + PermissionTestUtils.add(URI, "popup", Ci.nsIPermissionManager.DENY_ACTION); await openIdentityPopup(); let menulist = document.getElementById("identity-popup-popup-menulist"); diff --git a/browser/base/content/test/sanitize/browser_cookiePermission_aboutURL.js b/browser/base/content/test/sanitize/browser_cookiePermission_aboutURL.js index 2c951a4aa95f..cd971c6b23ef 100644 --- a/browser/base/content/test/sanitize/browser_cookiePermission_aboutURL.js +++ b/browser/base/content/test/sanitize/browser_cookiePermission_aboutURL.js @@ -77,7 +77,7 @@ add_task(async function deleteStorageOnlyCustomPermissionInAboutURL() { // Custom permission without considering OriginAttributes let uri = Services.io.newURI("about:newtab"); - Services.perms.add(uri, "cookie", Ci.nsICookiePermission.ACCESS_SESSION); + PermissionTestUtils.add(uri, "cookie", Ci.nsICookiePermission.ACCESS_SESSION); // Let's create a tab with some data. await SiteDataTestUtils.addToIndexedDB("about:newtab", "foo", "bar", {}); @@ -102,5 +102,5 @@ add_task(async function deleteStorageOnlyCustomPermissionInAboutURL() { }; }); - Services.perms.remove(uri, "cookie"); + PermissionTestUtils.remove(uri, "cookie"); }); diff --git a/browser/base/content/test/sanitize/browser_cookiePermission_subDomains.js b/browser/base/content/test/sanitize/browser_cookiePermission_subDomains.js index 5128ea968e29..3b9b925bf8b8 100644 --- a/browser/base/content/test/sanitize/browser_cookiePermission_subDomains.js +++ b/browser/base/content/test/sanitize/browser_cookiePermission_subDomains.js @@ -22,7 +22,11 @@ add_task(async function subDomains() { // Domains and data let uriA = Services.io.newURI("https://www.mozilla.org"); - Services.perms.add(uriA, "cookie", Ci.nsICookiePermission.ACCESS_SESSION); + PermissionTestUtils.add( + uriA, + "cookie", + Ci.nsICookiePermission.ACCESS_SESSION + ); Services.cookies.add( uriA.host, @@ -40,7 +44,7 @@ add_task(async function subDomains() { await createIndexedDB(uriA.host, {}); let uriB = Services.io.newURI("https://mozilla.org"); - Services.perms.add(uriB, "cookie", Ci.nsICookiePermission.ACCESS_ALLOW); + PermissionTestUtils.add(uriB, "cookie", Ci.nsICookiePermission.ACCESS_ALLOW); Services.cookies.add( uriB.host, @@ -85,8 +89,8 @@ add_task(async function subDomains() { ); // Cleaning up permissions - Services.perms.remove(uriA, "cookie"); - Services.perms.remove(uriB, "cookie"); + PermissionTestUtils.remove(uriA, "cookie"); + PermissionTestUtils.remove(uriB, "cookie"); }); // session only cookie life-time, 2 domains (mozilla.org, www.mozilla.org), @@ -108,7 +112,7 @@ add_task(async function subDomains() { // Domains and data let uriA = Services.io.newURI("https://sub.mozilla.org"); - Services.perms.add(uriA, "cookie", Ci.nsICookiePermission.ACCESS_ALLOW); + PermissionTestUtils.add(uriA, "cookie", Ci.nsICookiePermission.ACCESS_ALLOW); Services.cookies.add( uriA.host, @@ -170,5 +174,5 @@ add_task(async function subDomains() { ); // Cleaning up permissions - Services.perms.remove(uriA, "cookie"); + PermissionTestUtils.remove(uriA, "cookie"); }); diff --git a/browser/base/content/test/sanitize/browser_sanitize-sitepermissions.js b/browser/base/content/test/sanitize/browser_sanitize-sitepermissions.js index ff44a4422ad1..79807d16831b 100644 --- a/browser/base/content/test/sanitize/browser_sanitize-sitepermissions.js +++ b/browser/base/content/test/sanitize/browser_sanitize-sitepermissions.js @@ -19,12 +19,15 @@ add_task(async function test() { let numAtStart = countPermissions(); // Add a permission entry - var pm = Services.perms; - pm.add(Services.io.newURI("http://example.com"), "testing", pm.ALLOW_ACTION); + PermissionTestUtils.add( + "http://example.com", + "testing", + Services.perms.ALLOW_ACTION + ); // Sanity check ok( - pm.enumerator.hasMoreElements(), + Services.perms.enumerator.hasMoreElements(), "Permission manager should have elements, since we just added one" ); diff --git a/browser/base/content/test/sanitize/head.js b/browser/base/content/test/sanitize/head.js index de273a338d8d..ee97bcbb195b 100644 --- a/browser/base/content/test/sanitize/head.js +++ b/browser/base/content/test/sanitize/head.js @@ -8,6 +8,7 @@ XPCOMUtils.defineLazyModuleGetters(this, { PlacesUtils: "resource://gre/modules/PlacesUtils.jsm", Sanitizer: "resource:///modules/Sanitizer.jsm", SiteDataTestUtils: "resource://testing-common/SiteDataTestUtils.jsm", + PermissionTestUtils: "resource://testing-common/PermissionTestUtils.jsm", }); function createIndexedDB(host, originAttributes) { @@ -98,7 +99,7 @@ async function deleteOnShutdown(opt) { // Custom permission without considering OriginAttributes if (opt.cookiePermission !== undefined) { let uri = Services.io.newURI("https://www.example.com"); - Services.perms.add(uri, "cookie", opt.cookiePermission); + PermissionTestUtils.add(uri, "cookie", opt.cookiePermission); } // Let's create a tab with some data. @@ -151,7 +152,7 @@ async function deleteOnShutdown(opt) { if (opt.cookiePermission !== undefined) { let uri = Services.io.newURI("https://www.example.com"); - Services.perms.remove(uri, "cookie"); + PermissionTestUtils.remove(uri, "cookie"); } } diff --git a/browser/base/content/test/tabPrompts/browser_openPromptInBackgroundTab.js b/browser/base/content/test/tabPrompts/browser_openPromptInBackgroundTab.js index cd89d3f1736b..bbb493e79dc5 100644 --- a/browser/base/content/test/tabPrompts/browser_openPromptInBackgroundTab.js +++ b/browser/base/content/test/tabPrompts/browser_openPromptInBackgroundTab.js @@ -1,5 +1,9 @@ "use strict"; +const { PermissionTestUtils } = ChromeUtils.import( + "resource://testing-common/PermissionTestUtils.jsm" +); + const ROOT = getRootDirectory(gTestPath).replace( "chrome://mochitests/content/", "http://example.com/" @@ -66,10 +70,9 @@ add_task(async function() { Services.tm.dispatchToMainThread(resolve); }); // check permission is set - let ps = Services.perms; is( - ps.ALLOW_ACTION, - ps.testPermission(makeURI(pageWithAlert), "focus-tab-by-prompt"), + Services.perms.ALLOW_ACTION, + PermissionTestUtils.testPermission(pageWithAlert, "focus-tab-by-prompt"), "Tab switching should now be allowed" ); diff --git a/browser/base/content/test/trackingUI/browser_trackingUI_trackers_subview.js b/browser/base/content/test/trackingUI/browser_trackingUI_trackers_subview.js index b5169c0ea734..8d3861d20437 100644 --- a/browser/base/content/test/trackingUI/browser_trackingUI_trackers_subview.js +++ b/browser/base/content/test/trackingUI/browser_trackingUI_trackers_subview.js @@ -4,6 +4,10 @@ "use strict"; +const { PermissionTestUtils } = ChromeUtils.import( + "resource://testing-common/PermissionTestUtils.jsm" +); + const TRACKING_PAGE = "http://tracking.example.org/browser/browser/base/content/test/trackingUI/trackingPage.html"; @@ -113,10 +117,14 @@ add_task(async function testTrackersSubView() { await assertSitesListed(true); info("Testing trackers subview with TP enabled and a CB exception."); let uri = Services.io.newURI("https://tracking.example.org"); - Services.perms.add(uri, "trackingprotection", Services.perms.ALLOW_ACTION); + PermissionTestUtils.add( + uri, + "trackingprotection", + Services.perms.ALLOW_ACTION + ); await assertSitesListed(false); info("Testing trackers subview with TP enabled and a CB exception removed."); - Services.perms.remove(uri, "trackingprotection"); + PermissionTestUtils.remove(uri, "trackingprotection"); await assertSitesListed(true); Services.prefs.clearUserPref(TP_PREF); diff --git a/browser/base/content/test/webextensions/browser_permissions_unsigned.js b/browser/base/content/test/webextensions/browser_permissions_unsigned.js index 138c202ceb48..c401fb8fd45c 100644 --- a/browser/base/content/test/webextensions/browser_permissions_unsigned.js +++ b/browser/base/content/test/webextensions/browser_permissions_unsigned.js @@ -12,8 +12,8 @@ add_task(async function test_unsigned() { }); let testURI = makeURI("https://example.com/"); - Services.perms.add(testURI, "install", Services.perms.ALLOW_ACTION); - registerCleanupFunction(() => Services.perms.remove(testURI, "install")); + PermissionTestUtils.add(testURI, "install", Services.perms.ALLOW_ACTION); + registerCleanupFunction(() => PermissionTestUtils.remove(testURI, "install")); let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser); diff --git a/browser/base/content/test/webextensions/head.js b/browser/base/content/test/webextensions/head.js index 45cb64f0a92b..000da75fa966 100644 --- a/browser/base/content/test/webextensions/head.js +++ b/browser/base/content/test/webextensions/head.js @@ -27,6 +27,10 @@ ChromeUtils.import( ); let gCUITestUtils = new CustomizableUITestUtils(window); +const { PermissionTestUtils } = ChromeUtils.import( + "resource://testing-common/PermissionTestUtils.jsm" +); + /** * Wait for the given PopupNotification to display * @@ -309,8 +313,8 @@ async function testInstallMethod(installFn, telemetryBase) { } let testURI = makeURI("https://example.com/"); - Services.perms.add(testURI, "install", Services.perms.ALLOW_ACTION); - registerCleanupFunction(() => Services.perms.remove(testURI, "install")); + PermissionTestUtils.add(testURI, "install", Services.perms.ALLOW_ACTION); + registerCleanupFunction(() => PermissionTestUtils.remove(testURI, "install")); async function runOnce(filename, cancel) { let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser); diff --git a/browser/base/content/test/webrtc/browser_devices_get_user_media.js b/browser/base/content/test/webrtc/browser_devices_get_user_media.js index edfebc95801d..c11309a3e446 100644 --- a/browser/base/content/test/webrtc/browser_devices_get_user_media.js +++ b/browser/base/content/test/webrtc/browser_devices_get_user_media.js @@ -328,23 +328,27 @@ var gTests = [ ); function checkDevicePermissions(aDevice, aExpected) { - let Perms = Services.perms; let uri = gBrowser.selectedBrowser.documentURI; - let devicePerms = Perms.testExactPermission(uri, aDevice); + let devicePerms = PermissionTestUtils.testExactPermission( + uri, + aDevice + ); if (aExpected === undefined) { is( devicePerms, - Perms.UNKNOWN_ACTION, + Services.perms.UNKNOWN_ACTION, "no " + aDevice + " persistent permissions" ); } else { is( devicePerms, - aExpected ? Perms.ALLOW_ACTION : Perms.DENY_ACTION, + aExpected + ? Services.perms.ALLOW_ACTION + : Services.perms.DENY_ACTION, aDevice + " persistently " + (aExpected ? "allowed" : "denied") ); } - Perms.remove(uri, aDevice); + PermissionTestUtils.remove(uri, aDevice); } checkDevicePermissions("microphone", aExpectedAudioPerm); checkDevicePermissions("camera", aExpectedVideoPerm); @@ -355,7 +359,7 @@ var gTests = [ } // 3 cases where the user accepts the device prompt. - info("audio+video, user grants, expect both perms set to allow"); + info("audio+video, user grants, expect both Services.perms set to allow"); await checkPerm(true, true, true, true); info( "audio only, user grants, check audio perm set to allow, video perm not set" @@ -375,7 +379,7 @@ var gTests = [ "video only, user denies, expect video perm set to deny, audio perm not set" ); await checkPerm(false, true, undefined, false, true); - info("audio+video, user denies, expect both perms set to deny"); + info("audio+video, user denies, expect both Services.perms set to deny"); await checkPerm(true, true, false, false, true); }, }, @@ -390,21 +394,24 @@ var gTests = [ aRequestVideo, aExpectStream ) { - let Perms = Services.perms; let uri = gBrowser.selectedBrowser.documentURI; if (aAllowAudio !== undefined) { - Perms.add( + PermissionTestUtils.add( uri, "microphone", - aAllowAudio ? Perms.ALLOW_ACTION : Perms.DENY_ACTION + aAllowAudio + ? Services.perms.ALLOW_ACTION + : Services.perms.DENY_ACTION ); } if (aAllowVideo !== undefined) { - Perms.add( + PermissionTestUtils.add( uri, "camera", - aAllowVideo ? Perms.ALLOW_ACTION : Perms.DENY_ACTION + aAllowVideo + ? Services.perms.ALLOW_ACTION + : Services.perms.DENY_ACTION ); } @@ -458,8 +465,8 @@ var gTests = [ } } - Perms.remove(uri, "camera"); - Perms.remove(uri, "microphone"); + PermissionTestUtils.remove(uri, "camera"); + PermissionTestUtils.remove(uri, "microphone"); } // Set both permissions identically @@ -522,12 +529,11 @@ var gTests = [ desc: "Stop Sharing removes persistent permissions", run: async function checkStopSharingRemovesPersistentPermissions() { async function stopAndCheckPerm(aRequestAudio, aRequestVideo) { - let Perms = Services.perms; let uri = gBrowser.selectedBrowser.documentURI; // Initially set both permissions to 'allow'. - Perms.add(uri, "microphone", Perms.ALLOW_ACTION); - Perms.add(uri, "camera", Perms.ALLOW_ACTION); + PermissionTestUtils.add(uri, "microphone", Services.perms.ALLOW_ACTION); + PermissionTestUtils.add(uri, "camera", Services.perms.ALLOW_ACTION); let indicator = promiseIndicatorWindow(); // Start sharing what's been requested. @@ -544,25 +550,44 @@ var gTests = [ await stopSharing(aRequestVideo ? "camera" : "microphone"); // Check that permissions have been removed as expected. - let audioPerm = Perms.testExactPermission(uri, "microphone"); + let audioPerm = PermissionTestUtils.testExactPermission( + uri, + "microphone" + ); if (aRequestAudio) { - is(audioPerm, Perms.UNKNOWN_ACTION, "microphone permissions removed"); + is( + audioPerm, + Services.perms.UNKNOWN_ACTION, + "microphone permissions removed" + ); } else { - is(audioPerm, Perms.ALLOW_ACTION, "microphone permissions untouched"); + is( + audioPerm, + Services.perms.ALLOW_ACTION, + "microphone permissions untouched" + ); } - let videoPerm = Perms.testExactPermission(uri, "camera"); + let videoPerm = PermissionTestUtils.testExactPermission(uri, "camera"); if (aRequestVideo) { - is(videoPerm, Perms.UNKNOWN_ACTION, "camera permissions removed"); + is( + videoPerm, + Services.perms.UNKNOWN_ACTION, + "camera permissions removed" + ); } else { - is(videoPerm, Perms.ALLOW_ACTION, "camera permissions untouched"); + is( + videoPerm, + Services.perms.ALLOW_ACTION, + "camera permissions untouched" + ); } // Cleanup. await closeStream(true); - Perms.remove(uri, "camera"); - Perms.remove(uri, "microphone"); + PermissionTestUtils.remove(uri, "camera"); + PermissionTestUtils.remove(uri, "microphone"); } info("request audio+video, stop sharing resets both"); @@ -645,10 +670,9 @@ var gTests = [ await BrowserTestUtils.browserLoaded(browser); // Initially set both permissions to 'allow'. - let Perms = Services.perms; let uri = browser.documentURI; - Perms.add(uri, "microphone", Perms.ALLOW_ACTION); - Perms.add(uri, "camera", Perms.ALLOW_ACTION); + PermissionTestUtils.add(uri, "microphone", Services.perms.ALLOW_ACTION); + PermissionTestUtils.add(uri, "camera", Services.perms.ALLOW_ACTION); // Request devices and expect a prompt despite the saved 'Allow' permission, // because the connection isn't secure. @@ -673,8 +697,8 @@ var gTests = [ // Cleanup. await closeStream(true); - Perms.remove(uri, "camera"); - Perms.remove(uri, "microphone"); + PermissionTestUtils.remove(uri, "camera"); + PermissionTestUtils.remove(uri, "microphone"); }, }, ]; diff --git a/browser/base/content/test/webrtc/browser_devices_get_user_media_in_frame.js b/browser/base/content/test/webrtc/browser_devices_get_user_media_in_frame.js index 63470653837b..777d437cbb1a 100644 --- a/browser/base/content/test/webrtc/browser_devices_get_user_media_in_frame.js +++ b/browser/base/content/test/webrtc/browser_devices_get_user_media_in_frame.js @@ -65,16 +65,15 @@ var gTests = [ await indicator; await checkSharingUI({ video: true, audio: true }); - let Perms = Services.perms; let uri = Services.io.newURI("https://example.com/"); is( - Perms.testExactPermission(uri, "microphone"), - Perms.ALLOW_ACTION, + PermissionTestUtils.testExactPermission(uri, "microphone"), + Services.perms.ALLOW_ACTION, "microphone persistently allowed" ); is( - Perms.testExactPermission(uri, "camera"), - Perms.ALLOW_ACTION, + PermissionTestUtils.testExactPermission(uri, "camera"), + Services.perms.ALLOW_ACTION, "camera persistently allowed" ); @@ -82,13 +81,13 @@ var gTests = [ // The persistent permissions for the frame should have been removed. is( - Perms.testExactPermission(uri, "microphone"), - Perms.UNKNOWN_ACTION, + PermissionTestUtils.testExactPermission(uri, "microphone"), + Services.perms.UNKNOWN_ACTION, "microphone not persistently allowed" ); is( - Perms.testExactPermission(uri, "camera"), - Perms.UNKNOWN_ACTION, + PermissionTestUtils.testExactPermission(uri, "camera"), + Services.perms.UNKNOWN_ACTION, "camera not persistently allowed" ); diff --git a/browser/base/content/test/webrtc/head.js b/browser/base/content/test/webrtc/head.js index 0caa4a65d43d..16ba963f62f0 100644 --- a/browser/base/content/test/webrtc/head.js +++ b/browser/base/content/test/webrtc/head.js @@ -4,6 +4,9 @@ var { XPCOMUtils } = ChromeUtils.import( var { SitePermissions } = ChromeUtils.import( "resource:///modules/SitePermissions.jsm" ); +var { PermissionTestUtils } = ChromeUtils.import( + "resource://testing-common/PermissionTestUtils.jsm" +); const PREF_PERMISSION_FAKE = "media.navigator.permission.fake"; const PREF_AUDIO_LOOPBACK = "media.audio_loopback_dev"; diff --git a/browser/components/enterprisepolicies/tests/xpcshell/head.js b/browser/components/enterprisepolicies/tests/xpcshell/head.js index 0822525aa57d..536975192914 100644 --- a/browser/components/enterprisepolicies/tests/xpcshell/head.js +++ b/browser/components/enterprisepolicies/tests/xpcshell/head.js @@ -15,6 +15,9 @@ const { updateAppInfo, getAppInfo } = ChromeUtils.import( const { FileTestUtils } = ChromeUtils.import( "resource://testing-common/FileTestUtils.jsm" ); +const { PermissionTestUtils } = ChromeUtils.import( + "resource://testing-common/PermissionTestUtils.jsm" +); updateAppInfo({ name: "XPCShell", diff --git a/browser/components/enterprisepolicies/tests/xpcshell/test_permissions.js b/browser/components/enterprisepolicies/tests/xpcshell/test_permissions.js index 17f8f496ca0e..a96e2cc5e715 100644 --- a/browser/components/enterprisepolicies/tests/xpcshell/test_permissions.js +++ b/browser/components/enterprisepolicies/tests/xpcshell/test_permissions.js @@ -14,26 +14,26 @@ add_task(async function test_setup_preexisting_permissions() { // No ALLOW -> DENY override for popup and install permissions, // because their policies only supports the Allow parameter. - Services.perms.add( - URI("https://www.pre-existing-allow.com"), + PermissionTestUtils.add( + "https://www.pre-existing-allow.com", "camera", Ci.nsIPermissionManager.ALLOW_ACTION, Ci.nsIPermissionManager.EXPIRE_SESSION ); - Services.perms.add( - URI("https://www.pre-existing-allow.com"), + PermissionTestUtils.add( + "https://www.pre-existing-allow.com", "microphone", Ci.nsIPermissionManager.ALLOW_ACTION, Ci.nsIPermissionManager.EXPIRE_SESSION ); - Services.perms.add( - URI("https://www.pre-existing-allow.com"), + PermissionTestUtils.add( + "https://www.pre-existing-allow.com", "geo", Ci.nsIPermissionManager.ALLOW_ACTION, Ci.nsIPermissionManager.EXPIRE_SESSION ); - Services.perms.add( - URI("https://www.pre-existing-allow.com"), + PermissionTestUtils.add( + "https://www.pre-existing-allow.com", "desktop-notification", Ci.nsIPermissionManager.ALLOW_ACTION, Ci.nsIPermissionManager.EXPIRE_SESSION @@ -42,26 +42,26 @@ add_task(async function test_setup_preexisting_permissions() { // Pre-existing DENY permissions that should be overriden // with ALLOW. - Services.perms.add( - URI("https://www.pre-existing-deny.com"), + PermissionTestUtils.add( + "https://www.pre-existing-deny.com", "camera", Ci.nsIPermissionManager.DENY_ACTION, Ci.nsIPermissionManager.EXPIRE_SESSION ); - Services.perms.add( - URI("https://www.pre-existing-deny.com"), + PermissionTestUtils.add( + "https://www.pre-existing-deny.com", "microphone", Ci.nsIPermissionManager.DENY_ACTION, Ci.nsIPermissionManager.EXPIRE_SESSION ); - Services.perms.add( - URI("https://www.pre-existing-deny.com"), + PermissionTestUtils.add( + "https://www.pre-existing-deny.com", "geo", Ci.nsIPermissionManager.DENY_ACTION, Ci.nsIPermissionManager.EXPIRE_SESSION ); - Services.perms.add( - URI("https://www.pre-existing-deny.com"), + PermissionTestUtils.add( + "https://www.pre-existing-deny.com", "desktop-notification", Ci.nsIPermissionManager.DENY_ACTION, Ci.nsIPermissionManager.EXPIRE_SESSION @@ -103,13 +103,13 @@ function checkPermission(url, expected, permissionName) { let uri = Services.io.newURI(`https://www.${url}`); equal( - Services.perms.testPermission(uri, permissionName), + PermissionTestUtils.testPermission(uri, permissionName), expectedValue, `Correct (${permissionName}=${expected}) for URL ${url}` ); if (expected != "UNKNOWN") { - let permission = Services.perms.getPermissionObjectForURI( + let permission = PermissionTestUtils.getPermissionObject( uri, permissionName, true @@ -153,26 +153,26 @@ add_task(async function test_notifications_policy() { add_task(async function test_change_permission() { // Checks that changing a permission will still retain the // value set through the engine. - Services.perms.add( - URI("https://www.allow.com"), + PermissionTestUtils.add( + "https://www.allow.com", "camera", Ci.nsIPermissionManager.DENY_ACTION, Ci.nsIPermissionManager.EXPIRE_SESSION ); - Services.perms.add( - URI("https://www.allow.com"), + PermissionTestUtils.add( + "https://www.allow.com", "microphone", Ci.nsIPermissionManager.DENY_ACTION, Ci.nsIPermissionManager.EXPIRE_SESSION ); - Services.perms.add( - URI("https://www.allow.com"), + PermissionTestUtils.add( + "https://www.allow.com", "geo", Ci.nsIPermissionManager.DENY_ACTION, Ci.nsIPermissionManager.EXPIRE_SESSION ); - Services.perms.add( - URI("https://www.allow.com"), + PermissionTestUtils.add( + "https://www.allow.com", "desktop-notification", Ci.nsIPermissionManager.DENY_ACTION, Ci.nsIPermissionManager.EXPIRE_SESSION @@ -185,26 +185,26 @@ add_task(async function test_change_permission() { // Also change one un-managed permission to make sure it doesn't // cause any problems to the policy engine or the permission manager. - Services.perms.add( - URI("https://www.unmanaged.com"), + PermissionTestUtils.add( + "https://www.unmanaged.com", "camera", Ci.nsIPermissionManager.DENY_ACTION, Ci.nsIPermissionManager.EXPIRE_SESSION ); - Services.perms.add( - URI("https://www.unmanaged.com"), + PermissionTestUtils.add( + "https://www.unmanaged.com", "microphone", Ci.nsIPermissionManager.DENY_ACTION, Ci.nsIPermissionManager.EXPIRE_SESSION ); - Services.perms.add( - URI("https://www.unmanaged.com"), + PermissionTestUtils.add( + "https://www.unmanaged.com", "geo", Ci.nsIPermissionManager.DENY_ACTION, Ci.nsIPermissionManager.EXPIRE_SESSION ); - Services.perms.add( - URI("https://www.unmanaged.com"), + PermissionTestUtils.add( + "https://www.unmanaged.com", "desktop-notification", Ci.nsIPermissionManager.DENY_ACTION, Ci.nsIPermissionManager.EXPIRE_SESSION diff --git a/browser/components/enterprisepolicies/tests/xpcshell/test_popups_cookies_addons_flash.js b/browser/components/enterprisepolicies/tests/xpcshell/test_popups_cookies_addons_flash.js index 74ab479d59b9..b1d4ef42b872 100644 --- a/browser/components/enterprisepolicies/tests/xpcshell/test_popups_cookies_addons_flash.js +++ b/browser/components/enterprisepolicies/tests/xpcshell/test_popups_cookies_addons_flash.js @@ -14,15 +14,15 @@ add_task(async function test_setup_preexisting_permissions() { // No ALLOW -> DENY override for popup and install permissions, // because their policies only supports the Allow parameter. - Services.perms.add( - URI("https://www.pre-existing-allow.com"), + PermissionTestUtils.add( + "https://www.pre-existing-allow.com", "cookie", Ci.nsIPermissionManager.ALLOW_ACTION, Ci.nsIPermissionManager.EXPIRE_SESSION ); - Services.perms.add( - URI("https://www.pre-existing-allow.com"), + PermissionTestUtils.add( + "https://www.pre-existing-allow.com", "plugin:flash", Ci.nsIPermissionManager.ALLOW_ACTION, Ci.nsIPermissionManager.EXPIRE_SESSION @@ -30,29 +30,29 @@ add_task(async function test_setup_preexisting_permissions() { // Pre-existing DENY permissions that should be overriden // with ALLOW. - Services.perms.add( - URI("https://www.pre-existing-deny.com"), + PermissionTestUtils.add( + "https://www.pre-existing-deny.com", "popup", Ci.nsIPermissionManager.DENY_ACTION, Ci.nsIPermissionManager.EXPIRE_SESSION ); - Services.perms.add( - URI("https://www.pre-existing-deny.com"), + PermissionTestUtils.add( + "https://www.pre-existing-deny.com", "install", Ci.nsIPermissionManager.DENY_ACTION, Ci.nsIPermissionManager.EXPIRE_SESSION ); - Services.perms.add( - URI("https://www.pre-existing-deny.com"), + PermissionTestUtils.add( + "https://www.pre-existing-deny.com", "cookie", Ci.nsIPermissionManager.DENY_ACTION, Ci.nsIPermissionManager.EXPIRE_SESSION ); - Services.perms.add( - URI("https://www.pre-existing-deny.com"), + PermissionTestUtils.add( + "https://www.pre-existing-deny.com", "plugin:flash", Ci.nsIPermissionManager.DENY_ACTION, Ci.nsIPermissionManager.EXPIRE_SESSION @@ -73,13 +73,13 @@ function checkPermission(url, expected, permissionName) { let uri = Services.io.newURI(`https://www.${url}`); equal( - Services.perms.testPermission(uri, permissionName), + PermissionTestUtils.testPermission(uri, permissionName), expectedValue, `Correct (${permissionName}=${expected}) for URL ${url}` ); if (expected != "UNKNOWN") { - let permission = Services.perms.getPermissionObjectForURI( + let permission = PermissionTestUtils.getPermissionObject( uri, permissionName, true @@ -123,8 +123,8 @@ add_task(async function test_flash_policy() { add_task(async function test_change_permission() { // Checks that changing a permission will still retain the // value set through the engine. - Services.perms.add( - URI("https://www.allow.com"), + PermissionTestUtils.add( + "https://www.allow.com", "cookie", Ci.nsIPermissionManager.DENY_ACTION, Ci.nsIPermissionManager.EXPIRE_SESSION @@ -134,8 +134,8 @@ add_task(async function test_change_permission() { // Also change one un-managed permission to make sure it doesn't // cause any problems to the policy engine or the permission manager. - Services.perms.add( - URI("https://www.unmanaged.com"), + PermissionTestUtils.add( + "https://www.unmanaged.com", "cookie", Ci.nsIPermissionManager.DENY_ACTION, Ci.nsIPermissionManager.EXPIRE_SESSION diff --git a/browser/components/originattributes/test/browser/browser_permissions.js b/browser/components/originattributes/test/browser/browser_permissions.js index 3b615c14eb7b..3a076f4eaf7e 100644 --- a/browser/components/originattributes/test/browser/browser_permissions.js +++ b/browser/components/originattributes/test/browser/browser_permissions.js @@ -4,12 +4,16 @@ * This test is testing the cookie "permission" for a specific URI. */ +const { PermissionTestUtils } = ChromeUtils.import( + "resource://testing-common/PermissionTestUtils.jsm" +); + const TEST_PAGE = "http://example.net"; const uri = Services.io.newURI(TEST_PAGE); function disableCookies() { Services.cookies.removeAll(); - Services.perms.add(uri, "cookie", Services.perms.DENY_ACTION); + PermissionTestUtils.add(uri, "cookie", Services.perms.DENY_ACTION); } function ensureCookieNotSet(aBrowser) { @@ -33,7 +37,7 @@ IsolationTestTools.runTests( function enableCookies() { Services.cookies.removeAll(); - Services.perms.add(uri, "cookie", Services.perms.ALLOW_ACTION); + PermissionTestUtils.add(uri, "cookie", Services.perms.ALLOW_ACTION); } function ensureCookieSet(aBrowser) { diff --git a/browser/components/preferences/in-content/tests/browser_cookies_exceptions.js b/browser/components/preferences/in-content/tests/browser_cookies_exceptions.js index 3a93727dcb05..b99b72d1e216 100644 --- a/browser/components/preferences/in-content/tests/browser_cookies_exceptions.js +++ b/browser/components/preferences/in-content/tests/browser_cookies_exceptions.js @@ -138,7 +138,11 @@ add_task(async function testAdd() { await runTest( async (params, observeAllPromise, apply) => { let uri = Services.io.newURI("http://test.com"); - Services.perms.add(uri, "popup", Ci.nsIPermissionManager.DENY_ACTION); + PermissionTestUtils.add( + uri, + "popup", + Ci.nsIPermissionManager.DENY_ACTION + ); info("Adding unrelated permission should not change display."); assertListContents(params, []); @@ -146,7 +150,7 @@ add_task(async function testAdd() { apply(); await observeAllPromise; - Services.perms.remove(uri, "popup"); + PermissionTestUtils.remove(uri, "popup"); }, params => { return [ @@ -412,7 +416,11 @@ add_task(async function testSort() { for (let URL of ["http://a", "http://z", "http://b"]) { let URI = Services.io.newURI(URL); - Services.perms.add(URI, "cookie", Ci.nsIPermissionManager.ALLOW_ACTION); + PermissionTestUtils.add( + URI, + "cookie", + Ci.nsIPermissionManager.ALLOW_ACTION + ); } assertListContents(params, [ @@ -439,7 +447,7 @@ add_task(async function testSort() { for (let URL of ["http://a", "http://z", "http://b"]) { let uri = Services.io.newURI(URL); - Services.perms.remove(uri, "cookie"); + PermissionTestUtils.remove(uri, "cookie"); } }, params => { diff --git a/browser/components/preferences/in-content/tests/head.js b/browser/components/preferences/in-content/tests/head.js index 50ef7ee036db..d201d66f8e0c 100644 --- a/browser/components/preferences/in-content/tests/head.js +++ b/browser/components/preferences/in-content/tests/head.js @@ -2,6 +2,9 @@ * http://creativecommons.org/publicdomain/zero/1.0/ */ ChromeUtils.import("resource://gre/modules/Promise.jsm", this); +const { PermissionTestUtils } = ChromeUtils.import( + "resource://testing-common/PermissionTestUtils.jsm" +); const kDefaultWait = 2000; diff --git a/browser/components/translation/test/browser_translation_exceptions.js b/browser/components/translation/test/browser_translation_exceptions.js index f12854f8b950..da4d900e7a4e 100644 --- a/browser/components/translation/test/browser_translation_exceptions.js +++ b/browser/components/translation/test/browser_translation_exceptions.js @@ -6,6 +6,9 @@ var tmp = {}; ChromeUtils.import("resource:///modules/translation/Translation.jsm", tmp); +const { PermissionTestUtils } = ChromeUtils.import( + "resource://testing-common/PermissionTestUtils.jsm" +); var { Translation } = tmp; const kLanguagesPref = "browser.translation.neverForLanguages"; @@ -240,7 +243,7 @@ var gTests = [ ); // Cleanup. - Services.perms.remove(makeURI("http://example.com"), "translate"); + PermissionTestUtils.remove("http://example.com", "translate"); notif.close(); }, }, @@ -307,9 +310,16 @@ var gTests = [ run: async function checkDomainExceptions() { // Put 2 exceptions before opening the window to check the list is // displayed on load. - let perms = Services.perms; - perms.add(makeURI("http://example.org"), "translate", perms.DENY_ACTION); - perms.add(makeURI("http://example.com"), "translate", perms.DENY_ACTION); + PermissionTestUtils.add( + "http://example.org", + "translate", + Services.perms.DENY_ACTION + ); + PermissionTestUtils.add( + "http://example.com", + "translate", + Services.perms.DENY_ACTION + ); // Open the translation exceptions dialog. let win = openDialog( @@ -339,14 +349,18 @@ var gTests = [ is(getDomainExceptions().length, 1, "One exception in the permissions"); // Clear the permissions, and check the last item is removed from the display. - perms.remove(makeURI("http://example.org"), "translate"); - perms.remove(makeURI("http://example.com"), "translate"); + PermissionTestUtils.remove("http://example.org", "translate"); + PermissionTestUtils.remove("http://example.com", "translate"); is(tree.view.rowCount, 0, "The site exceptions list is empty"); ok(remove.disabled, "The 'Remove Site' button is disabled"); ok(removeAll.disabled, "The 'Remove All Site' button is disabled"); // Add an item and check it appears. - perms.add(makeURI("http://example.com"), "translate", perms.DENY_ACTION); + PermissionTestUtils.add( + "http://example.com", + "translate", + Services.perms.DENY_ACTION + ); is(tree.view.rowCount, 1, "The site exceptions list has 1 item"); ok(remove.disabled, "The 'Remove Site' button is disabled"); ok(!removeAll.disabled, "The 'Remove All Sites' button is enabled"); diff --git a/browser/components/uitour/test/browser_no_tabs.js b/browser/components/uitour/test/browser_no_tabs.js index bf6e9d42de5f..719484b56be1 100644 --- a/browser/components/uitour/test/browser_no_tabs.js +++ b/browser/components/uitour/test/browser_no_tabs.js @@ -60,8 +60,7 @@ add_task(async function test_windowless_UITour() { // Allow the URL to use the UITour. info("Adding UITour permission to the test page."); - let pageURI = Services.io.newURI(pageURL); - Services.perms.add(pageURI, "uitour", Services.perms.ALLOW_ACTION); + PermissionTestUtils.add(gTestPath, "uitour", Services.perms.ALLOW_ACTION); // UITour's ping will resolve this promise. await new Promise(resolve => { diff --git a/browser/components/uitour/test/head.js b/browser/components/uitour/test/head.js index 5b64ab8593c0..e928ffc1fd69 100644 --- a/browser/components/uitour/test/head.js +++ b/browser/components/uitour/test/head.js @@ -9,6 +9,10 @@ ChromeUtils.defineModuleGetter( "resource:///modules/UITour.jsm" ); +const { PermissionTestUtils } = ChromeUtils.import( + "resource://testing-common/PermissionTestUtils.jsm" +); + const SINGLE_TRY_TIMEOUT = 100; const NUMBER_OF_TRIES = 30; @@ -446,10 +450,18 @@ function setup_UITourTest() { // Use `add_task(setup_UITourTest);` instead as we will fold this into `setup_UITourTest` once all tests are using `add_UITour_task`. function UITourTest(usingAddTask = false) { Services.prefs.setBoolPref("browser.uitour.enabled", true); - let testHttpsUri = Services.io.newURI("https://example.org"); - let testHttpUri = Services.io.newURI("http://example.org"); - Services.perms.add(testHttpsUri, "uitour", Services.perms.ALLOW_ACTION); - Services.perms.add(testHttpUri, "uitour", Services.perms.ALLOW_ACTION); + let testHttpsOrigin = "https://example.org"; + let testHttpOrigin = "http://example.org"; + PermissionTestUtils.add( + testHttpsOrigin, + "uitour", + Services.perms.ALLOW_ACTION + ); + PermissionTestUtils.add( + testHttpOrigin, + "uitour", + Services.perms.ALLOW_ACTION + ); // If a test file is using add_task, we don't need to have a test function or // call `waitForExplicitFinish`. @@ -465,8 +477,8 @@ function UITourTest(usingAddTask = false) { } delete window.gTestTab; Services.prefs.clearUserPref("browser.uitour.enabled"); - Services.perms.remove(testHttpsUri, "uitour"); - Services.perms.remove(testHttpUri, "uitour"); + PermissionTestUtils.remove(testHttpsOrigin, "uitour"); + PermissionTestUtils.remove(testHttpOrigin, "uitour"); }); // When using tasks, the harness will call the next added task for us. diff --git a/browser/modules/test/unit/test_SiteDataManager.js b/browser/modules/test/unit/test_SiteDataManager.js index 1f10f6d1c995..9d4d2e3d84d0 100644 --- a/browser/modules/test/unit/test_SiteDataManager.js +++ b/browser/modules/test/unit/test_SiteDataManager.js @@ -13,6 +13,9 @@ const { SiteDataManager } = ChromeUtils.import( const { SiteDataTestUtils } = ChromeUtils.import( "resource://testing-common/SiteDataTestUtils.jsm" ); +const { PermissionTestUtils } = ChromeUtils.import( + "resource://testing-common/PermissionTestUtils.jsm" +); ChromeUtils.defineModuleGetter( this, "setTimeout", @@ -119,7 +122,7 @@ add_task(async function testRemove() { await SiteDataManager.updateSites(); let uri = Services.io.newURI(EXAMPLE_ORIGIN); - Services.perms.add(uri, "camera", Services.perms.ALLOW_ACTION); + PermissionTestUtils.add(uri, "camera", Services.perms.ALLOW_ACTION); SiteDataTestUtils.addToCookies(EXAMPLE_ORIGIN, "foo1", "bar1"); SiteDataTestUtils.addToCookies(EXAMPLE_ORIGIN, "foo2", "bar2"); @@ -151,25 +154,25 @@ add_task(async function testRemove() { let cookies = Services.cookies.countCookiesFromHost("example.com"); Assert.equal(cookies, 0, "Has cleared cookies for example.com"); - let perm = Services.perms.testPermission(uri, "persistent-storage"); + let perm = PermissionTestUtils.testPermission(uri, "persistent-storage"); Assert.equal( perm, Services.perms.UNKNOWN_ACTION, "Cleared the persistent-storage permission." ); - perm = Services.perms.testPermission(uri, "camera"); + perm = PermissionTestUtils.testPermission(uri, "camera"); Assert.equal( perm, Services.perms.ALLOW_ACTION, "Did not clear other permissions." ); - Services.perms.remove(uri, "camera"); + PermissionTestUtils.remove(uri, "camera"); }); add_task(async function testRemoveSiteData() { let uri = Services.io.newURI(EXAMPLE_ORIGIN); - Services.perms.add(uri, "camera", Services.perms.ALLOW_ACTION); + PermissionTestUtils.add(uri, "camera", Services.perms.ALLOW_ACTION); SiteDataTestUtils.addToCookies(EXAMPLE_ORIGIN, "foo1", "bar1"); SiteDataTestUtils.addToCookies(EXAMPLE_ORIGIN, "foo2", "bar2"); @@ -199,18 +202,18 @@ add_task(async function testRemoveSiteData() { let cookies = Services.cookies.countCookiesFromHost("example.org"); Assert.equal(cookies, 0, "Has cleared cookies for example.org"); - let perm = Services.perms.testPermission(uri, "persistent-storage"); + let perm = PermissionTestUtils.testPermission(uri, "persistent-storage"); Assert.equal( perm, Services.perms.UNKNOWN_ACTION, "Cleared the persistent-storage permission." ); - perm = Services.perms.testPermission(uri, "camera"); + perm = PermissionTestUtils.testPermission(uri, "camera"); Assert.equal( perm, Services.perms.ALLOW_ACTION, "Did not clear other permissions." ); - Services.perms.remove(uri, "camera"); + PermissionTestUtils.remove(uri, "camera"); }); diff --git a/dom/indexedDB/test/unit/test_idle_maintenance.js b/dom/indexedDB/test/unit/test_idle_maintenance.js index 04d31828da68..5c4d2ac2551f 100644 --- a/dom/indexedDB/test/unit/test_idle_maintenance.js +++ b/dom/indexedDB/test/unit/test_idle_maintenance.js @@ -15,7 +15,11 @@ function* testSteps() { info("Setting permissions"); - Services.perms.add(uri, "indexedDB", Ci.nsIPermissionManager.ALLOW_ACTION); + Services.perms.addFromPrincipal( + principal, + "indexedDB", + Ci.nsIPermissionManager.ALLOW_ACTION + ); // The idle-daily notification is disabled in xpchsell tests, so we don't // need to do anything special to disable it for this test. diff --git a/dom/indexedDB/test/unit/test_storageOption_pref.js b/dom/indexedDB/test/unit/test_storageOption_pref.js index c0204006ed48..d9bd1dcf7793 100644 --- a/dom/indexedDB/test/unit/test_storageOption_pref.js +++ b/dom/indexedDB/test/unit/test_storageOption_pref.js @@ -20,8 +20,14 @@ function* testSteps() { const origin = "https://example.com"; // Avoid trying to show permission prompts on a window. - let uri = Services.io.newURI(origin); - Services.perms.add(uri, "indexedDB", Ci.nsIPermissionManager.ALLOW_ACTION); + let principal = Services.scriptSecurityManager.createContentPrincipalFromOrigin( + origin + ); + Services.perms.addFromPrincipal( + principal, + "indexedDB", + Ci.nsIPermissionManager.ALLOW_ACTION + ); const objectStoreName = "Foo"; const data = { key: 1, value: "bar" }; @@ -30,7 +36,6 @@ function* testSteps() { Services.prefs.setBoolPref("dom.indexedDB.storageOption.enabled", false); // Open a database with content privileges. - let principal = getPrincipal(origin); let request = indexedDB.openForPrincipal(principal, name, { version, storage: "persistent", diff --git a/dom/notification/test/browser/browser_permission_dismiss.js b/dom/notification/test/browser/browser_permission_dismiss.js index dc30c0fa6ce3..c0572b2c11fa 100644 --- a/dom/notification/test/browser/browser_permission_dismiss.js +++ b/dom/notification/test/browser/browser_permission_dismiss.js @@ -1,5 +1,9 @@ "use strict"; +const { PermissionTestUtils } = ChromeUtils.import( + "resource://testing-common/PermissionTestUtils.jsm" +); + const ORIGIN_URI = Services.io.newURI("https://example.com"); const PERMISSION_NAME = "desktop-notification"; const PROMPT_ALLOW_BUTTON = -1; @@ -45,7 +49,7 @@ function clickDoorhangerButton(aButtonIndex) { * closes. */ function tabWithRequest(task, permission) { - Services.perms.remove(ORIGIN_URI, PERMISSION_NAME); + PermissionTestUtils.remove(ORIGIN_URI, PERMISSION_NAME); return BrowserTestUtils.withNewTab( { @@ -94,7 +98,7 @@ add_task(async function setup() { ); SimpleTest.registerCleanupFunction(() => { Services.prefs.clearUserPref("dom.webnotifications.requireuserinteraction"); - Services.perms.remove(ORIGIN_URI, PERMISSION_NAME); + PermissionTestUtils.remove(ORIGIN_URI, PERMISSION_NAME); }); }); @@ -109,7 +113,7 @@ add_task(async function test_requestPermission_granted() { ); is( - Services.perms.testPermission(ORIGIN_URI, PERMISSION_NAME), + PermissionTestUtils.testPermission(ORIGIN_URI, PERMISSION_NAME), Services.perms.ALLOW_ACTION, "Check permission in perm. manager" ); @@ -126,7 +130,7 @@ add_task(async function test_requestPermission_denied_temporarily() { ); is( - Services.perms.testPermission(ORIGIN_URI, PERMISSION_NAME), + PermissionTestUtils.testPermission(ORIGIN_URI, PERMISSION_NAME), Services.perms.UNKNOWN_ACTION, "Check permission in perm. manager" ); @@ -143,7 +147,7 @@ add_task(async function test_requestPermission_denied_permanently() { ); is( - Services.perms.testPermission(ORIGIN_URI, PERMISSION_NAME), + PermissionTestUtils.testPermission(ORIGIN_URI, PERMISSION_NAME), Services.perms.DENY_ACTION, "Check permission in perm. manager" ); diff --git a/dom/push/test/xpcshell/head.js b/dom/push/test/xpcshell/head.js index 2f3b35a144a6..b833189889a1 100644 --- a/dom/push/test/xpcshell/head.js +++ b/dom/push/test/xpcshell/head.js @@ -24,6 +24,9 @@ var { PlacesUtils } = ChromeUtils.import( var { ObjectUtils } = ChromeUtils.import( "resource://gre/modules/ObjectUtils.jsm" ); +var { PermissionTestUtils } = ChromeUtils.import( + "resource://testing-common/PermissionTestUtils.jsm" +); ChromeUtils.defineModuleGetter( this, diff --git a/dom/push/test/xpcshell/test_drop_expired.js b/dom/push/test/xpcshell/test_drop_expired.js index 618eec40d027..475ec3eaed00 100644 --- a/dom/push/test/xpcshell/test_drop_expired.js +++ b/dom/push/test/xpcshell/test_drop_expired.js @@ -23,13 +23,13 @@ function visitURI(uri, timestamp) { var putRecord = async function({ scope, perm, quota, lastPush, lastVisit }) { let uri = Services.io.newURI(scope); - Services.perms.add( + PermissionTestUtils.add( uri, "desktop-notification", Ci.nsIPermissionManager[perm] ); registerCleanupFunction(() => { - Services.perms.remove(uri, "desktop-notification"); + PermissionTestUtils.remove(uri, "desktop-notification"); }); await visitURI(uri, lastVisit); @@ -156,7 +156,7 @@ add_task(async function test_perm_restored() { (subject, data) => data == "https://example.info/expired-perm-revoked" ); - Services.perms.add( + PermissionTestUtils.add( permURI, "desktop-notification", Ci.nsIPermissionManager.ALLOW_ACTION diff --git a/dom/push/test/xpcshell/test_quota_observer.js b/dom/push/test/xpcshell/test_quota_observer.js index 9f8c0148f74f..6609de0a3f69 100644 --- a/dom/push/test/xpcshell/test_quota_observer.js +++ b/dom/push/test/xpcshell/test_quota_observer.js @@ -20,13 +20,13 @@ function run_test() { let putRecord = async function(perm, record) { let uri = Services.io.newURI(record.scope); - Services.perms.add( + PermissionTestUtils.add( uri, "desktop-notification", Ci.nsIPermissionManager[perm] ); registerCleanupFunction(() => { - Services.perms.remove(uri, "desktop-notification"); + PermissionTestUtils.remove(uri, "desktop-notification"); }); await db.put(record); diff --git a/dom/push/test/xpcshell/test_record.js b/dom/push/test/xpcshell/test_record.js index 70c2be0476b3..968c7a7a6666 100644 --- a/dom/push/test/xpcshell/test_record.js +++ b/dom/push/test/xpcshell/test_record.js @@ -90,7 +90,7 @@ function testPermissionCheck(props) { `Record ${JSON.stringify(props)} should not have permission yet` ); let permURI = Services.io.newURI(props.scope); - Services.perms.add( + PermissionTestUtils.add( permURI, "desktop-notification", Ci.nsIPermissionManager.ALLOW_ACTION @@ -101,7 +101,7 @@ function testPermissionCheck(props) { `Record ${JSON.stringify(props)} should have permission` ); } finally { - Services.perms.remove(permURI, "desktop-notification"); + PermissionTestUtils.remove(permURI, "desktop-notification"); } } diff --git a/dom/serviceworkers/test/browser_storage_permission.js b/dom/serviceworkers/test/browser_storage_permission.js index 317b8fccf207..bd73d43e28f6 100644 --- a/dom/serviceworkers/test/browser_storage_permission.js +++ b/dom/serviceworkers/test/browser_storage_permission.js @@ -1,5 +1,9 @@ "use strict"; +const { PermissionTestUtils } = ChromeUtils.import( + "resource://testing-common/PermissionTestUtils.jsm" +); + const BASE_URI = "http://mochi.test:8888/browser/dom/serviceworkers/test/"; const PAGE_URI = BASE_URI + "empty.html"; const SCOPE = PAGE_URI + "?storage_permission"; @@ -47,8 +51,8 @@ add_task(async function setup() { }); add_task(async function test_allow_permission() { - Services.perms.add( - Services.io.newURI(PAGE_URI), + PermissionTestUtils.add( + PAGE_URI, "cookie", Ci.nsICookiePermission.ACCESS_ALLOW ); @@ -67,8 +71,8 @@ add_task(async function test_allow_permission() { }); add_task(async function test_deny_permission() { - Services.perms.add( - Services.io.newURI(PAGE_URI), + PermissionTestUtils.add( + PAGE_URI, "cookie", Ci.nsICookiePermission.ACCESS_DENY ); @@ -84,12 +88,12 @@ add_task(async function test_deny_permission() { is(controller, null, "page should be not controlled with storage denied"); BrowserTestUtils.removeTab(tab); - Services.perms.remove(Services.io.newURI(PAGE_URI), "cookie"); + PermissionTestUtils.remove(PAGE_URI, "cookie"); }); add_task(async function test_session_permission() { - Services.perms.add( - Services.io.newURI(PAGE_URI), + PermissionTestUtils.add( + PAGE_URI, "cookie", Ci.nsICookiePermission.ACCESS_SESSION ); @@ -105,14 +109,14 @@ add_task(async function test_session_permission() { is(controller, null, "page should be not controlled with session storage"); BrowserTestUtils.removeTab(tab); - Services.perms.remove(Services.io.newURI(PAGE_URI), "cookie"); + PermissionTestUtils.remove(PAGE_URI, "cookie"); }); // Test to verify an about:blank iframe successfully inherits the // parent's controller when storage is blocked between opening the // parent page and creating the iframe. add_task(async function test_block_storage_before_blank_iframe() { - Services.perms.remove(Services.io.newURI(PAGE_URI), "cookie"); + PermissionTestUtils.remove(PAGE_URI, "cookie"); let tab = BrowserTestUtils.addTab(gBrowser, SCOPE); let browser = gBrowser.getBrowserForTab(tab); @@ -156,7 +160,7 @@ add_task(async function test_block_storage_before_blank_iframe() { // parent's controller when storage is blocked between opening the // parent page and creating the iframe. add_task(async function test_block_storage_before_blob_iframe() { - Services.perms.remove(Services.io.newURI(PAGE_URI), "cookie"); + PermissionTestUtils.remove(PAGE_URI, "cookie"); let tab = BrowserTestUtils.addTab(gBrowser, SCOPE); let browser = gBrowser.getBrowserForTab(tab); @@ -212,7 +216,7 @@ add_task(async function test_block_storage_before_blob_iframe() { // explicitly check if the worker is controlled since we don't expose // WorkerNavigator.serviceWorkers.controller yet. add_task(async function test_block_storage_before_blob_worker() { - Services.perms.remove(Services.io.newURI(PAGE_URI), "cookie"); + PermissionTestUtils.remove(PAGE_URI, "cookie"); let tab = BrowserTestUtils.addTab(gBrowser, SCOPE); let browser = gBrowser.getBrowserForTab(tab); @@ -265,7 +269,7 @@ add_task(async function test_block_storage_before_blob_worker() { }); add_task(async function cleanup() { - Services.perms.remove(Services.io.newURI(PAGE_URI), "cookie"); + PermissionTestUtils.remove(PAGE_URI, "cookie"); let tab = BrowserTestUtils.addTab(gBrowser, PAGE_URI); let browser = gBrowser.getBrowserForTab(tab); diff --git a/netwerk/cookie/test/browser/head.js b/netwerk/cookie/test/browser/head.js index 84ea9bc8e676..95a079f4ff28 100644 --- a/netwerk/cookie/test/browser/head.js +++ b/netwerk/cookie/test/browser/head.js @@ -1,3 +1,7 @@ +const { PermissionTestUtils } = ChromeUtils.import( + "resource://testing-common/PermissionTestUtils.jsm" +); + const BEHAVIOR_ACCEPT = Ci.nsICookieService.BEHAVIOR_ACCEPT; const BEHAVIOR_REJECT = Ci.nsICookieService.BEHAVIOR_REJECT; @@ -86,10 +90,8 @@ this.CookiePolicyHelper = { await SpecialPowers.pushPrefEnv({ set: prefs }); } - let uri = Services.io.newURI(TEST_DOMAIN); - // Let's set the first cookie pref. - Services.perms.add(uri, "cookie", config.fromPermission); + PermissionTestUtils.add(TEST_DOMAIN, "cookie", config.fromPermission); await SpecialPowers.pushPrefEnv({ set: [["network.cookie.cookieBehavior", config.fromBehavior]], }); @@ -133,7 +135,7 @@ this.CookiePolicyHelper = { ); // Now, let's change the cookie settings - Services.perms.add(uri, "cookie", config.toPermission); + PermissionTestUtils.add(TEST_DOMAIN, "cookie", config.toPermission); await SpecialPowers.pushPrefEnv({ set: [["network.cookie.cookieBehavior", config.toBehavior]], }); diff --git a/netwerk/test/unit/test_bug767025.js b/netwerk/test/unit/test_bug767025.js index 2b18155a1858..f1ebcb2eb6d7 100644 --- a/netwerk/test/unit/test_bug767025.js +++ b/netwerk/test/unit/test_bug767025.js @@ -1,6 +1,9 @@ /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ const { HttpServer } = ChromeUtils.import("resource://testing-common/httpd.js"); +const { PermissionTestUtils } = ChromeUtils.import( + "resource://testing-common/PermissionTestUtils.jsm" +); /** * This is testcase do following steps to make sure bug767025 removing @@ -107,7 +110,7 @@ function do_app_cache(manifestURL, pageURL) { Ci.nsIOfflineCacheUpdateService ); - Services.perms.add( + PermissionTestUtils.add( manifestURL, "offline-app", Ci.nsIPermissionManager.ALLOW_ACTION diff --git a/netwerk/test/unit/test_pinned_app_cache.js b/netwerk/test/unit/test_pinned_app_cache.js index 2472e8bab5d2..06159dbdd4e3 100644 --- a/netwerk/test/unit/test_pinned_app_cache.js +++ b/netwerk/test/unit/test_pinned_app_cache.js @@ -31,6 +31,9 @@ */ const { HttpServer } = ChromeUtils.import("resource://testing-common/httpd.js"); +const { PermissionTestUtils } = ChromeUtils.import( + "resource://testing-common/PermissionTestUtils.jsm" +); // const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components; @@ -141,7 +144,7 @@ function do_app_cache(manifestURL, pageURL, pinned) { Ci.nsIOfflineCacheUpdateService ); - Services.perms.add( + PermissionTestUtils.add( manifestURL, "pin-app", pinned diff --git a/toolkit/components/antitracking/test/browser/browser_allowListSeparationInPrivateAndNormalWindows.js b/toolkit/components/antitracking/test/browser/browser_allowListSeparationInPrivateAndNormalWindows.js index 81095c0c4e5c..343feb801958 100644 --- a/toolkit/components/antitracking/test/browser/browser_allowListSeparationInPrivateAndNormalWindows.js +++ b/toolkit/components/antitracking/test/browser/browser_allowListSeparationInPrivateAndNormalWindows.js @@ -15,7 +15,11 @@ "use strict"; add_task(async _ => { let uri = Services.io.newURI("https://example.net"); - Services.perms.add(uri, "trackingprotection-pb", Services.perms.ALLOW_ACTION); + PermissionTestUtils.add( + uri, + "trackingprotection-pb", + Services.perms.ALLOW_ACTION + ); registerCleanupFunction(_ => { Services.perms.removeAll(); diff --git a/toolkit/components/antitracking/test/browser/browser_allowPermissionForTracker.js b/toolkit/components/antitracking/test/browser/browser_allowPermissionForTracker.js index fdcecd8da790..c9fe27b056cf 100644 --- a/toolkit/components/antitracking/test/browser/browser_allowPermissionForTracker.js +++ b/toolkit/components/antitracking/test/browser/browser_allowPermissionForTracker.js @@ -4,13 +4,13 @@ /* import-globals-from antitracking_head.js */ add_task(async _ => { - Services.perms.add( - Services.io.newURI("https://tracking.example.org"), + PermissionTestUtils.add( + "https://tracking.example.org", "cookie", Services.perms.ALLOW_ACTION ); - Services.perms.add( - Services.io.newURI("https://tracking.example.com"), + PermissionTestUtils.add( + "https://tracking.example.com", "cookie", Services.perms.ALLOW_ACTION ); diff --git a/toolkit/components/antitracking/test/browser/browser_denyPermissionForTracker.js b/toolkit/components/antitracking/test/browser/browser_denyPermissionForTracker.js index 5c118cc3f849..7c2fbb897c9d 100644 --- a/toolkit/components/antitracking/test/browser/browser_denyPermissionForTracker.js +++ b/toolkit/components/antitracking/test/browser/browser_denyPermissionForTracker.js @@ -4,13 +4,13 @@ /* import-globals-from antitracking_head.js */ add_task(async _ => { - Services.perms.add( - Services.io.newURI("https://tracking.example.org"), + PermissionTestUtils.add( + "https://tracking.example.org", "cookie", Services.perms.DENY_ACTION ); - Services.perms.add( - Services.io.newURI("https://tracking.example.com"), + PermissionTestUtils.add( + "https://tracking.example.com", "cookie", Services.perms.DENY_ACTION ); diff --git a/toolkit/components/antitracking/test/browser/browser_permissionInNormalWindows.js b/toolkit/components/antitracking/test/browser/browser_permissionInNormalWindows.js index d33d95c0bcd6..9d230984271a 100644 --- a/toolkit/components/antitracking/test/browser/browser_permissionInNormalWindows.js +++ b/toolkit/components/antitracking/test/browser/browser_permissionInNormalWindows.js @@ -13,8 +13,10 @@ AntiTracking.runTest( let Services = SpecialPowers.Services; // We would use TEST_3RD_PARTY_DOMAIN here, except that the variable isn't // accessible in the context of the web page... - let uri = Services.io.newURI("https://tracking.example.org/"); - for (let perm of Services.perms.getAllForURI(uri)) { + let principal = Services.scriptSecurityManager.createContentPrincipalFromOrigin( + "https://tracking.example.org/" + ); + for (let perm of Services.perms.getAllForPrincipal(principal)) { // Ignore permissions other than storage access if (!perm.type.startsWith("3rdPartyStorage^")) { continue; diff --git a/toolkit/components/antitracking/test/browser/browser_permissionInPrivateWindows.js b/toolkit/components/antitracking/test/browser/browser_permissionInPrivateWindows.js index 785b31c31724..d6f33dbf0ab9 100644 --- a/toolkit/components/antitracking/test/browser/browser_permissionInPrivateWindows.js +++ b/toolkit/components/antitracking/test/browser/browser_permissionInPrivateWindows.js @@ -13,8 +13,10 @@ AntiTracking.runTest( let Services = SpecialPowers.Services; // We would use TEST_3RD_PARTY_DOMAIN here, except that the variable isn't // accessible in the context of the web page... - let uri = Services.io.newURI("https://tracking.example.org/"); - for (let perm of Services.perms.getAllForURI(uri)) { + let principal = Services.scriptSecurityManager.createContentPrincipalFromOrigin( + "https://tracking.example.org/" + ); + for (let perm of Services.perms.getAllForPrincipal(principal)) { // Ignore permissions other than storage access if (!perm.type.startsWith("3rdPartyStorage^")) { continue; diff --git a/toolkit/components/antitracking/test/browser/browser_storageAccessDoorHanger.js b/toolkit/components/antitracking/test/browser/browser_storageAccessDoorHanger.js index 1a4744651114..3b76fb4b585f 100644 --- a/toolkit/components/antitracking/test/browser/browser_storageAccessDoorHanger.js +++ b/toolkit/components/antitracking/test/browser/browser_storageAccessDoorHanger.js @@ -242,119 +242,29 @@ async function preparePermissionsFromOtherSites(topPage) { // For the first page, don't do anything } else if (topPage == TEST_TOP_PAGE_2) { // For the second page, only add the permission from the first page - Services.perms.add( - Services.io.newURI(TEST_DOMAIN), - type, - permission, - expireType, - 0 - ); + PermissionTestUtils.add(TEST_DOMAIN, type, permission, expireType, 0); } else if (topPage == TEST_TOP_PAGE_3) { // For the third page, add the permissions from the first two pages - Services.perms.add( - Services.io.newURI(TEST_DOMAIN), - type, - permission, - expireType, - 0 - ); - Services.perms.add( - Services.io.newURI(TEST_DOMAIN_2), - type, - permission, - expireType, - 0 - ); + PermissionTestUtils.add(TEST_DOMAIN, type, permission, expireType, 0); + PermissionTestUtils.add(TEST_DOMAIN_2, type, permission, expireType, 0); } else if (topPage == TEST_TOP_PAGE_4) { // For the fourth page, add the permissions from the first three pages - Services.perms.add( - Services.io.newURI(TEST_DOMAIN), - type, - permission, - expireType, - 0 - ); - Services.perms.add( - Services.io.newURI(TEST_DOMAIN_2), - type, - permission, - expireType, - 0 - ); - Services.perms.add( - Services.io.newURI(TEST_DOMAIN_3), - type, - permission, - expireType, - 0 - ); + PermissionTestUtils.add(TEST_DOMAIN, type, permission, expireType, 0); + PermissionTestUtils.add(TEST_DOMAIN_2, type, permission, expireType, 0); + PermissionTestUtils.add(TEST_DOMAIN_3, type, permission, expireType, 0); } else if (topPage == TEST_TOP_PAGE_5) { // For the fifth page, add the permissions from the first four pages - Services.perms.add( - Services.io.newURI(TEST_DOMAIN), - type, - permission, - expireType, - 0 - ); - Services.perms.add( - Services.io.newURI(TEST_DOMAIN_2), - type, - permission, - expireType, - 0 - ); - Services.perms.add( - Services.io.newURI(TEST_DOMAIN_3), - type, - permission, - expireType, - 0 - ); - Services.perms.add( - Services.io.newURI(TEST_DOMAIN_4), - type, - permission, - expireType, - 0 - ); + PermissionTestUtils.add(TEST_DOMAIN, type, permission, expireType, 0); + PermissionTestUtils.add(TEST_DOMAIN_2, type, permission, expireType, 0); + PermissionTestUtils.add(TEST_DOMAIN_3, type, permission, expireType, 0); + PermissionTestUtils.add(TEST_DOMAIN_4, type, permission, expireType, 0); } else if (topPage == TEST_TOP_PAGE_6) { // For the sixth page, add the permissions from the first five pages - Services.perms.add( - Services.io.newURI(TEST_DOMAIN), - type, - permission, - expireType, - 0 - ); - Services.perms.add( - Services.io.newURI(TEST_DOMAIN_2), - type, - permission, - expireType, - 0 - ); - Services.perms.add( - Services.io.newURI(TEST_DOMAIN_3), - type, - permission, - expireType, - 0 - ); - Services.perms.add( - Services.io.newURI(TEST_DOMAIN_4), - type, - permission, - expireType, - 0 - ); - Services.perms.add( - Services.io.newURI(TEST_DOMAIN_5), - type, - permission, - expireType, - 0 - ); + PermissionTestUtils.add(TEST_DOMAIN, type, permission, expireType, 0); + PermissionTestUtils.add(TEST_DOMAIN_2, type, permission, expireType, 0); + PermissionTestUtils.add(TEST_DOMAIN_3, type, permission, expireType, 0); + PermissionTestUtils.add(TEST_DOMAIN_4, type, permission, expireType, 0); + PermissionTestUtils.add(TEST_DOMAIN_5, type, permission, expireType, 0); } else { ok(false, "Unexpected top page: " + topPage); } diff --git a/toolkit/components/antitracking/test/browser/browser_userInteraction.js b/toolkit/components/antitracking/test/browser/browser_userInteraction.js index ccc06f97a778..5c1d5a03f6fa 100644 --- a/toolkit/components/antitracking/test/browser/browser_userInteraction.js +++ b/toolkit/components/antitracking/test/browser/browser_userInteraction.js @@ -31,7 +31,7 @@ add_task(async function() { let uri = Services.io.newURI(TEST_DOMAIN); is( - Services.perms.testPermission(uri, "storageAccessAPI"), + PermissionTestUtils.testPermission(uri, "storageAccessAPI"), Services.perms.UNKNOWN_ACTION, "Before user-interaction we don't have a permission" ); diff --git a/toolkit/components/antitracking/test/browser/head.js b/toolkit/components/antitracking/test/browser/head.js index e83b76e0073f..e978317df449 100644 --- a/toolkit/components/antitracking/test/browser/head.js +++ b/toolkit/components/antitracking/test/browser/head.js @@ -56,6 +56,10 @@ const { UrlClassifierTestUtils } = ChromeUtils.import( "resource://testing-common/UrlClassifierTestUtils.jsm" ); +const { PermissionTestUtils } = ChromeUtils.import( + "resource://testing-common/PermissionTestUtils.jsm" +); + Services.scriptloader.loadSubScript( "chrome://mochitests/content/browser/toolkit/components/antitracking/test/browser/antitracking_head.js", this diff --git a/toolkit/components/antitracking/test/browser/storageAccessAPIHelpers.js b/toolkit/components/antitracking/test/browser/storageAccessAPIHelpers.js index 6a4c42fec55c..a3a8b49365f7 100644 --- a/toolkit/components/antitracking/test/browser/storageAccessAPIHelpers.js +++ b/toolkit/components/antitracking/test/browser/storageAccessAPIHelpers.js @@ -147,8 +147,13 @@ async function waitUntilPermission(url, name) { let id = setInterval(_ => { let Services = SpecialPowers.Services; let uri = Services.io.newURI(url); + let principal = Services.scriptSecurityManager.createContentPrincipal( + uri, + {} + ); if ( - Services.perms.testPermission(uri, name) == Services.perms.ALLOW_ACTION + Services.perms.testPermissionFromPrincipal(principal, name) == + Services.perms.ALLOW_ACTION ) { clearInterval(id); resolve(); @@ -174,11 +179,17 @@ async function interactWithTracker() { function isOnContentBlockingAllowList() { let url = new URL(SpecialPowers.wrap(top).location.href); let origin = SpecialPowers.Services.io.newURI("https://" + url.host); + let principal = SpecialPowers.Services.scriptSecurityManager.createContentPrincipal( + origin, + {} + ); let types = ["trackingprotection", "trackingprotection-pb"]; return types.some(type => { return ( - SpecialPowers.Services.perms.testPermission(origin, type) == - SpecialPowers.Services.perms.ALLOW_ACTION + SpecialPowers.Services.perms.testPermissionFromPrincipal( + principal, + type + ) == SpecialPowers.Services.perms.ALLOW_ACTION ); }); } diff --git a/toolkit/components/passwordmgr/test/unit/test_storage_mozStorage.js b/toolkit/components/passwordmgr/test/unit/test_storage_mozStorage.js index 8ca5d6471b57..5f6ca144397f 100644 --- a/toolkit/components/passwordmgr/test/unit/test_storage_mozStorage.js +++ b/toolkit/components/passwordmgr/test/unit/test_storage_mozStorage.js @@ -5,6 +5,10 @@ /* eslint-disable no-var */ +const { PermissionTestUtils } = ChromeUtils.import( + "resource://testing-common/PermissionTestUtils.jsm" +); + const ENCTYPE_BASE64 = 0; const ENCTYPE_SDR = 1; const PERMISSION_SAVE_LOGINS = "login-saving"; @@ -83,12 +87,14 @@ function getAllDisabledHostsFromPermissionManager() { } function setLoginSavingEnabled(origin, enabled) { - let uri = Services.io.newURI(origin); - if (enabled) { - Services.perms.remove(uri, PERMISSION_SAVE_LOGINS); + PermissionTestUtils.remove(origin, PERMISSION_SAVE_LOGINS); } else { - Services.perms.add(uri, PERMISSION_SAVE_LOGINS, Services.perms.DENY_ACTION); + PermissionTestUtils.add( + origin, + PERMISSION_SAVE_LOGINS, + Services.perms.DENY_ACTION + ); } } diff --git a/toolkit/components/telemetry/tests/browser/browser_HybridContentTelemetry.js b/toolkit/components/telemetry/tests/browser/browser_HybridContentTelemetry.js index 0262e42f8109..fe211279959a 100644 --- a/toolkit/components/telemetry/tests/browser/browser_HybridContentTelemetry.js +++ b/toolkit/components/telemetry/tests/browser/browser_HybridContentTelemetry.js @@ -13,6 +13,9 @@ const { TelemetryUtils } = ChromeUtils.import( const { ObjectUtils } = ChromeUtils.import( "resource://gre/modules/ObjectUtils.jsm" ); +const { PermissionTestUtils } = ChromeUtils.import( + "resource://testing-common/PermissionTestUtils.jsm" +); const HC_PERMISSION = "hc_telemetry"; @@ -95,7 +98,11 @@ add_task(async function test_untrusted_http_origin() { // Try to use the API on a non-secure host. const testHost = "http://example.org"; let testHttpUri = Services.io.newURI(testHost); - Services.perms.add(testHttpUri, HC_PERMISSION, Services.perms.ALLOW_ACTION); + PermissionTestUtils.add( + testHttpUri, + HC_PERMISSION, + Services.perms.ALLOW_ACTION + ); let url = getRootDirectory(gTestPath) + "hybrid_content.html"; url = url.replace("chrome://mochitests/content", testHost); let newTab = await BrowserTestUtils.openNewForegroundTab(gBrowser, url); @@ -127,7 +134,7 @@ add_task(async function test_untrusted_http_origin() { // Finally clean up the listener. BrowserTestUtils.removeTab(newTab); - Services.perms.remove(testHttpUri, HC_PERMISSION); + PermissionTestUtils.remove(testHttpUri, HC_PERMISSION); Services.mm.removeMessageListener(messageName, makeTestFail); Services.telemetry.setEventRecordingEnabled("telemetry.test", false); }); @@ -195,7 +202,11 @@ add_task(async function test_trusted_disabled_hybrid_telemetry() { // Try to use the API on a secure host. const testHost = "https://example.org"; let testHttpsUri = Services.io.newURI(testHost); - Services.perms.add(testHttpsUri, HC_PERMISSION, Services.perms.ALLOW_ACTION); + PermissionTestUtils.add( + testHttpsUri, + HC_PERMISSION, + Services.perms.ALLOW_ACTION + ); let url = getRootDirectory(gTestPath) + "hybrid_content.html"; url = url.replace("chrome://mochitests/content", testHost); let newTab = await BrowserTestUtils.openNewForegroundTab(gBrowser, url); @@ -228,7 +239,7 @@ add_task(async function test_trusted_disabled_hybrid_telemetry() { // Finally clean up the listener. await SpecialPowers.popPrefEnv(); BrowserTestUtils.removeTab(newTab); - Services.perms.remove(testHttpsUri, HC_PERMISSION); + PermissionTestUtils.remove(testHttpsUri, HC_PERMISSION); Services.mm.removeMessageListener(messageName, makeTestFail); Services.telemetry.setEventRecordingEnabled("telemetry.test", false); }); @@ -239,7 +250,11 @@ add_task(async function test_hybrid_content_with_iframe() { // Open a trusted page that can use in the HCT in a new tab. const testOuterPageHost = "https://example.com"; let testHttpsUri = Services.io.newURI(testOuterPageHost); - Services.perms.add(testHttpsUri, HC_PERMISSION, Services.perms.ALLOW_ACTION); + PermissionTestUtils.add( + testHttpsUri, + HC_PERMISSION, + Services.perms.ALLOW_ACTION + ); let url = getRootDirectory(gTestPath) + "hybrid_content.html"; let outerUrl = url.replace("chrome://mochitests/content", testOuterPageHost); let newTab = await BrowserTestUtils.openNewForegroundTab(gBrowser, outerUrl); @@ -297,7 +312,7 @@ add_task(async function test_hybrid_content_with_iframe() { // Cleanup permissions and remove the tab. BrowserTestUtils.removeTab(newTab); Services.mm.removeMessageListener(messageName, makeTestFail); - Services.perms.remove(testHttpsUri, HC_PERMISSION); + PermissionTestUtils.remove(testHttpsUri, HC_PERMISSION); Services.telemetry.setEventRecordingEnabled("telemetry.test", false); }); @@ -325,7 +340,11 @@ add_task(async function test_hybrid_content_recording() { // Give the test host enough privileges to use the API and open the test page. let testHttpsUri = Services.io.newURI(testHost); - Services.perms.add(testHttpsUri, HC_PERMISSION, Services.perms.ALLOW_ACTION); + PermissionTestUtils.add( + testHttpsUri, + HC_PERMISSION, + Services.perms.ALLOW_ACTION + ); let url = getRootDirectory(gTestPath) + "hybrid_content.html"; url = url.replace("chrome://mochitests/content", testHost); let newTab = await BrowserTestUtils.openNewForegroundTab(gBrowser, url); @@ -398,7 +417,7 @@ add_task(async function test_hybrid_content_recording() { // Cleanup permissions and remove the tab. BrowserTestUtils.removeTab(newTab); - Services.perms.remove(testHttpsUri, HC_PERMISSION); + PermissionTestUtils.remove(testHttpsUri, HC_PERMISSION); }); add_task(async function test_can_upload() { @@ -410,7 +429,11 @@ add_task(async function test_can_upload() { // Give the test host enough privileges to use the API and open the test page. let testHttpsUri = Services.io.newURI(testHost); - Services.perms.add(testHttpsUri, HC_PERMISSION, Services.perms.ALLOW_ACTION); + PermissionTestUtils.add( + testHttpsUri, + HC_PERMISSION, + Services.perms.ALLOW_ACTION + ); let url = getRootDirectory(gTestPath) + "hybrid_content.html"; url = url.replace("chrome://mochitests/content", testHost); let newTab = await BrowserTestUtils.openNewForegroundTab(gBrowser, url); @@ -445,14 +468,17 @@ add_task(async function test_can_upload() { // Cleanup permissions and remove the tab. BrowserTestUtils.removeTab(newTab); - Services.perms.remove(testHttpsUri, HC_PERMISSION); + PermissionTestUtils.remove(testHttpsUri, HC_PERMISSION); }); add_task(async function test_hct_for_discopane() { const discoHost = "https://discovery.addons.mozilla.org"; let discoHttpsUri = Services.io.newURI(discoHost); - let permission = Services.perms.testPermission(discoHttpsUri, HC_PERMISSION); + let permission = PermissionTestUtils.testPermission( + discoHttpsUri, + HC_PERMISSION + ); ok( permission == Services.perms.ALLOW_ACTION, @@ -496,7 +522,7 @@ add_task(async function test_init_rejects() { // Give the test host HCT privileges and test that init doesn't throw. const testHostPrivileges = "https://example.com"; let testUrlPrivileges = Services.io.newURI(testHostPrivileges); - Services.perms.add( + PermissionTestUtils.add( testUrlPrivileges, HC_PERMISSION, Services.perms.ALLOW_ACTION @@ -534,5 +560,5 @@ add_task(async function test_init_rejects() { // Cleanup permissions and remove the tab. BrowserTestUtils.removeTab(newTab); BrowserTestUtils.removeTab(otherTab); - Services.perms.remove(testUrlPrivileges, HC_PERMISSION); + PermissionTestUtils.remove(testUrlPrivileges, HC_PERMISSION); }); diff --git a/toolkit/modules/tests/xpcshell/test_PermissionsUtils.js b/toolkit/modules/tests/xpcshell/test_PermissionsUtils.js index 411e6cb517e8..a80eaa805486 100644 --- a/toolkit/modules/tests/xpcshell/test_PermissionsUtils.js +++ b/toolkit/modules/tests/xpcshell/test_PermissionsUtils.js @@ -13,6 +13,9 @@ const TEST_PERM = "test-permission"; const { PermissionsUtils } = ChromeUtils.import( "resource://gre/modules/PermissionsUtils.jsm" ); +const { PermissionTestUtils } = ChromeUtils.import( + "resource://testing-common/PermissionTestUtils.jsm" +); function run_test() { test_importfromPrefs(); @@ -79,7 +82,7 @@ function test_importfromPrefs() { for (let url of unknown) { let uri = Services.io.newURI(url); Assert.equal( - Services.perms.testPermission(uri, TEST_PERM), + PermissionTestUtils.testPermission(uri, TEST_PERM), Services.perms.UNKNOWN_ACTION ); } @@ -99,21 +102,21 @@ function test_importfromPrefs() { for (let url of whitelisted) { let uri = Services.io.newURI(url); Assert.equal( - Services.perms.testPermission(uri, TEST_PERM), + PermissionTestUtils.testPermission(uri, TEST_PERM), Services.perms.ALLOW_ACTION ); } for (let url of blacklisted) { let uri = Services.io.newURI(url); Assert.equal( - Services.perms.testPermission(uri, TEST_PERM), + PermissionTestUtils.testPermission(uri, TEST_PERM), Services.perms.DENY_ACTION ); } for (let url of untouched) { let uri = Services.io.newURI(url); Assert.equal( - Services.perms.testPermission(uri, TEST_PERM), + PermissionTestUtils.testPermission(uri, TEST_PERM), Services.perms.UNKNOWN_ACTION ); } diff --git a/toolkit/modules/tests/xpcshell/test_web_channel.js b/toolkit/modules/tests/xpcshell/test_web_channel.js index d37fa4fcda57..3d25c8608340 100644 --- a/toolkit/modules/tests/xpcshell/test_web_channel.js +++ b/toolkit/modules/tests/xpcshell/test_web_channel.js @@ -6,6 +6,9 @@ const { WebChannel } = ChromeUtils.import( "resource://gre/modules/WebChannel.jsm" ); +const { PermissionTestUtils } = ChromeUtils.import( + "resource://testing-common/PermissionTestUtils.jsm" +); const ERROR_ID_ORIGIN_REQUIRED = "WebChannel id and originOrPermission are required."; @@ -93,13 +96,13 @@ add_task(function test_web_channel_listen() { add_task(function test_web_channel_listen_permission() { return new Promise((resolve, reject) => { // add a new permission - Services.perms.add( + PermissionTestUtils.add( VALID_WEB_CHANNEL_ORIGIN, TEST_PERMISSION_NAME, Services.perms.ALLOW_ACTION ); registerCleanupFunction(() => - Services.perms.remove(VALID_WEB_CHANNEL_ORIGIN, TEST_PERMISSION_NAME) + PermissionTestUtils.remove(VALID_WEB_CHANNEL_ORIGIN, TEST_PERMISSION_NAME) ); let channel = new WebChannel(VALID_WEB_CHANNEL_ID, TEST_PERMISSION_NAME, { broker: MockWebChannelBroker, diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_permissions.js b/toolkit/mozapps/extensions/test/xpcshell/test_permissions.js index 5147ad63d36a..c542a5c65612 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_permissions.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_permissions.js @@ -5,6 +5,10 @@ // Checks that permissions set in preferences are correctly imported but can // be removed by the user. +const { PermissionTestUtils } = ChromeUtils.import( + "resource://testing-common/PermissionTestUtils.jsm" +); + const XPI_MIMETYPE = "application/x-xpinstall"; function newPrincipal(uri) { @@ -30,8 +34,8 @@ add_task(async function setup() { "https://test5.com" ); - Services.perms.add( - NetUtil.newURI("https://www.test9.com"), + PermissionTestUtils.add( + "https://www.test9.com", "install", Ci.nsIPermissionManager.ALLOW_ACTION ); diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_amosigned_trigger.js b/toolkit/mozapps/extensions/test/xpinstall/browser_amosigned_trigger.js index e04a323ca173..7c405876a51b 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/browser_amosigned_trigger.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_amosigned_trigger.js @@ -8,8 +8,11 @@ function test() { Harness.finalContentEvent = "InstallComplete"; Harness.setup(); - var pm = Services.perms; - pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + PermissionTestUtils.add( + "http://example.com/", + "install", + Services.perms.ALLOW_ACTION + ); var triggers = encodeURIComponent( JSON.stringify({ @@ -46,7 +49,7 @@ function install_ended(install, addon) { const finish_test = async function(count) { is(count, 1, "1 Add-on should have been successfully installed"); - Services.perms.remove(makeURI("http://example.com"), "install"); + PermissionTestUtils.remove("http://example.com", "install"); const results = await ContentTask.spawn( gBrowser.selectedBrowser, diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_amosigned_trigger_iframe.js b/toolkit/mozapps/extensions/test/xpinstall/browser_amosigned_trigger_iframe.js index a22dc9323ad6..2fa2a9707038 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/browser_amosigned_trigger_iframe.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_amosigned_trigger_iframe.js @@ -9,8 +9,11 @@ function test() { Harness.finalContentEvent = "InstallComplete"; Harness.setup(); - var pm = Services.perms; - pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + PermissionTestUtils.add( + "http://example.com/", + "install", + Services.perms.ALLOW_ACTION + ); var inner_url = encodeURIComponent( TESTROOT + @@ -46,7 +49,7 @@ function install_ended(install, addon) { const finish_test = async function(count) { is(count, 1, "1 Add-on should have been successfully installed"); - Services.perms.remove(makeURI("http://example.com"), "install"); + PermissionTestUtils.remove("http://example.com", "install"); const results = await ContentTask.spawn( gBrowser.selectedBrowser, diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_auth.js b/toolkit/mozapps/extensions/test/xpinstall/browser_auth.js index a906ab5e1ee9..263576ddf9cc 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/browser_auth.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_auth.js @@ -16,8 +16,11 @@ function test() { Services.prefs.setIntPref("network.auth.subresource-http-auth-allow", 2); - var pm = Services.perms; - pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + PermissionTestUtils.add( + "http://example.com/", + "install", + Services.perms.ALLOW_ACTION + ); var triggers = encodeURIComponent( JSON.stringify({ @@ -51,7 +54,7 @@ function finish_test(count) { ); authMgr.clearAll(); - Services.perms.remove(makeURI("http://example.com"), "install"); + PermissionTestUtils.remove("http://example.com", "install"); Services.prefs.clearUserPref( "network.auth.non-web-content-triggered-resources-http-auth-allow" diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_auth2.js b/toolkit/mozapps/extensions/test/xpinstall/browser_auth2.js index afcedaf6cf33..aa16bf1172de 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/browser_auth2.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_auth2.js @@ -16,8 +16,11 @@ function test() { Harness.installsCompletedCallback = finish_test; Harness.setup(); - var pm = Services.perms; - pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + PermissionTestUtils.add( + "http://example.com/", + "install", + Services.perms.ALLOW_ACTION + ); var triggers = encodeURIComponent( JSON.stringify({ @@ -56,7 +59,7 @@ function finish_test(count) { ); authMgr.clearAll(); - Services.perms.remove(makeURI("http://example.com"), "install"); + PermissionTestUtils.remove("http://example.com", "install"); Services.prefs.clearUserPref( "network.auth.non-web-content-triggered-resources-http-auth-allow" diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_auth3.js b/toolkit/mozapps/extensions/test/xpinstall/browser_auth3.js index 2a3eef5bd53d..1b812c0b1c1b 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/browser_auth3.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_auth3.js @@ -15,8 +15,11 @@ function test() { Harness.installsCompletedCallback = finish_test; Harness.setup(); - var pm = Services.perms; - pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + PermissionTestUtils.add( + "http://example.com/", + "install", + Services.perms.ALLOW_ACTION + ); var triggers = encodeURIComponent( JSON.stringify({ @@ -55,7 +58,7 @@ function finish_test(count) { ); authMgr.clearAll(); - Services.perms.remove(makeURI("http://example.com"), "install"); + PermissionTestUtils.remove("http://example.com", "install"); Services.prefs.clearUserPref( "network.auth.non-web-content-triggered-resources-http-auth-allow" diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_auth4.js b/toolkit/mozapps/extensions/test/xpinstall/browser_auth4.js index 0ba2267ff3f8..c86c6999f1e2 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/browser_auth4.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_auth4.js @@ -14,8 +14,11 @@ function test() { Harness.installsCompletedCallback = finish_test; Harness.setup(); - var pm = Services.perms; - pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + PermissionTestUtils.add( + "http://example.com/", + "install", + Services.perms.ALLOW_ACTION + ); var triggers = encodeURIComponent( JSON.stringify({ @@ -54,7 +57,7 @@ function finish_test(count) { ); authMgr.clearAll(); - Services.perms.remove(makeURI("http://example.com"), "install"); + PermissionTestUtils.remove("http://example.com", "install"); Services.prefs.clearUserPref( "network.auth.non-web-content-triggered-resources-http-auth-allow" diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_badhash.js b/toolkit/mozapps/extensions/test/xpinstall/browser_badhash.js index 1a022682a026..b27c1f459c3b 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/browser_badhash.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_badhash.js @@ -6,8 +6,11 @@ function test() { Harness.installsCompletedCallback = finish_test; Harness.setup(); - var pm = Services.perms; - pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + PermissionTestUtils.add( + "http://example.com/", + "install", + Services.perms.ALLOW_ACTION + ); var triggers = encodeURIComponent( JSON.stringify({ @@ -33,7 +36,7 @@ function download_failed(install) { function finish_test(count) { is(count, 0, "No add-ons should have been installed"); - Services.perms.remove(makeURI("http://example.com/"), "install"); + PermissionTestUtils.remove("http://example.com/", "install"); gBrowser.removeCurrentTab(); Harness.finish(); diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_badhashtype.js b/toolkit/mozapps/extensions/test/xpinstall/browser_badhashtype.js index 1a30348ff426..5ef1f2963ff3 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/browser_badhashtype.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_badhashtype.js @@ -6,8 +6,11 @@ function test() { Harness.installsCompletedCallback = finish_test; Harness.setup(); - var pm = Services.perms; - pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + PermissionTestUtils.add( + "http://example.com/", + "install", + Services.perms.ALLOW_ACTION + ); var triggers = encodeURIComponent( JSON.stringify({ @@ -33,7 +36,7 @@ function download_failed(install) { function finish_test(count) { is(count, 0, "No add-ons should have been installed"); - Services.perms.remove(makeURI("http://example.com/"), "install"); + PermissionTestUtils.remove("http://example.com/", "install"); gBrowser.removeCurrentTab(); Harness.finish(); diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_bug540558.js b/toolkit/mozapps/extensions/test/xpinstall/browser_bug540558.js index b18fd77cf89f..805453ae69c1 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/browser_bug540558.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_bug540558.js @@ -5,8 +5,11 @@ function test() { Harness.installsCompletedCallback = finish_test; Harness.setup(); - var pm = Services.perms; - pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + PermissionTestUtils.add( + "http://example.com/", + "install", + Services.perms.ALLOW_ACTION + ); gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser); BrowserTestUtils.loadURI(gBrowser, TESTROOT + "bug540558.html"); @@ -18,7 +21,7 @@ function check_xpi_install(install, addon) { function finish_test(count) { is(count, 1, "1 Add-on should have been successfully installed"); - Services.perms.remove(makeURI("http://example.com"), "install"); + PermissionTestUtils.remove("http://example.com", "install"); gBrowser.removeCurrentTab(); Harness.finish(); diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_bug645699.js b/toolkit/mozapps/extensions/test/xpinstall/browser_bug645699.js index 3d7e2a936da4..c2fb96a3e7c7 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/browser_bug645699.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_bug645699.js @@ -8,8 +8,11 @@ function test() { Harness.installsCompletedCallback = finish_test; Harness.setup(); - var pm = Services.perms; - pm.add(makeURI("http://example.org/"), "install", pm.ALLOW_ACTION); + PermissionTestUtils.add( + "http://example.org/", + "install", + Services.perms.ALLOW_ACTION + ); gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser); BrowserTestUtils.loadURI(gBrowser, TESTROOT + "bug645699.html"); @@ -36,7 +39,7 @@ function confirm_install(panel) { function finish_test(count) { is(count, 0, "0 Add-ons should have been successfully installed"); - Services.perms.remove(makeURI("http://addons.mozilla.org"), "install"); + PermissionTestUtils.remove("http://addons.mozilla.org", "install"); gBrowser.removeCurrentTab(); Harness.finish(); diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_bug672485.js b/toolkit/mozapps/extensions/test/xpinstall/browser_bug672485.js index f50b325e198e..0b0bae0de4b4 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/browser_bug672485.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_bug672485.js @@ -15,8 +15,11 @@ function test() { delete Services.ww; is(Services.ww, undefined, "Services.ww should now be undefined"); - var pm = Services.perms; - pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + PermissionTestUtils.add( + "http://example.com/", + "install", + Services.perms.ALLOW_ACTION + ); var triggers = encodeURIComponent( JSON.stringify({ @@ -51,7 +54,7 @@ function finish_test(count) { Services.ww = gWindowWatcher; - Services.perms.remove(makeURI("http://example.com"), "install"); + PermissionTestUtils.remove("http://example.com", "install"); Harness.finish(); } diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_containers.js b/toolkit/mozapps/extensions/test/xpinstall/browser_containers.js index 768275a5958f..71fd67cd0fad 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/browser_containers.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_containers.js @@ -29,8 +29,11 @@ function test() { Harness.finalContentEvent = "InstallComplete"; Harness.setup(); - var pm = Services.perms; - pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + PermissionTestUtils.add( + "http://example.com/", + "install", + Services.perms.ALLOW_ACTION + ); var triggers = encodeURIComponent( JSON.stringify({ @@ -76,7 +79,7 @@ const finish_test = async function(count) { Services.obs.removeObserver(check_channel, "http-on-before-connect"); - Services.perms.remove(makeURI("http://example.com"), "install"); + PermissionTestUtils.remove("http://example.com", "install"); const results = await ContentTask.spawn( gBrowser.selectedBrowser, diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_cookies.js b/toolkit/mozapps/extensions/test/xpinstall/browser_cookies.js index 10e4a06b4f7e..5056b3365036 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/browser_cookies.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_cookies.js @@ -7,8 +7,11 @@ function test() { Harness.installsCompletedCallback = finish_test; Harness.setup(); - var pm = Services.perms; - pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + PermissionTestUtils.add( + "http://example.com/", + "install", + Services.perms.ALLOW_ACTION + ); var triggers = encodeURIComponent( JSON.stringify({ @@ -29,7 +32,7 @@ function download_failed(install) { function finish_test(count) { is(count, 0, "No add-ons should have been installed"); - Services.perms.remove(makeURI("http://example.com"), "install"); + PermissionTestUtils.remove("http://example.com", "install"); gBrowser.removeCurrentTab(); Harness.finish(); diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_cookies2.js b/toolkit/mozapps/extensions/test/xpinstall/browser_cookies2.js index b9e6eadd87d5..319f86717304 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/browser_cookies2.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_cookies2.js @@ -20,8 +20,11 @@ function test() { Ci.nsICookie.SAMESITE_NONE ); - var pm = Services.perms; - pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + PermissionTestUtils.add( + "http://example.com/", + "install", + Services.perms.ALLOW_ACTION + ); var triggers = encodeURIComponent( JSON.stringify({ @@ -51,7 +54,7 @@ function finish_test(count) { {} ); - Services.perms.remove(makeURI("http://example.com"), "install"); + PermissionTestUtils.remove("http://example.com", "install"); gBrowser.removeCurrentTab(); Harness.finish(); diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_cookies3.js b/toolkit/mozapps/extensions/test/xpinstall/browser_cookies3.js index a65919c9d8d6..451b7605f299 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/browser_cookies3.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_cookies3.js @@ -20,8 +20,11 @@ function test() { Ci.nsICookie.SAMESITE_NONE ); - var pm = Services.perms; - pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + PermissionTestUtils.add( + "http://example.com/", + "install", + Services.perms.ALLOW_ACTION + ); Services.prefs.setIntPref("network.cookie.cookieBehavior", 1); @@ -55,7 +58,7 @@ function finish_test(count) { Services.prefs.clearUserPref("network.cookie.cookieBehavior"); - Services.perms.remove(makeURI("http://example.com"), "install"); + PermissionTestUtils.remove("http://example.com", "install"); gBrowser.removeCurrentTab(); Harness.finish(); diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_cookies4.js b/toolkit/mozapps/extensions/test/xpinstall/browser_cookies4.js index b12657375928..6bcf0a718c54 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/browser_cookies4.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_cookies4.js @@ -21,8 +21,11 @@ function test() { Ci.nsICookie.SAMESITE_NONE ); - var pm = Services.perms; - pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + PermissionTestUtils.add( + "http://example.com/", + "install", + Services.perms.ALLOW_ACTION + ); Services.prefs.setIntPref("network.cookie.cookieBehavior", 1); @@ -55,7 +58,7 @@ function finish_test(count) { ); Services.prefs.clearUserPref("network.cookie.cookieBehavior"); - Services.perms.remove(makeURI("http://example.com"), "install"); + PermissionTestUtils.remove("http://example.com", "install"); gBrowser.removeCurrentTab(); Harness.finish(); diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_corrupt.js b/toolkit/mozapps/extensions/test/xpinstall/browser_corrupt.js index 846a8e5392b8..b392bf05874d 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/browser_corrupt.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_corrupt.js @@ -6,8 +6,11 @@ function test() { Harness.finalContentEvent = "InstallComplete"; Harness.setup(); - var pm = Services.perms; - pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + PermissionTestUtils.add( + "http://example.com/", + "install", + Services.perms.ALLOW_ACTION + ); var triggers = encodeURIComponent( JSON.stringify({ @@ -27,7 +30,7 @@ function download_failed(install) { const finish_test = async function(count) { is(count, 0, "No add-ons should have been installed"); - Services.perms.remove(makeURI("http://example.com"), "install"); + PermissionTestUtils.remove("http://example.com", "install"); const results = await ContentTask.spawn( gBrowser.selectedBrowser, diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_datauri.js b/toolkit/mozapps/extensions/test/xpinstall/browser_datauri.js index 775549af49d8..a3aa6c53b672 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/browser_datauri.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_datauri.js @@ -53,7 +53,7 @@ function install_blocked(installInfo) { function finish_test(count) { is(count, 0, "No add-ons should have been installed"); - Services.perms.remove(makeURI("http://example.com"), "install"); + PermissionTestUtils.remove("http://example.com", "install"); gBrowser.removeCurrentTab(); Harness.finish(); diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_doorhanger_installs.js b/toolkit/mozapps/extensions/test/xpinstall/browser_doorhanger_installs.js index b09559cda001..1abfceec9fdc 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/browser_doorhanger_installs.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_doorhanger_installs.js @@ -422,7 +422,7 @@ var TESTS = [ let installs = await AddonManager.getAllInstalls(); is(installs.length, 0, "Should be no pending installs"); - let installPerm = Services.perms.testPermission( + let installPerm = PermissionTestUtils.testPermission( gBrowser.currentURI, "install" ); @@ -480,8 +480,11 @@ var TESTS = [ let originalTab = gBrowser.selectedTab; let tab; gBrowser.selectedTab = originalTab; - let pm = Services.perms; - pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + PermissionTestUtils.add( + "http://example.com/", + "install", + Services.perms.ALLOW_ACTION + ); let progressPromise = waitForProgressNotification(); let dialogPromise = waitForInstallDialog(); @@ -532,15 +535,18 @@ var TESTS = [ addon.uninstall(); - Services.perms.remove(makeURI("http://example.com/"), "install"); + PermissionTestUtils.remove("http://example.com/", "install"); Services.prefs.clearUserPref("extensions.allowPrivateBrowsingByDefault"); await removeTabAndWaitForNotificationClose(); }, async function test_failedDownload() { - let pm = Services.perms; - pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + PermissionTestUtils.add( + "http://example.com/", + "install", + Services.perms.ALLOW_ACTION + ); let progressPromise = waitForProgressNotification(); let failPromise = waitForNotification("addon-install-failed"); @@ -563,13 +569,16 @@ var TESTS = [ "Should have seen the right message" ); - Services.perms.remove(makeURI("http://example.com/"), "install"); + PermissionTestUtils.remove("http://example.com/", "install"); await removeTabAndWaitForNotificationClose(); }, async function test_corruptFile() { - let pm = Services.perms; - pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + PermissionTestUtils.add( + "http://example.com/", + "install", + Services.perms.ALLOW_ACTION + ); let progressPromise = waitForProgressNotification(); let failPromise = waitForNotification("addon-install-failed"); @@ -593,13 +602,16 @@ var TESTS = [ "Should have seen the right message" ); - Services.perms.remove(makeURI("http://example.com/"), "install"); + PermissionTestUtils.remove("http://example.com/", "install"); await removeTabAndWaitForNotificationClose(); }, async function test_incompatible() { - let pm = Services.perms; - pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + PermissionTestUtils.add( + "http://example.com/", + "install", + Services.perms.ALLOW_ACTION + ); let progressPromise = waitForProgressNotification(); let failPromise = waitForNotification("addon-install-failed"); @@ -629,7 +641,7 @@ var TESTS = [ "Should have seen the right message" ); - Services.perms.remove(makeURI("http://example.com/"), "install"); + PermissionTestUtils.remove("http://example.com/", "install"); await removeTabAndWaitForNotificationClose(); }, @@ -807,8 +819,11 @@ var TESTS = [ }, async function test_cancel() { - let pm = Services.perms; - pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + PermissionTestUtils.add( + "http://example.com/", + "install", + Services.perms.ALLOW_ACTION + ); let notificationPromise = waitForNotification(PROGRESS_NOTIFICATION); let triggers = encodeURIComponent( @@ -862,7 +877,7 @@ var TESTS = [ let installs = await AddonManager.getAllInstalls(); is(installs.length, 0, "Should be no pending install"); - Services.perms.remove(makeURI("http://example.com/"), "install"); + PermissionTestUtils.remove("http://example.com/", "install"); BrowserTestUtils.removeTab(gBrowser.selectedTab); }, diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_empty.js b/toolkit/mozapps/extensions/test/xpinstall/browser_empty.js index 21f1f34b8d8a..25ae27325a14 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/browser_empty.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_empty.js @@ -5,8 +5,11 @@ function test() { Harness.installsCompletedCallback = finish_test; Harness.setup(); - var pm = Services.perms; - pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + PermissionTestUtils.add( + "http://example.com/", + "install", + Services.perms.ALLOW_ACTION + ); var triggers = encodeURIComponent( JSON.stringify({ @@ -26,7 +29,7 @@ function download_failed(install) { function finish_test(count) { is(count, 0, "No add-ons should have been installed"); - Services.perms.remove(makeURI("http://example.com"), "install"); + PermissionTestUtils.remove("http://example.com", "install"); gBrowser.removeCurrentTab(); Harness.finish(); diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_hash.js b/toolkit/mozapps/extensions/test/xpinstall/browser_hash.js index 37fea4643e5c..55ad2bb4bb1a 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/browser_hash.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_hash.js @@ -6,8 +6,11 @@ function test() { Harness.installsCompletedCallback = finish_test; Harness.setup(); - var pm = Services.perms; - pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + PermissionTestUtils.add( + "http://example.com/", + "install", + Services.perms.ALLOW_ACTION + ); var triggers = encodeURIComponent( JSON.stringify({ @@ -34,7 +37,7 @@ function install_ended(install, addon) { function finish_test(count) { is(count, 1, "1 Add-on should have been successfully installed"); - Services.perms.remove(makeURI("http://example.com"), "install"); + PermissionTestUtils.remove("http://example.com", "install"); gBrowser.removeCurrentTab(); Harness.finish(); diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_hash2.js b/toolkit/mozapps/extensions/test/xpinstall/browser_hash2.js index 4ed9f7b42647..0f06cd9715b1 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/browser_hash2.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_hash2.js @@ -6,8 +6,11 @@ function test() { Harness.installsCompletedCallback = finish_test; Harness.setup(); - var pm = Services.perms; - pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + PermissionTestUtils.add( + "http://example.com/", + "install", + Services.perms.ALLOW_ACTION + ); var triggers = encodeURIComponent( JSON.stringify({ @@ -34,7 +37,7 @@ function install_ended(install, addon) { function finish_test(count) { is(count, 1, "1 Add-on should have been successfully installed"); - Services.perms.remove(makeURI("http://example.com"), "install"); + PermissionTestUtils.remove("http://example.com", "install"); gBrowser.removeCurrentTab(); Harness.finish(); diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_httphash.js b/toolkit/mozapps/extensions/test/xpinstall/browser_httphash.js index 99cee600847a..9248f5962b1b 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/browser_httphash.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_httphash.js @@ -7,8 +7,11 @@ function test() { Harness.installsCompletedCallback = finish_test; Harness.setup(); - var pm = Services.perms; - pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + PermissionTestUtils.add( + "http://example.com/", + "install", + Services.perms.ALLOW_ACTION + ); Services.prefs.setBoolPref(PREF_INSTALL_REQUIREBUILTINCERTS, false); var url = "https://example.com/browser/" + RELATIVE_DIR + "hashRedirect.sjs"; @@ -41,7 +44,7 @@ function install_ended(install, addon) { function finish_test(count) { is(count, 1, "1 Add-on should have been successfully installed"); - Services.perms.remove(makeURI("http://example.com"), "install"); + PermissionTestUtils.remove("http://example.com", "install"); Services.prefs.clearUserPref(PREF_INSTALL_REQUIREBUILTINCERTS); gBrowser.removeCurrentTab(); diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_httphash2.js b/toolkit/mozapps/extensions/test/xpinstall/browser_httphash2.js index ebda5949f018..a411aa0ecb61 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/browser_httphash2.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_httphash2.js @@ -7,8 +7,11 @@ function test() { Harness.installsCompletedCallback = finish_test; Harness.setup(); - var pm = Services.perms; - pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + PermissionTestUtils.add( + "http://example.com/", + "install", + Services.perms.ALLOW_ACTION + ); Services.prefs.setBoolPref(PREF_INSTALL_REQUIREBUILTINCERTS, false); var url = "https://example.com/browser/" + RELATIVE_DIR + "hashRedirect.sjs"; @@ -38,7 +41,7 @@ function download_failed(install) { function finish_test(count) { is(count, 0, "0 Add-ons should have been successfully installed"); - Services.perms.remove(makeURI("http://example.com"), "install"); + PermissionTestUtils.remove("http://example.com", "install"); Services.prefs.clearUserPref(PREF_INSTALL_REQUIREBUILTINCERTS); gBrowser.removeCurrentTab(); diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_httphash3.js b/toolkit/mozapps/extensions/test/xpinstall/browser_httphash3.js index 999bad84b8ab..7892e8478105 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/browser_httphash3.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_httphash3.js @@ -6,8 +6,11 @@ function test() { Harness.installsCompletedCallback = finish_test; Harness.setup(); - var pm = Services.perms; - pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + PermissionTestUtils.add( + "http://example.com/", + "install", + Services.perms.ALLOW_ACTION + ); Services.prefs.setBoolPref(PREF_INSTALL_REQUIREBUILTINCERTS, false); var url = "https://example.com/browser/" + RELATIVE_DIR + "hashRedirect.sjs"; @@ -38,7 +41,7 @@ function install_ended(install, addon) { function finish_test(count) { is(count, 1, "1 Add-on should have been successfully installed"); - Services.perms.remove(makeURI("http://example.com"), "install"); + PermissionTestUtils.remove("http://example.com", "install"); Services.prefs.clearUserPref(PREF_INSTALL_REQUIREBUILTINCERTS); gBrowser.removeCurrentTab(); diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_httphash4.js b/toolkit/mozapps/extensions/test/xpinstall/browser_httphash4.js index c96229a27680..1ca0735b903c 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/browser_httphash4.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_httphash4.js @@ -6,8 +6,11 @@ function test() { Harness.installsCompletedCallback = finish_test; Harness.setup(); - var pm = Services.perms; - pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + PermissionTestUtils.add( + "http://example.com/", + "install", + Services.perms.ALLOW_ACTION + ); var url = "http://example.com/browser/" + RELATIVE_DIR + "hashRedirect.sjs"; url += "?sha1:foobar|" + TESTROOT + "amosigned.xpi"; @@ -36,7 +39,7 @@ function install_ended(install, addon) { function finish_test(count) { is(count, 1, "1 Add-on should have been successfully installed"); - Services.perms.remove(makeURI("http://example.com"), "install"); + PermissionTestUtils.remove("http://example.com", "install"); gBrowser.removeCurrentTab(); Harness.finish(); diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_httphash5.js b/toolkit/mozapps/extensions/test/xpinstall/browser_httphash5.js index df96e003a12c..2f7b5d7b74c8 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/browser_httphash5.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_httphash5.js @@ -6,8 +6,11 @@ function test() { Harness.installsCompletedCallback = finish_test; Harness.setup(); - var pm = Services.perms; - pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + PermissionTestUtils.add( + "http://example.com/", + "install", + Services.perms.ALLOW_ACTION + ); Services.prefs.setBoolPref(PREF_INSTALL_REQUIREBUILTINCERTS, false); var url = "https://example.com/browser/" + RELATIVE_DIR + "hashRedirect.sjs"; @@ -39,7 +42,7 @@ function install_ended(install, addon) { function finish_test(count) { is(count, 1, "1 Add-on should have been successfully installed"); - Services.perms.remove(makeURI("http://example.com"), "install"); + PermissionTestUtils.remove("http://example.com", "install"); Services.prefs.clearUserPref(PREF_INSTALL_REQUIREBUILTINCERTS); gBrowser.removeCurrentTab(); diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_httphash6.js b/toolkit/mozapps/extensions/test/xpinstall/browser_httphash6.js index efc6c3bf841d..7437dfaa7d97 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/browser_httphash6.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_httphash6.js @@ -20,8 +20,11 @@ function test() { Harness.installsCompletedCallback = finish_failed_download; Harness.setup(); - var pm = Services.perms; - pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + PermissionTestUtils.add( + "http://example.com/", + "install", + Services.perms.ALLOW_ACTION + ); Services.prefs.setBoolPref(PREF_INSTALL_REQUIREBUILTINCERTS, false); // Set up the redirect to give a bad hash @@ -93,7 +96,7 @@ function install_ended(install, addon) { function finish_test(count) { is(count, 1, "1 Add-on should have been successfully installed"); - Services.perms.remove(makeURI("http://example.com"), "install"); + PermissionTestUtils.remove("http://example.com", "install"); Services.prefs.clearUserPref(PREF_INSTALL_REQUIREBUILTINCERTS); gBrowser.removeCurrentTab(); diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_installchrome.js b/toolkit/mozapps/extensions/test/xpinstall/browser_installchrome.js index 85042fc844a1..ae7868dbaacd 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/browser_installchrome.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_installchrome.js @@ -5,8 +5,11 @@ function test() { Harness.installsCompletedCallback = finish_test; Harness.setup(); - var pm = Services.perms; - pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + PermissionTestUtils.add( + "http://example.com/", + "install", + Services.perms.ALLOW_ACTION + ); gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser); BrowserTestUtils.loadURI( @@ -23,7 +26,7 @@ function install_ended(install, addon) { function finish_test(count) { is(count, 1, "1 Add-on should have been successfully installed"); - Services.perms.remove(makeURI("http://example.com"), "install"); + PermissionTestUtils.remove("http://example.com", "install"); gBrowser.removeCurrentTab(); Harness.finish(); diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_newwindow.js b/toolkit/mozapps/extensions/test/xpinstall/browser_newwindow.js index f53abddcbd9b..f02adaf3f0c6 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/browser_newwindow.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_newwindow.js @@ -17,8 +17,7 @@ async function test() { win = await BrowserTestUtils.openNewBrowserWindow(); Harness.setup(win); - const pm = Services.perms; - pm.add(exampleURI, "install", pm.ALLOW_ACTION); + PermissionTestUtils.add(exampleURI, "install", Services.perms.ALLOW_ACTION); const triggers = encodeURIComponent( JSON.stringify({ @@ -45,7 +44,7 @@ function confirm_install(panel) { async function finish_test(count) { is(count, 1, "1 Add-on should have been successfully installed"); - Services.perms.remove(exampleURI, "install"); + PermissionTestUtils.remove(exampleURI, "install"); const results = await ContentTask.spawn( win.gBrowser.selectedBrowser, diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_offline.js b/toolkit/mozapps/extensions/test/xpinstall/browser_offline.js index 0dfd32bc34d8..3dfda36efed6 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/browser_offline.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_offline.js @@ -7,8 +7,11 @@ function test() { Harness.installsCompletedCallback = finish_test; Harness.setup(); - var pm = Services.perms; - pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + PermissionTestUtils.add( + "http://example.com/", + "install", + Services.perms.ALLOW_ACTION + ); var triggers = encodeURIComponent( JSON.stringify({ @@ -59,7 +62,7 @@ function finish_test(count) { Services.io.offline = false; } catch (ex) {} - Services.perms.remove(makeURI("http://example.com"), "install"); + PermissionTestUtils.remove("http://example.com", "install"); wait_for_online(); } diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_privatebrowsing.js b/toolkit/mozapps/extensions/test/xpinstall/browser_privatebrowsing.js index 7aff8213f177..ad3339a2a00e 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/browser_privatebrowsing.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_privatebrowsing.js @@ -32,8 +32,11 @@ async function test() { gPrivateWin = await BrowserTestUtils.openNewBrowserWindow({ private: true }); Harness.setup(gPrivateWin); - var pm = Services.perms; - pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + PermissionTestUtils.add( + "http://example.com/", + "install", + Services.perms.ALLOW_ACTION + ); var triggers = encodeURIComponent( JSON.stringify({ @@ -83,7 +86,7 @@ const finish_test = async function(count) { Services.obs.removeObserver(check_channel, "http-on-before-connect"); - Services.perms.remove(makeURI("http://example.com"), "install"); + PermissionTestUtils.remove("http://example.com", "install"); const results = await ContentTask.spawn( gPrivateWin.gBrowser.selectedBrowser, diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_relative.js b/toolkit/mozapps/extensions/test/xpinstall/browser_relative.js index 4ba26d41c8e5..a4700026656e 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/browser_relative.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_relative.js @@ -7,8 +7,11 @@ function test() { Harness.finalContentEvent = "InstallComplete"; Harness.setup(); - var pm = Services.perms; - pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + PermissionTestUtils.add( + "http://example.com/", + "install", + Services.perms.ALLOW_ACTION + ); var triggers = encodeURIComponent( JSON.stringify({ @@ -40,7 +43,7 @@ function install_ended(install, addon) { const finish_test = async function(count) { is(count, 1, "1 Add-on should have been successfully installed"); - Services.perms.remove(makeURI("http://example.com"), "install"); + PermissionTestUtils.remove("http://example.com", "install"); const results = await ContentTask.spawn( gBrowser.selectedBrowser, diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_signed_trigger.js b/toolkit/mozapps/extensions/test/xpinstall/browser_signed_trigger.js index 6f8ca58c32f3..3f737628768f 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/browser_signed_trigger.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_signed_trigger.js @@ -7,8 +7,11 @@ function test() { Harness.installsCompletedCallback = finish_test; Harness.setup(); - var pm = Services.perms; - pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + PermissionTestUtils.add( + "http://example.com/", + "install", + Services.perms.ALLOW_ACTION + ); var triggers = encodeURIComponent( JSON.stringify({ @@ -34,7 +37,7 @@ function install_ended(install, addon) { function finish_test(count) { is(count, 1, "1 Add-on should have been successfully installed"); - Services.perms.remove(makeURI("http://example.com"), "install"); + PermissionTestUtils.remove("http://example.com", "install"); gBrowser.removeCurrentTab(); Harness.finish(); diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_softwareupdate.js b/toolkit/mozapps/extensions/test/xpinstall/browser_softwareupdate.js index 17ec78451a7e..1d5643f5e1b4 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/browser_softwareupdate.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_softwareupdate.js @@ -5,8 +5,11 @@ function test() { Harness.installsCompletedCallback = finish_test; Harness.setup(); - var pm = Services.perms; - pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + PermissionTestUtils.add( + "http://example.com/", + "install", + Services.perms.ALLOW_ACTION + ); gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser); BrowserTestUtils.loadURI( @@ -23,7 +26,7 @@ function install_ended(install, addon) { function finish_test(count) { is(count, 1, "1 Add-on should have been successfully installed"); - Services.perms.remove(makeURI("http://example.com"), "install"); + PermissionTestUtils.remove("http://example.com", "install"); gBrowser.removeCurrentTab(); Harness.finish(); diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_trigger_redirect.js b/toolkit/mozapps/extensions/test/xpinstall/browser_trigger_redirect.js index f9206848eb65..37dbc7285cb8 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/browser_trigger_redirect.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_trigger_redirect.js @@ -7,8 +7,11 @@ function test() { Harness.finalContentEvent = "InstallComplete"; Harness.setup(); - var pm = Services.perms; - pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + PermissionTestUtils.add( + "http://example.com/", + "install", + Services.perms.ALLOW_ACTION + ); gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser); BrowserTestUtils.loadURI(gBrowser, TESTROOT + "triggerredirect.html"); @@ -26,7 +29,7 @@ function install_ended(install, addon) { function finish_test(count) { is(count, 1, "1 Add-on should have been successfully installed"); - Services.perms.remove(makeURI("http://example.com"), "install"); + PermissionTestUtils.remove("http://example.com", "install"); is( gBrowser.currentURI.spec, diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_unsigned_trigger.js b/toolkit/mozapps/extensions/test/xpinstall/browser_unsigned_trigger.js index 648efb5b7eb2..382b094784d3 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/browser_unsigned_trigger.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_unsigned_trigger.js @@ -8,8 +8,11 @@ function test() { Harness.finalContentEvent = "InstallComplete"; Harness.setup(); - var pm = Services.perms; - pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + PermissionTestUtils.add( + "http://example.com/", + "install", + Services.perms.ALLOW_ACTION + ); var triggers = encodeURIComponent( JSON.stringify({ @@ -41,7 +44,7 @@ function install_ended(install, addon) { const finish_test = async function(count) { is(count, 1, "1 Add-on should have been successfully installed"); - Services.perms.remove(makeURI("http://example.com"), "install"); + PermissionTestUtils.remove("http://example.com", "install"); const results = await ContentTask.spawn( gBrowser.selectedBrowser, diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_unsigned_trigger_iframe.js b/toolkit/mozapps/extensions/test/xpinstall/browser_unsigned_trigger_iframe.js index a33d52a4c7a0..da82f1855f7a 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/browser_unsigned_trigger_iframe.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_unsigned_trigger_iframe.js @@ -9,8 +9,11 @@ function test() { Harness.finalContentEvent = "InstallComplete"; Harness.setup(); - var pm = Services.perms; - pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + PermissionTestUtils.add( + "http://example.com/", + "install", + Services.perms.ALLOW_ACTION + ); var inner_url = encodeURIComponent( TESTROOT + @@ -46,7 +49,7 @@ function install_ended(install, addon) { const finish_test = async function(count) { is(count, 1, "1 Add-on should have been successfully installed"); - Services.perms.remove(makeURI("http://example.com"), "install"); + PermissionTestUtils.remove("http://example.com", "install"); const results = await ContentTask.spawn( gBrowser.selectedBrowser, diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_unsigned_trigger_xorigin.js b/toolkit/mozapps/extensions/test/xpinstall/browser_unsigned_trigger_xorigin.js index 442c43d9ea1a..bdf6194ea0e9 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/browser_unsigned_trigger_xorigin.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_unsigned_trigger_xorigin.js @@ -9,8 +9,11 @@ function test() { Harness.finalContentEvent = "InstallComplete"; Harness.setup(); - var pm = Services.perms; - pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + PermissionTestUtils.add( + "http://example.com/", + "install", + Services.perms.ALLOW_ACTION + ); var inner_url = encodeURIComponent( TESTROOT + @@ -45,7 +48,7 @@ function finish_test(count) { ); is(count, 0, "No add-ons should have been installed"); - Services.perms.remove(makeURI("http://example.com"), "install"); + PermissionTestUtils.remove("http://example.com", "install"); gBrowser.removeCurrentTab(); Harness.finish(); diff --git a/toolkit/mozapps/extensions/test/xpinstall/head.js b/toolkit/mozapps/extensions/test/xpinstall/head.js index db5c34d3b276..56d88c75e06e 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/head.js +++ b/toolkit/mozapps/extensions/test/xpinstall/head.js @@ -1,5 +1,9 @@ /* eslint no-unused-vars: ["error", {vars: "local", args: "none"}] */ +const { PermissionTestUtils } = ChromeUtils.import( + "resource://testing-common/PermissionTestUtils.jsm" +); + const RELATIVE_DIR = "toolkit/mozapps/extensions/test/xpinstall/"; const TESTROOT = "http://example.com/browser/" + RELATIVE_DIR;