Bug 1318491 - Disable new tab longpress containers menu for private browsing mode r=Gijs
authorJonathan Kingston <jkt@mozilla.com>
Thu, 24 Nov 2016 13:45:06 +0000
changeset 324854 a37d5a9d30fc4d5c31fce00fbf4b169d3db6d30d
parent 324853 e26b6b6d7d9800539151a781a684e22f525b7a57
child 324855 176260cf74af539eb25adcbedb9e7132657df22e
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersGijs
bugs1318491
milestone53.0a1
Bug 1318491 - Disable new tab longpress containers menu for private browsing mode r=Gijs MozReview-Commit-ID: Ldmya1q7eO9
browser/base/content/tabbrowser.xml
browser/components/contextualidentity/test/browser/browser_newtabButton.js
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -5396,17 +5396,18 @@
       <method name="observe">
         <parameter name="aSubject"/>
         <parameter name="aTopic"/>
         <parameter name="aData"/>
         <body><![CDATA[
           switch (aTopic) {
             case "nsPref:changed":
               // This is the only pref observed.
-              let containersEnabled = Services.prefs.getBoolPref("privacy.userContext.enabled");
+              let containersEnabled = Services.prefs.getBoolPref("privacy.userContext.enabled")
+                                        && !PrivateBrowsingUtils.isWindowPrivate(window);
 
               const newTab = document.getElementById("new-tab-button");
               const newTab2 = document.getAnonymousElementByAttribute(this, "anonid", "tabs-newtab-button")
 
               if (containersEnabled) {
                 for (let parent of [newTab, newTab2]) {
                   if (!parent)
                     continue;
--- a/browser/components/contextualidentity/test/browser/browser_newtabButton.js
+++ b/browser/components/contextualidentity/test/browser/browser_newtabButton.js
@@ -28,8 +28,23 @@ add_task(function* test() {
     EventUtils.synthesizeMouseAtCenter(contextIdItem, {});
 
     let tab = yield waitForTabPromise;
 
     is(tab.getAttribute('usercontextid'), i, `New tab has UCI equal ${i}`);
     yield BrowserTestUtils.removeTab(tab);
   }
 });
+
+
+add_task(function* test_private_mode() {
+  let privateWindow = yield BrowserTestUtils.openNewBrowserWindow({private: true});
+  let privateDocument = privateWindow.document;
+  let {tabContainer} = privateWindow.gBrowser;
+  let newTab = privateDocument.getAnonymousElementByAttribute(tabContainer, "anonid", "tabs-newtab-button");
+  let newTab2 = privateDocument.getElementById("new-tab-button");
+  // Check to ensure we are talking about the right button
+  ok(!!newTab.clientWidth, "new tab button should not be hidden");
+  ok(!newTab2.clientWidth, "overflow new tab button should be hidden");
+  let popup = privateDocument.getAnonymousElementByAttribute(newTab, "anonid", "newtab-popup");
+  ok(!popup, "new tab should not have a popup");
+  yield BrowserTestUtils.closeWindow(privateWindow);
+});