Bug 1318491 - Disable new tab longpress containers menu for private browsing mode
MozReview-Commit-ID: Ldmya1q7eO9
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -5370,17 +5370,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,19 @@ 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 newTab = privateDocument.getElementById('tabbrowser-tabs');
+ ok(!newTab.hidden, "new tabs should not be hidden");
+ let popup = privateDocument.getAnonymousElementByAttribute(newTab, "anonid", "newtab-popup");
+ ok(!popup, "new tab should not have a popup");
+ yield BrowserTestUtils.closeWindow(privateWindow);
+});