Bug 1520436 - part2 : modify test. r=johannh
☠☠ backed out by 1136af68ddae ☠ ☠
authoralwu <alwu@mozilla.com>
Tue, 22 Jan 2019 18:16:52 +0000
changeset 514941 4752a33b4c3ac775977b7e97d992d29c7ce2b110
parent 514940 10716b2122dc152763b64e5fccd43ea1bdee239e
child 514942 fb80118393dc7ab2c942eeeaf5a600221e47b716
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjohannh
bugs1520436
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1520436 - part2 : modify test. r=johannh Differential Revision: https://phabricator.services.mozilla.com/D16771
browser/base/content/test/permissions/browser_permissions.js
browser/modules/test/browser/browser_SitePermissions.js
--- a/browser/base/content/test/permissions/browser_permissions.js
+++ b/browser/base/content/test/permissions/browser_permissions.js
@@ -84,34 +84,46 @@ add_task(async function testIdentityIcon
   });
 });
 
 add_task(async function testCancelPermission() {
   await BrowserTestUtils.withNewTab(PERMISSIONS_PAGE, async function() {
     let permissionsList = document.getElementById("identity-popup-permission-list");
     let emptyLabel = permissionsList.nextElementSibling.nextElementSibling;
 
+    await SpecialPowers.pushPrefEnv({set: [
+      ["media.autoplay.default", SpecialPowers.Ci.nsIAutoplay.BLOCKED],
+    ]});
+
     SitePermissions.set(gBrowser.currentURI, "geo", SitePermissions.ALLOW);
-    SitePermissions.set(gBrowser.currentURI, "camera", SitePermissions.BLOCK);
+    SitePermissions.set(gBrowser.currentURI, "autoplay-media", SitePermissions.ALLOW);
 
     await openIdentityPopup();
 
     ok(BrowserTestUtils.is_hidden(emptyLabel), "List of permissions is not empty");
 
     let cancelButtons = permissionsList
       .querySelectorAll(".identity-popup-permission-remove-button");
 
     cancelButtons[0].click();
     let labels = permissionsList.querySelectorAll(".identity-popup-permission-label");
     is(labels.length, 1, "One permission should be removed");
+    is(cancelButtons[0].getAttribute("tooltiptext"),
+       gBrowserBundle.GetStringFromName("permissions.remove.tooltip"),
+       "tooltip text for promptable permission is correct");
+
     cancelButtons[1].click();
     labels = permissionsList.querySelectorAll(".identity-popup-permission-label");
     is(labels.length, 0, "One permission should be removed");
+    is(cancelButtons[1].getAttribute("tooltiptext"),
+       gBrowserBundle.GetStringFromName("permissions.remove.tooltip.noPrompt"),
+       "tooltip text for non-promptable is correct");
 
     await closeIdentityPopup();
+    await SpecialPowers.popPrefEnv();
   });
 });
 
 add_task(async function testPermissionHints() {
   await BrowserTestUtils.withNewTab(PERMISSIONS_PAGE, async function(browser) {
     let permissionsList = document.getElementById("identity-popup-permission-list");
     let emptyHint = document.getElementById("identity-popup-permission-empty-hint");
     let reloadHint = document.getElementById("identity-popup-permission-reload-hint");
--- a/browser/modules/test/browser/browser_SitePermissions.js
+++ b/browser/modules/test/browser/browser_SitePermissions.js
@@ -27,67 +27,84 @@ add_task(async function testGetAllPermis
 
   Services.prefs.setIntPref("permissions.default.shortcuts", 2);
 
   SitePermissions.set(uri, "camera", SitePermissions.ALLOW);
   SitePermissions.set(uri, "cookie", SitePermissions.ALLOW_COOKIES_FOR_SESSION);
   SitePermissions.set(uri, "popup", SitePermissions.BLOCK);
   SitePermissions.set(uri, "geo", SitePermissions.ALLOW, SitePermissions.SCOPE_SESSION);
   SitePermissions.set(uri, "shortcuts", SitePermissions.ALLOW);
+  SitePermissions.set(uri, "autoplay-media", SitePermissions.BLOCK);
 
   let permissions = SitePermissions.getAllPermissionDetailsForBrowser(tab.linkedBrowser);
 
   let camera = permissions.find(({id}) => id === "camera");
   Assert.deepEqual(camera, {
     id: "camera",
     label: "Use the Camera",
     state: SitePermissions.ALLOW,
     scope: SitePermissions.SCOPE_PERSISTENT,
+    isPromptable: true,
   });
 
   // Check that removed permissions (State.UNKNOWN) are skipped.
   SitePermissions.remove(uri, "camera");
   permissions = SitePermissions.getAllPermissionDetailsForBrowser(tab.linkedBrowser);
 
   camera = permissions.find(({id}) => id === "camera");
   Assert.equal(camera, undefined);
 
   let cookie = permissions.find(({id}) => id === "cookie");
   Assert.deepEqual(cookie, {
     id: "cookie",
     label: "Set Cookies",
     state: SitePermissions.ALLOW_COOKIES_FOR_SESSION,
     scope: SitePermissions.SCOPE_PERSISTENT,
+    isPromptable: true,
   });
 
   let popup = permissions.find(({id}) => id === "popup");
   Assert.deepEqual(popup, {
     id: "popup",
     label: "Open Pop-up Windows",
     state: SitePermissions.BLOCK,
     scope: SitePermissions.SCOPE_PERSISTENT,
+    isPromptable: true,
   });
 
   let geo = permissions.find(({id}) => id === "geo");
   Assert.deepEqual(geo, {
     id: "geo",
     label: "Access Your Location",
     state: SitePermissions.ALLOW,
     scope: SitePermissions.SCOPE_SESSION,
+    isPromptable: true,
   });
 
   let shortcuts = permissions.find(({id}) => id === "shortcuts");
   Assert.deepEqual(shortcuts, {
     id: "shortcuts",
     label: "Override Keyboard Shortcuts",
     state: SitePermissions.ALLOW,
     scope: SitePermissions.SCOPE_PERSISTENT,
+    isPromptable: true,
   });
 
+  let autoplay = permissions.find(({id}) => id === "autoplay-media");
+  Assert.deepEqual(autoplay, {
+    id: "autoplay-media",
+    label: "Automatically Play Media with Sound",
+    state: SitePermissions.BLOCK,
+    scope: SitePermissions.SCOPE_PERSISTENT,
+    isPromptable: false,
+  });
+
+
   SitePermissions.remove(uri, "cookie");
   SitePermissions.remove(uri, "popup");
   SitePermissions.remove(uri, "geo");
   SitePermissions.remove(uri, "shortcuts");
+  SitePermissions.remove(uri, "autoplay-media");
 
   Services.prefs.clearUserPref("permissions.default.shortcuts");
 
   BrowserTestUtils.removeTab(gBrowser.selectedTab);
 });