Bug 1318491 - Disable new tab longpress containers menu for private browsing mode draft
authorJonathan Kingston <jkt@mozilla.com>
Thu, 24 Nov 2016 13:45:06 +0000
changeset 445851 7074c0567ea2bc0893d22007392590eb364a3463
parent 445848 13736e2db6eb94b02dd28cc88f2943b8109aa374
child 538648 dccbb6d855fc50a8d970411865f3d49f860a0683
push id37640
push userjkingston@mozilla.com
push dateWed, 30 Nov 2016 12:08:48 +0000
bugs1318491
milestone53.0a1
Bug 1318491 - Disable new tab longpress containers menu for private browsing mode 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);
+});