Bug 1661517 - Removed extensions.allowPrivateBrowsingByDefault preference. r=mixedpuppy

Differential Revision: https://phabricator.services.mozilla.com/D97094
This commit is contained in:
Sonia Singla 2021-06-02 21:48:05 +00:00
Родитель cba669901b
Коммит c2ffd0413b
48 изменённых файлов: 160 добавлений и 388 удалений

Просмотреть файл

@ -72,7 +72,6 @@ add_task(async function test_sideloading() {
["xpinstall.signatures.required", false],
["extensions.autoDisableScopes", 15],
["extensions.ui.ignoreUnsigned", true],
["extensions.allowPrivateBrowsingByDefault", false],
],
});

Просмотреть файл

@ -2,12 +2,6 @@
/* vim: set sts=2 sw=2 et tw=80: */
"use strict";
add_task(async function setup() {
await SpecialPowers.pushPrefEnv({
set: [["extensions.allowPrivateBrowsingByDefault", false]],
});
});
async function testIncognito(incognitoOverride) {
let extension = ExtensionTestUtils.loadExtension({
manifest: {

Просмотреть файл

@ -10,6 +10,7 @@ const { XPCOMUtils } = ChromeUtils.import(
XPCOMUtils.defineLazyModuleGetters(this, {
AddonManager: "resource://gre/modules/AddonManager.jsm",
ExtensionSettingsStore: "resource://gre/modules/ExtensionSettingsStore.jsm",
HomePage: "resource:///modules/HomePage.jsm",
});
ChromeUtils.defineModuleGetter(
@ -543,12 +544,35 @@ add_task(async function test_doorhanger_new_window() {
// Skipping for window leak in debug builds, follow up bug: 1678412
}).skip(AppConstants.DEBUG);
async function testHomePageWindow(options = {}) {
let windowOpenedPromise = BrowserTestUtils.waitForNewWindow();
let win = OpenBrowserWindow(options.options);
let openHomepage = TestUtils.topicObserved("browser-open-homepage-start");
await windowOpenedPromise;
let doc = win.document;
let panel = ExtensionControlledPopup._getAndMaybeCreatePanel(doc);
let popupShown = options.expectPanel && promisePopupShown(panel);
win.BrowserHome();
await Promise.all([
BrowserTestUtils.browserLoaded(win.gBrowser.selectedBrowser),
openHomepage,
popupShown,
]);
await options.test(win);
if (options.expectPanel) {
let popupHidden = promisePopupHidden(panel);
panel.hidePopup();
await popupHidden;
}
await BrowserTestUtils.closeWindow(win);
}
add_task(async function test_overriding_home_page_incognito_not_allowed() {
await SpecialPowers.pushPrefEnv({
set: [
["extensions.allowPrivateBrowsingByDefault", false],
["browser.startup.page", 1],
],
set: [["browser.startup.page", 1]],
});
let extension = ExtensionTestUtils.loadExtension({
@ -556,60 +580,58 @@ add_task(async function test_overriding_home_page_incognito_not_allowed() {
chrome_settings_overrides: { homepage: "home.html" },
name: "extension",
},
background() {
browser.test.sendMessage("url", browser.runtime.getURL("home.html"));
},
files: { "home.html": "<h1>1</h1>" },
useAddonManager: "temporary",
});
await extension.startup();
let url = await extension.awaitMessage("url");
let url = `moz-extension://${extension.uuid}/home.html`;
let windowOpenedPromise = BrowserTestUtils.waitForNewWindow({ url });
let win = OpenBrowserWindow();
await testHomePageWindow({
expectPanel: true,
test(win) {
let doc = win.document;
let description = doc.getElementById(
"extension-homepage-notification-description"
);
let popupnotification = description.closest("popupnotification");
is(
description.textContent,
"An extension, extension, changed what you see when you open your homepage and new windows.Learn more",
"The extension name is in the popup"
);
is(
popupnotification.hidden,
false,
"The expected popup notification is visible"
);
await windowOpenedPromise;
let doc = win.document;
let panel = ExtensionControlledPopup._getAndMaybeCreatePanel(doc);
await promisePopupShown(panel);
Assert.equal(HomePage.get(win), url, "The homepage is not set");
Assert.equal(
win.gURLBar.value,
url,
"home page not used in private window"
);
},
});
let description = doc.getElementById(
"extension-homepage-notification-description"
);
let popupnotification = description.closest("popupnotification");
is(
description.textContent,
"An extension, extension, changed what you see when you open your homepage and new windows.Learn more",
"The extension name is in the popup"
);
is(
popupnotification.hidden,
false,
"The expected popup notification is visible"
);
ok(win.gURLBar.value.endsWith("home.html"), "extension is in control");
await BrowserTestUtils.closeWindow(win);
// Verify a private window does not open the extension page.
windowOpenedPromise = BrowserTestUtils.waitForNewWindow();
win = OpenBrowserWindow({ private: true });
await windowOpenedPromise;
win.BrowserHome();
await BrowserTestUtils.browserLoaded(win.gBrowser.selectedBrowser);
is(win.gURLBar.value, "", "home page not used in private window");
await testHomePageWindow({
expectPanel: false,
options: { private: true },
test(win) {
Assert.notEqual(HomePage.get(win), url, "The homepage is not set");
Assert.notEqual(
win.gURLBar.value,
url,
"home page not used in private window"
);
},
});
await extension.unload();
await BrowserTestUtils.closeWindow(win);
});
add_task(async function test_overriding_home_page_incognito_spanning() {
await SpecialPowers.pushPrefEnv({
set: [["extensions.allowPrivateBrowsingByDefault", false]],
});
let extension = ExtensionTestUtils.loadExtension({
manifest: {
chrome_settings_overrides: { homepage: "home.html" },
@ -625,62 +647,73 @@ add_task(async function test_overriding_home_page_incognito_spanning() {
await extension.startup();
let windowOpenedPromise = BrowserTestUtils.waitForNewWindow();
let win = OpenBrowserWindow({ private: true });
await windowOpenedPromise;
let doc = win.document;
let panel = ExtensionControlledPopup._getAndMaybeCreatePanel(doc);
let popupShown = promisePopupShown(panel);
win.BrowserHome();
await BrowserTestUtils.browserLoaded(win.gBrowser.selectedBrowser);
await popupShown;
ok(getHomePageURL().endsWith("home.html"), "The homepage is set");
ok(
win.gURLBar.value.endsWith("home.html"),
"extension is in control in private window"
);
let popupHidden = promisePopupHidden(panel);
panel.hidePopup();
await popupHidden;
// private window uses extension homepage
await testHomePageWindow({
expectPanel: true,
options: { private: true },
test(win) {
Assert.equal(
HomePage.get(win),
`moz-extension://${extension.uuid}/home.html`,
"The homepage is set"
);
Assert.equal(
win.gURLBar.value,
`moz-extension://${extension.uuid}/home.html`,
"extension is control in window"
);
},
});
await extension.unload();
await BrowserTestUtils.closeWindow(win);
});
add_task(async function test_overriding_home_page_incognito_external() {
await SpecialPowers.pushPrefEnv({
set: [["extensions.allowPrivateBrowsingByDefault", false]],
});
let extension = ExtensionTestUtils.loadExtension({
manifest: {
chrome_settings_overrides: { homepage: "https://example.com/home.html" },
chrome_settings_overrides: { homepage: "/home.html" },
name: "extension",
},
useAddonManager: "temporary",
files: { "home.html": "<h1>non-private home</h1>" },
});
await extension.startup();
// Verify a private window does not open the extension page.
let windowOpenedPromise = BrowserTestUtils.waitForNewWindow();
let win = OpenBrowserWindow({ private: true });
await windowOpenedPromise;
let openHomepage = TestUtils.topicObserved("browser-open-homepage-start");
win.BrowserHome();
await BrowserTestUtils.browserLoaded(win.gBrowser.selectedBrowser);
await openHomepage;
// non-private window uses extension homepage
await testHomePageWindow({
expectPanel: true,
test(win) {
Assert.equal(
HomePage.get(win),
`moz-extension://${extension.uuid}/home.html`,
"The homepage is set"
);
Assert.equal(
win.gURLBar.value,
`moz-extension://${extension.uuid}/home.html`,
"extension is control in window"
);
},
});
is(win.gURLBar.value, "", "home page not used in private window");
is(
win.gBrowser.selectedBrowser.currentURI.spec,
"about:home",
"home page not used in private window"
);
// private window does not use extension window
await testHomePageWindow({
expectPanel: false,
options: { private: true },
test(win) {
Assert.notEqual(
HomePage.get(win),
`moz-extension://${extension.uuid}/home.html`,
"The homepage is not set"
);
Assert.notEqual(
win.gURLBar.value,
`moz-extension://${extension.uuid}/home.html`,
"home page not used in private window"
);
},
});
await extension.unload();
await BrowserTestUtils.closeWindow(win);
});

Просмотреть файл

@ -3,10 +3,6 @@
"use strict";
add_task(async function test_user_defined_commands() {
await SpecialPowers.pushPrefEnv({
set: [["extensions.allowPrivateBrowsingByDefault", false]],
});
const testCommands = [
// Ctrl Shortcuts
{

Просмотреть файл

@ -4,12 +4,6 @@
loadTestSubscript("head_devtools.js");
add_task(async function setup() {
await SpecialPowers.pushPrefEnv({
set: [["extensions.allowPrivateBrowsingByDefault", false]],
});
});
async function testIncognito(incognitoOverride) {
let privateAllowed = incognitoOverride == "spanning";

Просмотреть файл

@ -380,10 +380,6 @@ add_task(async function testAboutFind() {
});
add_task(async function testIncognitoFind() {
await SpecialPowers.pushPrefEnv({
set: [["extensions.allowPrivateBrowsingByDefault", false]],
});
async function background() {
await browser.test.assertRejects(
browser.find.find("banana"),
@ -427,10 +423,6 @@ add_task(async function testIncognitoFind() {
});
add_task(async function testIncognitoFindAllowed() {
await SpecialPowers.pushPrefEnv({
set: [["extensions.allowPrivateBrowsingByDefault", false]],
});
// We're only testing we can make the calls in a private window,
// testFind above tests full functionality.
async function background() {

Просмотреть файл

@ -138,10 +138,6 @@ add_task(async function testIncognitoPopup() {
});
add_task(async function test_pageAction_incognito_not_allowed() {
SpecialPowers.pushPrefEnv({
set: [["extensions.allowPrivateBrowsingByDefault", false]],
});
const URL = "https://example.com/";
let extension = ExtensionTestUtils.loadExtension({
manifest: {

Просмотреть файл

@ -2,10 +2,6 @@
// Make sure that we won't trigger events for a private window.
add_task(async function test_no_show_hide_for_private_window() {
await SpecialPowers.pushPrefEnv({
set: [["extensions.allowPrivateBrowsingByDefault", false]],
});
function background() {
let events = [];
browser.menus.onShown.addListener(data => events.push(data));

Просмотреть файл

@ -97,10 +97,6 @@ add_task(async function test_sessions_forget_closed_tab() {
});
add_task(async function test_sessions_forget_closed_tab_private() {
SpecialPowers.pushPrefEnv({
set: [["extensions.allowPrivateBrowsingByDefault", false]],
});
let pb_extension = getExtension("spanning");
await pb_extension.startup();
let extension = getExtension();

Просмотреть файл

@ -93,10 +93,6 @@ add_task(async function test_sessions_forget_closed_window() {
});
add_task(async function test_sessions_forget_closed_window_private() {
SpecialPowers.pushPrefEnv({
set: [["extensions.allowPrivateBrowsingByDefault", false]],
});
let pb_extension = getExtension("spanning");
await pb_extension.startup();
let extension = getExtension("not_allowed");

Просмотреть файл

@ -60,7 +60,8 @@ async function run_test_extension(incognitoOverride) {
extension.sendMessage("check-sessions");
recentlyClosed = await extension.awaitMessage("recentlyClosed");
let expectedCount = incognitoOverride == "not_allowed" ? 0 : 2;
let expectedCount =
!incognitoOverride || incognitoOverride == "not_allowed" ? 0 : 2;
checkRecentlyClosed(
recentlyClosed.filter(onlyNewItemsFilter),
expectedCount,
@ -83,18 +84,10 @@ async function run_test_extension(incognitoOverride) {
}
add_task(async function test_sessions_get_recently_closed_default() {
SpecialPowers.pushPrefEnv({
set: [["extensions.allowPrivateBrowsingByDefault", true]],
});
await run_test_extension();
});
add_task(async function test_sessions_get_recently_closed_private_incognito() {
SpecialPowers.pushPrefEnv({
set: [["extensions.allowPrivateBrowsingByDefault", false]],
});
await run_test_extension("spanning");
await run_test_extension("not_allowed");
});

Просмотреть файл

@ -8,10 +8,6 @@ add_task(async function test_sessions_tab_value_private() {
"No closed window sessions at start of test"
);
SpecialPowers.pushPrefEnv({
set: [["extensions.allowPrivateBrowsingByDefault", false]],
});
let extension = ExtensionTestUtils.loadExtension({
manifest: {
applications: {

Просмотреть файл

@ -3,10 +3,6 @@
"use strict";
add_task(async function test_sidebarAction_not_allowed() {
await SpecialPowers.pushPrefEnv({
set: [["extensions.allowPrivateBrowsingByDefault", false]],
});
let extension = ExtensionTestUtils.loadExtension({
manifest: {
sidebar_action: {

Просмотреть файл

@ -6,9 +6,6 @@
// incognito data in event listeners it will fail.
let monitor;
add_task(async function startup() {
SpecialPowers.pushPrefEnv({
set: [["extensions.allowPrivateBrowsingByDefault", false]],
});
monitor = await startIncognitoMonitorExtension();
});
registerCleanupFunction(async function finish() {

Просмотреть файл

@ -3,10 +3,6 @@
"use strict";
add_task(async function testExecuteScriptIncognitoNotAllowed() {
SpecialPowers.pushPrefEnv({
set: [["extensions.allowPrivateBrowsingByDefault", false]],
});
const url =
"http://mochi.test:8888/browser/browser/components/extensions/test/browser/file_iframe_document.html";

Просмотреть файл

@ -8,9 +8,6 @@ const SITE_SPECIFIC_PREF = "browser.zoom.siteSpecific";
// incognito data in event listeners it will fail.
let monitor;
add_task(async function startup() {
SpecialPowers.pushPrefEnv({
set: [["extensions.allowPrivateBrowsingByDefault", false]],
});
monitor = await startIncognitoMonitorExtension();
});
registerCleanupFunction(async function finish() {

Просмотреть файл

@ -621,10 +621,6 @@ add_task(async function dontTemporarilyShowAboutExtensionPath() {
});
add_task(async function test_overriding_newtab_incognito_not_allowed() {
await SpecialPowers.pushPrefEnv({
set: [["extensions.allowPrivateBrowsingByDefault", false]],
});
let panel = getNewTabDoorhanger().closest("panel");
let extension = ExtensionTestUtils.loadExtension({
@ -670,10 +666,6 @@ add_task(async function test_overriding_newtab_incognito_not_allowed() {
});
add_task(async function test_overriding_newtab_incognito_spanning() {
await SpecialPowers.pushPrefEnv({
set: [["extensions.allowPrivateBrowsingByDefault", false]],
});
let extension = ExtensionTestUtils.loadExtension({
...extensionData,
useAddonManager: "permanent",

Просмотреть файл

@ -5,9 +5,6 @@
SimpleTest.requestCompleteLog();
add_task(async function test_windows_events_not_allowed() {
SpecialPowers.pushPrefEnv({
set: [["extensions.allowPrivateBrowsingByDefault", false]],
});
let monitor = await startIncognitoMonitorExtension();
function background() {

Просмотреть файл

@ -3,10 +3,6 @@
"use strict";
add_task(async function test_window_incognito() {
SpecialPowers.pushPrefEnv({
set: [["extensions.allowPrivateBrowsingByDefault", false]],
});
const url =
"http://mochi.test:8888/browser/browser/components/extensions/test/browser/file_iframe_document.html";

Просмотреть файл

@ -25,7 +25,6 @@ const HOMEPAGE_URL_PREF = "browser.startup.homepage";
const HOMEPAGE_URI = "webext-homepage-1.html";
Services.prefs.setBoolPref("browser.privatebrowsing.autostart", true);
Services.prefs.setBoolPref("extensions.allowPrivateBrowsingByDefault", false);
AddonTestUtils.init(this);
AddonTestUtils.usePrivilegedSignatures = false;

Просмотреть файл

@ -3915,12 +3915,6 @@
# Prefs starting with "extensions."
#---------------------------------------------------------------------------
# Private browsing opt-in is only supported on Firefox desktop.
- name: extensions.allowPrivateBrowsingByDefault
type: bool
value: false
mirror: always
# Whether the background.service_worker in the extension manifest.json file
# is enabled.
- name: extensions.backgroundServiceWorker.enabled

Просмотреть файл

@ -111,13 +111,6 @@ XPCOMUtils.defineLazyPreferenceGetter(
);
// Temporary pref to be turned on when ready.
XPCOMUtils.defineLazyPreferenceGetter(
this,
"allowPrivateBrowsingByDefault",
"extensions.allowPrivateBrowsingByDefault",
true
);
XPCOMUtils.defineLazyPreferenceGetter(
this,
"userContextIsolation",
@ -970,16 +963,6 @@ class ExtensionData {
this.manifest = manifest;
this.rawManifest = manifest;
if (
allowPrivateBrowsingByDefault &&
"incognito" in manifest &&
manifest.incognito == "not_allowed"
) {
throw new Error(
`manifest.incognito set to "not_allowed" is currently unvailable for use.`
);
}
if (manifest && manifest.default_locale) {
await this.initLocale();
}
@ -2622,32 +2605,30 @@ class Extension extends ExtensionData {
// We automatically add permissions to system/built-in extensions.
// Extensions expliticy stating not_allowed will never get permission.
if (!allowPrivateBrowsingByDefault) {
let isAllowed = this.permissions.has(PRIVATE_ALLOWED_PERMISSION);
if (this.manifest.incognito === "not_allowed") {
// If an extension previously had permission, but upgrades/downgrades to
// a version that specifies "not_allowed" in manifest, remove the
// permission.
if (isAllowed) {
ExtensionPermissions.remove(this.id, {
permissions: [PRIVATE_ALLOWED_PERMISSION],
origins: [],
});
this.permissions.delete(PRIVATE_ALLOWED_PERMISSION);
}
} else if (
!isAllowed &&
this.isPrivileged &&
!this.addonData.temporarilyInstalled
) {
// Add to EP so it is preserved after ADDON_INSTALL. We don't wait on the add here
// since we are pushing the value into this.permissions. EP will eventually save.
ExtensionPermissions.add(this.id, {
let isAllowed = this.permissions.has(PRIVATE_ALLOWED_PERMISSION);
if (this.manifest.incognito === "not_allowed") {
// If an extension previously had permission, but upgrades/downgrades to
// a version that specifies "not_allowed" in manifest, remove the
// permission.
if (isAllowed) {
ExtensionPermissions.remove(this.id, {
permissions: [PRIVATE_ALLOWED_PERMISSION],
origins: [],
});
this.permissions.add(PRIVATE_ALLOWED_PERMISSION);
this.permissions.delete(PRIVATE_ALLOWED_PERMISSION);
}
} else if (
!isAllowed &&
this.isPrivileged &&
!this.addonData.temporarilyInstalled
) {
// Add to EP so it is preserved after ADDON_INSTALL. We don't wait on the add here
// since we are pushing the value into this.permissions. EP will eventually save.
ExtensionPermissions.add(this.id, {
permissions: [PRIVATE_ALLOWED_PERMISSION],
origins: [],
});
this.permissions.add(PRIVATE_ALLOWED_PERMISSION);
}
// We only want to update the SVG_CONTEXT_PROPERTIES_PERMISSION during install and

Просмотреть файл

@ -174,10 +174,6 @@ WebExtensionPolicy::WebExtensionPolicy(GlobalObject& aGlobal,
mLocalizeCallback(aInit.mLocalizeCallback),
mIsPrivileged(aInit.mIsPrivileged),
mPermissions(new AtomSet(aInit.mPermissions)) {
// We set this here to prevent this policy changing after creation.
mAllowPrivateBrowsingByDefault =
StaticPrefs::extensions_allowPrivateBrowsingByDefault();
MatchPatternOptions options;
options.mRestrictSchemes = !HasPermission(nsGkAtoms::mozillaAddons);
@ -546,8 +542,7 @@ void WebExtensionPolicy::GetContentScripts(
}
bool WebExtensionPolicy::PrivateBrowsingAllowed() const {
return mAllowPrivateBrowsingByDefault ||
HasPermission(nsGkAtoms::privateBrowsingAllowedPermission);
return HasPermission(nsGkAtoms::privateBrowsingAllowedPermission);
}
bool WebExtensionPolicy::CanAccessContext(nsILoadContext* aContext) const {

Просмотреть файл

@ -243,7 +243,6 @@ class WebExtensionPolicy final : public nsISupports,
dom::BrowsingContextGroup::KeepAlivePtr mBrowsingContextGroup;
bool mActive = false;
bool mAllowPrivateBrowsingByDefault = true;
RefPtr<WebExtensionLocalizeCallback> mLocalizeCallback;

Просмотреть файл

@ -1,10 +1,6 @@
"use strict";
add_task(async function test_theme_incognito_not_allowed() {
await SpecialPowers.pushPrefEnv({
set: [["extensions.allowPrivateBrowsingByDefault", false]],
});
let windowExtension = ExtensionTestUtils.loadExtension({
incognitoOverride: "spanning",
async background() {

Просмотреть файл

@ -14,10 +14,6 @@
"use strict";
async function test_contentscript_incognito() {
await SpecialPowers.pushPrefEnv({set: [
["extensions.allowPrivateBrowsingByDefault", false],
]});
let extension = ExtensionTestUtils.loadExtension({
incognitoOverride: "spanning",
manifest: {

Просмотреть файл

@ -14,7 +14,6 @@
add_task(async function test_cookies() {
await SpecialPowers.pushPrefEnv({set: [
["extensions.allowPrivateBrowsingByDefault", false],
["dom.security.https_first_pbm", false],
]});

Просмотреть файл

@ -14,10 +14,6 @@
"use strict";
add_task(async function test_cookies_incognito_not_allowed() {
await SpecialPowers.pushPrefEnv({
set: [["extensions.allowPrivateBrowsingByDefault", false]],
});
let privateExtension = ExtensionTestUtils.loadExtension({
incognitoOverride: "spanning",
async background() {

Просмотреть файл

@ -66,11 +66,6 @@ function protocolChromeScript() {
}
add_task(async function test_protocolHandler() {
await SpecialPowers.pushPrefEnv({
set: [
["extensions.allowPrivateBrowsingByDefault", false],
],
});
let extensionData = {
manifest: {
protocol_handlers: [

Просмотреть файл

@ -53,10 +53,6 @@ function testScript() {
}
add_task(async function test_web_accessible_resources_incognito() {
await SpecialPowers.pushPrefEnv({set: [
["extensions.allowPrivateBrowsingByDefault", false],
]});
// This extension will not have access to private browsing so its
// accessible resources should not be able to load in them.
let extension = ExtensionTestUtils.loadExtension({

Просмотреть файл

@ -15,10 +15,6 @@
"use strict";
add_task(async function webnav_test_incognito() {
await SpecialPowers.pushPrefEnv({
set: [["extensions.allowPrivateBrowsingByDefault", false]],
});
// Monitor will fail if it gets any event.
let monitor = ExtensionTestUtils.loadExtension({
manifest: {

Просмотреть файл

@ -7,11 +7,9 @@ add_task(async function test_background_incognito() {
"Test background page incognito value with permanent private browsing enabled"
);
Services.prefs.setBoolPref("extensions.allowPrivateBrowsingByDefault", false);
Services.prefs.setBoolPref("browser.privatebrowsing.autostart", true);
registerCleanupFunction(() => {
Services.prefs.clearUserPref("browser.privatebrowsing.autostart");
Services.prefs.clearUserPref("extensions.allowPrivateBrowsingByDefault");
});
let extension = ExtensionTestUtils.loadExtension({

Просмотреть файл

@ -102,7 +102,7 @@ add_task(async function test_contentscript_context() {
await extension.unload();
});
async function contentscript_context_incognito_not_allowed_test() {
add_task(async function test_contentscript_context_incognito_not_allowed() {
async function background() {
await browser.contentScripts.register({
js: [{ file: "registered_script.js" }],
@ -158,13 +158,6 @@ async function contentscript_context_incognito_not_allowed_test() {
await contentPage.close();
await extension.unload();
}
add_task(async function test_contentscript_context_incognito_not_allowed() {
return runWithPrefs(
[["extensions.allowPrivateBrowsingByDefault", false]],
contentscript_context_incognito_not_allowed_test
);
});
add_task(async function test_contentscript_context_unload_while_in_bfcache() {

Просмотреть файл

@ -17,7 +17,6 @@ add_task(function setup() {
);
info(`Using download directory ${downloadDir.path}`);
Services.prefs.setBoolPref("extensions.allowPrivateBrowsingByDefault", false);
Services.prefs.setIntPref("browser.download.folderList", 2);
Services.prefs.setComplexValue(
"browser.download.dir",
@ -26,7 +25,6 @@ add_task(function setup() {
);
registerCleanupFunction(() => {
Services.prefs.clearUserPref("extensions.allowPrivateBrowsingByDefault");
Services.prefs.clearUserPref("browser.download.folderList");
Services.prefs.clearUserPref("browser.download.dir");

Просмотреть файл

@ -3,8 +3,6 @@
"use strict";
add_task(async function test_is_allowed_incognito_access() {
Services.prefs.setBoolPref("extensions.allowPrivateBrowsingByDefault", false);
async function background() {
let allowed = await browser.extension.isAllowedIncognitoAccess();
@ -20,12 +18,9 @@ add_task(async function test_is_allowed_incognito_access() {
await extension.startup();
await extension.awaitFinish("isAllowedIncognitoAccess");
await extension.unload();
Services.prefs.clearUserPref("extensions.allowPrivateBrowsingByDefault");
});
add_task(async function test_is_denied_incognito_access() {
Services.prefs.setBoolPref("extensions.allowPrivateBrowsingByDefault", false);
async function background() {
let allowed = await browser.extension.isAllowedIncognitoAccess();
@ -40,7 +35,6 @@ add_task(async function test_is_denied_incognito_access() {
await extension.startup();
await extension.awaitFinish("isNotAllowedIncognitoAccess");
await extension.unload();
Services.prefs.clearUserPref("extensions.allowPrivateBrowsingByDefault");
});
add_task(async function test_in_incognito_context_false() {

Просмотреть файл

@ -48,28 +48,16 @@ function assertActionAMTelemetryEvent(
Assert.deepEqual(events, expectedActionEvents, assertMessage);
}
async function runIncognitoTest(
extensionData,
privateBrowsingAllowed,
allowPrivateBrowsingByDefault
) {
Services.prefs.setBoolPref(
"extensions.allowPrivateBrowsingByDefault",
allowPrivateBrowsingByDefault
);
async function runIncognitoTest(extensionData, privateBrowsingAllowed) {
let wrapper = ExtensionTestUtils.loadExtension(extensionData);
await wrapper.startup();
let { extension } = wrapper;
if (!allowPrivateBrowsingByDefault) {
// Check the permission if we're not allowPrivateBrowsingByDefault.
equal(
extension.permissions.has("internal:privateBrowsingAllowed"),
privateBrowsingAllowed,
"privateBrowsingAllowed in serialized extension"
);
}
equal(
extension.permissions.has("internal:privateBrowsingAllowed"),
privateBrowsingAllowed,
"privateBrowsingAllowed in serialized extension"
);
equal(
extension.privateBrowsingAllowed,
privateBrowsingAllowed,
@ -82,12 +70,10 @@ async function runIncognitoTest(
);
await wrapper.unload();
Services.prefs.clearUserPref("extensions.allowPrivateBrowsingByDefault");
}
add_task(async function test_extension_incognito_spanning() {
await runIncognitoTest({}, false, false);
await runIncognitoTest({}, true, true);
await runIncognitoTest({}, false);
});
// Test that when we are restricted, we can override the restriction for tests.
@ -95,7 +81,7 @@ add_task(async function test_extension_incognito_override_spanning() {
let extensionData = {
incognitoOverride: "spanning",
};
await runIncognitoTest(extensionData, true, false);
await runIncognitoTest(extensionData, true);
});
// This tests that a privileged extension will always have private browsing.
@ -103,15 +89,13 @@ add_task(async function test_extension_incognito_privileged() {
let extensionData = {
isPrivileged: true,
};
await runIncognitoTest(extensionData, true, true);
await runIncognitoTest(extensionData, true, false);
await runIncognitoTest(extensionData, true);
});
// We only test spanning upgrades since that is the only allowed
// incognito type prior to feature being turned on.
add_task(async function test_extension_incognito_spanning_grandfathered() {
await AddonTestUtils.promiseStartupManager();
Services.prefs.setBoolPref("extensions.allowPrivateBrowsingByDefault", true);
Services.prefs.setBoolPref("extensions.incognito.migrated", false);
// This extension gets disabled before the "upgrade", it should not
@ -135,8 +119,8 @@ add_task(async function test_extension_incognito_spanning_grandfathered() {
);
equal(
disabledPolicy.privateBrowsingAllowed,
true,
"privateBrowsingAllowed in disabled addon"
false,
"privateBrowsingAllowed in not allowed disabled addon"
);
let disabledAddon = await AddonManager.getAddonByID(disabledAddonId);
@ -162,12 +146,10 @@ add_task(async function test_extension_incognito_spanning_grandfathered() {
);
equal(
policy.privateBrowsingAllowed,
true,
"privateBrowsingAllowed in extension"
false,
"privateBrowsingAllowed is false in extension"
);
// Turn on incognito support and update the browser.
Services.prefs.setBoolPref("extensions.allowPrivateBrowsingByDefault", false);
// Disable the addonsManager telemetry event category, to ensure that it will
// be enabled automatically during the AddonManager/XPIProvider startup and
// the telemetry event recorded (See Bug 1540112 for a rationale).
@ -212,7 +194,6 @@ add_task(async function test_extension_incognito_spanning_grandfathered() {
await wrapper.unload();
await disabledWrapper.unload();
Services.prefs.clearUserPref("extensions.allowPrivateBrowsingByDefault");
Services.prefs.clearUserPref("extensions.incognito.migrated");
const expectedEvents = [
@ -232,8 +213,6 @@ add_task(async function test_extension_incognito_spanning_grandfathered() {
});
add_task(async function test_extension_privileged_not_allowed() {
Services.prefs.setBoolPref("extensions.allowPrivateBrowsingByDefault", false);
let addonId = "privileged_not_allowed@mochi.test";
let extensionData = {
manifest: {
@ -263,8 +242,6 @@ add_task(async function test_extension_privileged_not_allowed() {
// Test that we remove pb permission if an extension is updated to not_allowed.
add_task(async function test_extension_upgrade_not_allowed() {
Services.prefs.setBoolPref("extensions.allowPrivateBrowsingByDefault", false);
let addonId = "upgrade@mochi.test";
let extensionData = {
manifest: {

Просмотреть файл

@ -3,8 +3,6 @@
"use strict";
add_task(async function test_manifest_incognito() {
Services.prefs.setBoolPref("extensions.allowPrivateBrowsingByDefault", false);
let normalized = await ExtensionTestUtils.normalizeManifest({
incognito: "spanning",
});
@ -44,5 +42,4 @@ add_task(async function test_manifest_incognito() {
undefined,
"Invalid incognito string should be undefined"
);
Services.prefs.clearUserPref("extensions.allowPrivateBrowsingByDefault");
});

Просмотреть файл

@ -731,8 +731,6 @@ add_task(async function test_permissions_prompt() {
// Check that internal permissions can not be set and are not returned by the API.
add_task(async function test_internal_permissions() {
Services.prefs.setBoolPref("extensions.allowPrivateBrowsingByDefault", false);
function background() {
browser.test.onMessage.addListener(async (method, arg) => {
try {
@ -819,5 +817,4 @@ add_task(async function test_internal_permissions() {
});
await extension.unload();
Services.prefs.clearUserPref("extensions.allowPrivateBrowsingByDefault");
});

Просмотреть файл

@ -9,8 +9,6 @@ server.registerPathHandler("/dummy", (request, response) => {
});
add_task(async function test_incognito_webrequest_access() {
Services.prefs.setBoolPref("extensions.allowPrivateBrowsingByDefault", false);
let pb_extension = ExtensionTestUtils.loadExtension({
incognitoOverride: "spanning",
manifest: {
@ -76,6 +74,4 @@ add_task(async function test_incognito_webrequest_access() {
await pb_extension.unload();
await extension.unload();
Services.prefs.clearUserPref("extensions.allowPrivateBrowsingByDefault");
});

Просмотреть файл

@ -11,12 +11,6 @@ server.registerPathHandler("/dummy", (request, response) => {
});
add_task(async function test_incognito_proxy_onRequest_access() {
// No specific support exists in the proxy api for this test,
// rather it depends on functionality existing in ChannelWrapper
// that prevents notification of private channels if the
// extension does not have permission.
Services.prefs.setBoolPref("extensions.allowPrivateBrowsingByDefault", false);
// This extension will fail if it gets a private request.
let extension = ExtensionTestUtils.loadExtension({
manifest: {
@ -98,6 +92,4 @@ add_task(async function test_incognito_proxy_onRequest_access() {
await pextension.unload();
await extension.unload();
Services.prefs.clearUserPref("extensions.allowPrivateBrowsingByDefault");
});

Просмотреть файл

@ -44,12 +44,6 @@ XPCOMUtils.defineLazyGetter(this, "extensionStylesheets", () => {
return ExtensionParent.extensionStylesheets;
});
XPCOMUtils.defineLazyPreferenceGetter(
this,
"allowPrivateBrowsingByDefault",
"extensions.allowPrivateBrowsingByDefault",
true
);
XPCOMUtils.defineLazyPreferenceGetter(
this,
"SUPPORT_URL",
@ -432,7 +426,6 @@ async function isAddonOptionsUIAllowed(addon) {
// The current page is in a private browsing window, and the add-on does not
// have the permission to access private browsing windows. Block access.
return (
allowPrivateBrowsingByDefault ||
// Note: This function is async because isAllowedInPrivateBrowsing is async.
isAllowedInPrivateBrowsing(addon)
);
@ -2828,7 +2821,7 @@ class AddonDetails extends HTMLElement {
);
// By default, all private browsing rows are hidden. Possibly show one.
if (allowPrivateBrowsingByDefault || addon.type != "extension") {
if (addon.type != "extension") {
// All add-addons of this type are allowed in private browsing mode, so
// do not show any UI.
} else if (addon.incognito == "not_allowed") {
@ -3359,11 +3352,7 @@ class AddonCard extends HTMLElement {
}
// Set the private browsing badge visibility.
if (
!allowPrivateBrowsingByDefault &&
addon.type == "extension" &&
addon.incognito != "not_allowed"
) {
if (addon.type == "extension" && addon.incognito != "not_allowed") {
// Keep update synchronous, the badge can appear later.
isAllowedInPrivateBrowsing(addon).then(isAllowed => {
card.querySelector(

Просмотреть файл

@ -39,13 +39,6 @@ XPCOMUtils.defineLazyModuleGetters(this, {
verifyBundleSignedState: "resource://gre/modules/addons/XPIInstall.jsm",
});
XPCOMUtils.defineLazyPreferenceGetter(
this,
"allowPrivateBrowsingByDefault",
"extensions.allowPrivateBrowsingByDefault",
true
);
const { nsIBlocklistService } = Ci;
// These are injected from XPIProvider.jsm
@ -754,7 +747,6 @@ class AddonInternal {
// when the extension has opted out or it gets the permission automatically
// on every extension startup (as system, privileged and builtin addons).
if (
!allowPrivateBrowsingByDefault &&
this.type === "extension" &&
this.incognito !== "not_allowed" &&
this.signedState !== AddonManager.SIGNEDSTATE_PRIVILEGED &&

Просмотреть файл

@ -2495,10 +2495,6 @@ var XPIProvider = {
// enabled extension will be migrated.
try {
if (
!Services.prefs.getBoolPref(
"extensions.allowPrivateBrowsingByDefault",
true
) &&
!Services.prefs.getBoolPref("extensions.incognito.migrated", false)
) {
XPIDatabase.syncLoadDB(false);

Просмотреть файл

@ -131,10 +131,6 @@ async function assertBackButtonIsDisabled(win) {
}
add_task(async function enableHtmlViews() {
await SpecialPowers.pushPrefEnv({
set: [["extensions.allowPrivateBrowsingByDefault", false]],
});
gProvider = new MockProvider();
gProvider.createAddons([
{

Просмотреть файл

@ -43,7 +43,6 @@ add_task(async function setup() {
set: [
["extensions.webapi.testing", true],
["extensions.install.requireBuiltInCerts", false],
["extensions.allowPrivateBrowsingByDefault", false],
],
});
info("added preferences");

Просмотреть файл

@ -8,7 +8,6 @@ add_task(async function test_theme_install() {
set: [
["extensions.webapi.testing", true],
["extensions.install.requireBuiltInCerts", false],
["extensions.allowPrivateBrowsingByDefault", false],
],
});

Просмотреть файл

@ -144,10 +144,6 @@ add_task(function clearInitialTelemetry() {
});
add_task(async function test_badge_and_toggle_incognito() {
await SpecialPowers.pushPrefEnv({
set: [["extensions.allowPrivateBrowsingByDefault", false]],
});
let addons = new Map([
[
"@test-default",
@ -291,10 +287,6 @@ add_task(async function test_badge_and_toggle_incognito() {
});
add_task(async function test_addon_preferences_button() {
await SpecialPowers.pushPrefEnv({
set: [["extensions.allowPrivateBrowsingByDefault", false]],
});
let addons = new Map([
[
"test-inline-options@mozilla.com",
@ -460,10 +452,7 @@ add_task(async function test_addon_preferences_button() {
add_task(async function test_addon_postinstall_incognito_hidden_checkbox() {
await SpecialPowers.pushPrefEnv({
set: [
["extensions.allowPrivateBrowsingByDefault", false],
["extensions.langpacks.signatures.required", false],
],
set: [["extensions.langpacks.signatures.required", false]],
});
const TEST_ADDONS = [

Просмотреть файл

@ -161,16 +161,8 @@ function acceptAppMenuNotificationWhenShown(
PanelUI.notificationPanel.removeEventListener("popupshown", popupshown);
let allowPrivate = Services.prefs.getBoolPref(
"extensions.allowPrivateBrowsingByDefault",
true
);
let checkbox = document.getElementById("addon-incognito-checkbox");
is(
checkbox.hidden,
privileged || (allowPrivate && !checkIncognito),
"checkbox visibility is correct"
);
is(checkbox.hidden, privileged, "checkbox visibility is correct");
is(checkbox.checked, incognitoChecked, "checkbox is marked as expected");
// If we're unchecking or checking the incognito property, this will
@ -646,10 +638,6 @@ var TESTS = [
},
async function test_whitelistedInstall() {
SpecialPowers.pushPrefEnv({
set: [["extensions.allowPrivateBrowsingByDefault", false]],
});
let originalTab = gBrowser.selectedTab;
let tab;
gBrowser.selectedTab = originalTab;
@ -711,7 +699,6 @@ var TESTS = [
PermissionTestUtils.remove("http://example.com/", "install");
Services.prefs.clearUserPref("extensions.allowPrivateBrowsingByDefault");
await removeTabAndWaitForNotificationClose();
},
@ -858,9 +845,6 @@ var TESTS = [
},
async function test_urlBar() {
SpecialPowers.pushPrefEnv({
set: [["extensions.allowPrivateBrowsingByDefault", false]],
});
let progressPromise = waitForProgressNotification();
let dialogPromise = waitForInstallDialog();
@ -918,8 +902,6 @@ var TESTS = [
await addon.uninstall();
Services.prefs.clearUserPref("extensions.allowPrivateBrowsingByDefault");
await removeTabAndWaitForNotificationClose();
},
@ -1120,9 +1102,6 @@ var TESTS = [
},
async function test_incognito_checkbox() {
SpecialPowers.pushPrefEnv({
set: [["extensions.allowPrivateBrowsingByDefault", false]],
});
// Grant permission up front.
const permissionName = "internal:privateBrowsingAllowed";
let incognitoPermission = {
@ -1198,9 +1177,6 @@ var TESTS = [
},
async function test_incognito_checkbox_new_window() {
SpecialPowers.pushPrefEnv({
set: [["extensions.allowPrivateBrowsingByDefault", false]],
});
let win = await BrowserTestUtils.openNewBrowserWindow();
await SimpleTest.promiseFocus(win);
// Grant permission up front.