Bug 1331921 - Hide temporary permissions on tab reload through the context menu. r=florian
authorJohann Hofmann <jhofmann@mozilla.com>
Fri, 20 Jan 2017 10:17:43 +0100
changeset 464578 ea5dac2d3a458a09bf0df4ee8e8b8c8c07a0b7d7
parent 464577 bdfebb742afe2d328e63fefb08ba283cc95718e7
child 464579 772c8d7a210c803b8c5adbc03be7a5c1107a82d4
push id42370
push usermwein@mozilla.com
push dateSat, 21 Jan 2017 03:10:58 +0000
reviewersflorian
bugs1331921
milestone53.0a1
Bug 1331921 - Hide temporary permissions on tab reload through the context menu. r=florian MozReview-Commit-ID: 6CbhisP94PT
browser/base/content/tabbrowser.xml
browser/base/content/test/general/browser_temporary_permissions_navigation.js
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -3086,17 +3086,21 @@
           ]]>
         </body>
       </method>
 
       <method name="reloadTab">
         <parameter name="aTab"/>
         <body>
           <![CDATA[
-            this.getBrowserForTab(aTab).reload();
+            let browser = this.getBrowserForTab(aTab);
+            // Reset temporary permissions on the current tab. This is done here
+            // because we only want to reset permissions on user reload.
+            SitePermissions.clearTemporaryPermissions(browser);
+            browser.reload();
           ]]>
         </body>
       </method>
 
       <method name="addProgressListener">
         <parameter name="aListener"/>
         <body>
           <![CDATA[
--- a/browser/base/content/test/general/browser_temporary_permissions_navigation.js
+++ b/browser/base/content/test/general/browser_temporary_permissions_navigation.js
@@ -30,19 +30,46 @@ add_task(function* testTempPermissionOnR
       return reloadButton.disabled == false;
     });
 
     Assert.deepEqual(SitePermissions.get(uri, id, browser), {
       state: SitePermissions.BLOCK,
       scope: SitePermissions.SCOPE_TEMPORARY,
     });
 
+    reloaded = BrowserTestUtils.browserLoaded(browser, false, uri.spec);
+
     // Reload as a user (should remove the temp permission).
     EventUtils.synthesizeMouseAtCenter(reloadButton, {});
 
+    yield reloaded;
+
+    Assert.deepEqual(SitePermissions.get(uri, id, browser), {
+      state: SitePermissions.UNKNOWN,
+      scope: SitePermissions.SCOPE_PERSISTENT,
+    });
+
+    // Set the permission again.
+    SitePermissions.set(uri, id, SitePermissions.BLOCK, SitePermissions.SCOPE_TEMPORARY, browser);
+
+    // Open the tab context menu.
+    let contextMenu = document.getElementById("tabContextMenu");
+    let popupShownPromise = BrowserTestUtils.waitForEvent(contextMenu, "popupshown");
+    EventUtils.synthesizeMouseAtCenter(gBrowser.selectedTab, {type: "contextmenu", button: 2});
+    yield popupShownPromise;
+
+    let reloadMenuItem = document.getElementById("context_reloadTab");
+
+    reloaded = BrowserTestUtils.browserLoaded(browser, false, uri.spec);
+
+    // Reload as a user through the context menu (should remove the temp permission).
+    EventUtils.synthesizeMouseAtCenter(reloadMenuItem, {});
+
+    yield reloaded;
+
     Assert.deepEqual(SitePermissions.get(uri, id, browser), {
       state: SitePermissions.UNKNOWN,
       scope: SitePermissions.SCOPE_PERSISTENT,
     });
 
     SitePermissions.remove(uri, id, browser);
   });
 });