diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js index bf1467e2bf25..35a80d697932 100644 --- a/browser/app/profile/firefox.js +++ b/browser/app/profile/firefox.js @@ -1286,8 +1286,7 @@ pref("browser.newtabpage.columns", 5); // directory tiles download URL pref("browser.newtabpage.directory.source", "https://tiles.services.mozilla.com/v3/links/fetch/%LOCALE%/%CHANNEL%"); -// activates Activity Stream -pref("browser.newtabpage.activity-stream.enabled", true); +// Activity Stream prefs that control to which page to redirect pref("browser.newtabpage.activity-stream.prerender", true); #ifndef RELEASE_OR_BETA pref("browser.newtabpage.activity-stream.debug", false); diff --git a/browser/base/content/browser-thumbnails.js b/browser/base/content/browser-thumbnails.js index 2453bd21550b..d7ab0ee80c23 100644 --- a/browser/base/content/browser-thumbnails.js +++ b/browser/base/content/browser-thumbnails.js @@ -14,13 +14,6 @@ var gBrowserThumbnails = { */ PREF_DISK_CACHE_SSL: "browser.cache.disk_cache_ssl", - /** - * Pref that controls whether activity stream is enabled - */ - PREF_ACTIVITY_STREAM_ENABLED: "browser.newtabpage.activity-stream.enabled", - - _activityStreamEnabled: null, - _captureDelayMS: 1000, /** @@ -46,12 +39,9 @@ var gBrowserThumbnails = { init: function Thumbnails_init() { gBrowser.addTabsProgressListener(this); Services.prefs.addObserver(this.PREF_DISK_CACHE_SSL, this); - Services.prefs.addObserver(this.PREF_ACTIVITY_STREAM_ENABLED, this); this._sslDiskCacheEnabled = Services.prefs.getBoolPref(this.PREF_DISK_CACHE_SSL); - this._activityStreamEnabled = - Services.prefs.getBoolPref(this.PREF_ACTIVITY_STREAM_ENABLED); this._tabEvents.forEach(function(aEvent) { gBrowser.tabContainer.addEventListener(aEvent, this); @@ -63,7 +53,6 @@ var gBrowserThumbnails = { uninit: function Thumbnails_uninit() { gBrowser.removeTabsProgressListener(this); Services.prefs.removeObserver(this.PREF_DISK_CACHE_SSL, this); - Services.prefs.removeObserver(this.PREF_ACTIVITY_STREAM_ENABLED, this); if (this._topSiteURLsRefreshTimer) { this._topSiteURLsRefreshTimer.cancel(); @@ -98,12 +87,6 @@ var gBrowserThumbnails = { this._sslDiskCacheEnabled = Services.prefs.getBoolPref(this.PREF_DISK_CACHE_SSL); break; - case this.PREF_ACTIVITY_STREAM_ENABLED: - this._activityStreamEnabled = - Services.prefs.getBoolPref(this.PREF_ACTIVITY_STREAM_ENABLED); - // Get the new top sites - this.clearTopSiteURLCache(); - break; } }, @@ -209,16 +192,12 @@ async function getTopSiteURLs() { 60 * 1000, Ci.nsITimer.TYPE_ONE_SHOT); let sites = []; - if (gBrowserThumbnails._activityStreamEnabled) { - // Get both the top sites returned by the query, and also any pinned sites - // that the user might have added manually that also need a screenshot. - // Also include top sites that don't have rich icons - let topSites = await NewTabUtils.activityStreamLinks.getTopSites(); - sites.push(...topSites.filter(link => !(link.faviconSize >= 96))); - sites.push(...NewTabUtils.pinnedLinks.links); - } else { - sites = NewTabUtils.links.getLinks(); - } + // Get both the top sites returned by the query, and also any pinned sites + // that the user might have added manually that also need a screenshot. + // Also include top sites that don't have rich icons + let topSites = await NewTabUtils.activityStreamLinks.getTopSites(); + sites.push(...topSites.filter(link => !(link.faviconSize >= 96))); + sites.push(...NewTabUtils.pinnedLinks.links); return sites.reduce((urls, link) => { if (link) urls.push(link.url); return urls; diff --git a/browser/base/content/test/general/browser_bug724239.js b/browser/base/content/test/general/browser_bug724239.js index a5bef5a80ae3..00d3c5b7a3c1 100644 --- a/browser/base/content/test/general/browser_bug724239.js +++ b/browser/base/content/test/general/browser_bug724239.js @@ -11,7 +11,6 @@ add_task(async function test_blank() { }); add_task(async function test_newtab() { - await SpecialPowers.pushPrefEnv({set: [["browser.newtabpage.activity-stream.enabled", true]]}); await BrowserTestUtils.withNewTab({ gBrowser, url: "about:blank" }, async function(browser) { // Can't load it directly because that'll use a preloaded tab if present. @@ -22,15 +21,4 @@ add_task(async function test_newtab() { await BrowserTestUtils.browserLoaded(browser); is(gBrowser.canGoBack, true, "about:newtab was added to the session history when AS was enabled."); }); - await SpecialPowers.pushPrefEnv({set: [["browser.newtabpage.activity-stream.enabled", false]]}); - await BrowserTestUtils.withNewTab({ gBrowser, url: "about:blank" }, - async function(browser) { - // Can't load it directly because that'll use a preloaded tab if present. - BrowserTestUtils.loadURI(browser, "about:newtab"); - await BrowserTestUtils.browserLoaded(browser); - - BrowserTestUtils.loadURI(browser, "http://example.com"); - await BrowserTestUtils.browserLoaded(browser); - is(gBrowser.canGoBack, false, "about:newtab was not added to the session history when AS was disabled."); - }); }); diff --git a/browser/base/content/test/general/browser_testOpenNewRemoteTabsFromNonRemoteBrowsers.js b/browser/base/content/test/general/browser_testOpenNewRemoteTabsFromNonRemoteBrowsers.js index a9b20c88a103..9f049cf73d1f 100644 --- a/browser/base/content/test/general/browser_testOpenNewRemoteTabsFromNonRemoteBrowsers.js +++ b/browser/base/content/test/general/browser_testOpenNewRemoteTabsFromNonRemoteBrowsers.js @@ -11,7 +11,7 @@ requestLongerTimeout(2); function frame_script() { content.document.body.innerHTML = ` - Open a window + Open a window `; let element = content.document.getElementById("testAnchor"); @@ -62,7 +62,7 @@ add_task(async function test_new_tab() { await promiseTabLoadEvent(newTab); - // Our framescript opens to about:home which means that the + // Our framescript opens to a web page which means that the // tab should eventually become remote. ok(newTab.linkedBrowser.isRemoteBrowser, "The opened browser never became remote."); @@ -114,7 +114,7 @@ add_task(async function test_new_window() { await promiseTabLoadEvent(newTab); - // Our framescript opens to about:home which means that the + // Our framescript opens to a web page which means that the // tab should eventually become remote. ok(newTab.linkedBrowser.isRemoteBrowser, "The opened browser never became remote."); diff --git a/browser/base/content/test/newtab/browser.ini b/browser/base/content/test/newtab/browser.ini index 38cf95b2016a..5bbb7745d210 100644 --- a/browser/base/content/test/newtab/browser.ini +++ b/browser/base/content/test/newtab/browser.ini @@ -1,5 +1,5 @@ [DEFAULT] -skip-if = (os == 'linux') # Bug 1243103, Bug 1243398, etc. +skip-if = true # Bug 1433133 to remove; previously skipped for intermittents, e.g., Bug 1243103, Bug 1243398 support-files = head.js diff --git a/browser/base/content/test/newtab/head.js b/browser/base/content/test/newtab/head.js index a22a84eb89a7..437d95df6848 100644 --- a/browser/base/content/test/newtab/head.js +++ b/browser/base/content/test/newtab/head.js @@ -3,10 +3,8 @@ const PREF_NEWTAB_ENABLED = "browser.newtabpage.enabled"; const PREF_NEWTAB_DIRECTORYSOURCE = "browser.newtabpage.directory.source"; -const PREF_NEWTAB_ACTIVITY_STREAM = "browser.newtabpage.activity-stream.enabled"; Services.prefs.setBoolPref(PREF_NEWTAB_ENABLED, true); -Services.prefs.setBoolPref(PREF_NEWTAB_ACTIVITY_STREAM, false); // Opens and closes a new tab to clear any existing preloaded ones. This is // necessary to prevent any left-over activity-stream preloaded new tabs from @@ -96,7 +94,6 @@ add_task(async function setupWindowSize() { registerCleanupFunction(function() { Services.prefs.clearUserPref(PREF_NEWTAB_ENABLED); - Services.prefs.clearUserPref(PREF_NEWTAB_ACTIVITY_STREAM); Services.prefs.setCharPref(PREF_NEWTAB_DIRECTORYSOURCE, gOrigDirectorySource); return watchLinksChangeOnce(); diff --git a/browser/components/about/AboutRedirector.cpp b/browser/components/about/AboutRedirector.cpp index fd2dc6bb59c0..2fb83865d8f5 100644 --- a/browser/components/about/AboutRedirector.cpp +++ b/browser/components/about/AboutRedirector.cpp @@ -21,8 +21,6 @@ namespace browser { NS_IMPL_ISUPPORTS(AboutRedirector, nsIAboutModule) -bool AboutRedirector::sActivityStreamEnabled = false; - struct RedirEntry { const char* id; const char* url; @@ -76,15 +74,18 @@ static const RedirEntry kRedirMap[] = { { "welcomeback", "chrome://browser/content/aboutWelcomeBack.xhtml", nsIAboutModule::ALLOW_SCRIPT | nsIAboutModule::HIDE_FROM_ABOUTABOUT }, + // Actual activity stream URL for home and newtab are set in channel creation // Linkable because of indexeddb use (bug 1228118) - { "home", "chrome://browser/content/abouthome/aboutHome.xhtml", + { "home", "about:blank", nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT | nsIAboutModule::URI_MUST_LOAD_IN_CHILD | nsIAboutModule::ALLOW_SCRIPT | nsIAboutModule::MAKE_LINKABLE | nsIAboutModule::ENABLE_INDEXED_DB }, - // the newtab's actual URL will be determined when the channel is created { "newtab", "about:blank", + nsIAboutModule::ENABLE_INDEXED_DB | + nsIAboutModule::URI_MUST_LOAD_IN_CHILD | + nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT | nsIAboutModule::ALLOW_SCRIPT }, { "preferences", "chrome://browser/content/preferences/in-content/preferences.xul", nsIAboutModule::ALLOW_SCRIPT }, @@ -115,17 +116,6 @@ GetAboutModuleName(nsIURI *aURI) return path; } -void -AboutRedirector::LoadActivityStreamPrefs() -{ - static bool sASEnabledCacheInited = false; - if (!sASEnabledCacheInited) { - Preferences::AddBoolVarCache(&AboutRedirector::sActivityStreamEnabled, - "browser.newtabpage.activity-stream.enabled"); - sASEnabledCacheInited = true; - } -} - NS_IMETHODIMP AboutRedirector::NewChannel(nsIURI* aURI, nsILoadInfo* aLoadInfo, @@ -142,14 +132,11 @@ AboutRedirector::NewChannel(nsIURI* aURI, nsCOMPtr ioService = do_GetIOService(&rv); NS_ENSURE_SUCCESS(rv, rv); - LoadActivityStreamPrefs(); - for (auto & redir : kRedirMap) { if (!strcmp(path.get(), redir.id)) { nsAutoCString url; - if (path.EqualsLiteral("newtab") || - (path.EqualsLiteral("home") && sActivityStreamEnabled)) { + if (path.EqualsLiteral("newtab") || path.EqualsLiteral("home")) { // let the aboutNewTabService decide where to redirect nsCOMPtr aboutNewTabService = do_GetService("@mozilla.org/browser/aboutnewtab-service;1", &rv); @@ -201,24 +188,8 @@ AboutRedirector::GetURIFlags(nsIURI *aURI, uint32_t *result) nsAutoCString name = GetAboutModuleName(aURI); - LoadActivityStreamPrefs(); - for (auto & redir : kRedirMap) { if (name.Equals(redir.id)) { - - // Once ActivityStream is fully rolled out and we've removed Tiles, - // this special case can go away and the flag can just become part - // of the normal about:newtab entry in kRedirMap. - if (name.EqualsLiteral("newtab") || name.EqualsLiteral("home")) { - if (sActivityStreamEnabled) { - *result = redir.flags | - nsIAboutModule::URI_MUST_LOAD_IN_CHILD | - nsIAboutModule::ENABLE_INDEXED_DB | - nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT; - return NS_OK; - } - } - *result = redir.flags; return NS_OK; } diff --git a/browser/components/about/AboutRedirector.h b/browser/components/about/AboutRedirector.h index 7b70a6f77bed..8e12f4332343 100644 --- a/browser/components/about/AboutRedirector.h +++ b/browser/components/about/AboutRedirector.h @@ -24,11 +24,6 @@ public: protected: virtual ~AboutRedirector() {} - -private: - static bool sActivityStreamEnabled; - - static void LoadActivityStreamPrefs(); }; } // namespace browser diff --git a/browser/components/about/test/unit/test_getURIFlags.js b/browser/components/about/test/unit/test_getURIFlags.js index 177c1ce1480b..f2037571c12a 100644 --- a/browser/components/about/test/unit/test_getURIFlags.js +++ b/browser/components/about/test/unit/test_getURIFlags.js @@ -6,25 +6,10 @@ const uri = Services.io.newURI("about:newtab"); function run_test() { test_AS_enabled_flags(); - test_AS_disabled_flags(); -} - -// Since tiles isn't e10s capable, it shouldn't advertise that it can load in -// the child. -function test_AS_disabled_flags() { - Services.prefs.setBoolPref("browser.newtabpage.activity-stream.enabled", - false); - - let flags = am.getURIFlags(uri); - - ok(!(flags & Ci.nsIAboutModule.URI_MUST_LOAD_IN_CHILD)); } // Activity Stream, however, is e10s-capable, and should advertise it. function test_AS_enabled_flags() { - Services.prefs.setBoolPref("browser.newtabpage.activity-stream.enabled", - true); - let flags = am.getURIFlags(uri); ok(flags & Ci.nsIAboutModule.URI_MUST_LOAD_IN_CHILD); diff --git a/browser/components/newtab/NewTabPrefsProvider.jsm b/browser/components/newtab/NewTabPrefsProvider.jsm index 5e248c795883..204c6b7606b5 100644 --- a/browser/components/newtab/NewTabPrefsProvider.jsm +++ b/browser/components/newtab/NewTabPrefsProvider.jsm @@ -12,7 +12,6 @@ XPCOMUtils.defineLazyGetter(this, "EventEmitter", function() { // Supported prefs and data type const gPrefsMap = new Map([ - ["browser.newtabpage.activity-stream.enabled", "bool"], ["browser.newtabpage.enabled", "bool"], ["browser.newtabpage.enhanced", "bool"], ["browser.newtabpage.introShown", "bool"], diff --git a/browser/components/newtab/aboutNewTabService.js b/browser/components/newtab/aboutNewTabService.js index be34ce1bf0d0..7e8a05ec60a9 100644 --- a/browser/components/newtab/aboutNewTabService.js +++ b/browser/components/newtab/aboutNewTabService.js @@ -13,7 +13,10 @@ ChromeUtils.import("resource://gre/modules/AppConstants.jsm"); ChromeUtils.defineModuleGetter(this, "AboutNewTab", "resource:///modules/AboutNewTab.jsm"); -const LOCAL_NEWTAB_URL = "chrome://browser/content/newtab/newTab.xhtml"; +// Dummy references to the files that this service no longer allows loading. +// Bug 1409054 to remove "chrome://browser/content/abouthome/aboutHome.xhtml" +// Bug 1433133 to remove "chrome://browser/content/newtab/newTab.xhtml" + const TOPIC_APP_QUIT = "quit-application-granted"; const TOPIC_LOCALES_CHANGE = "intl:requested-locales-changed"; @@ -27,8 +30,6 @@ const IS_MAIN_PROCESS = Services.appinfo.processType === Services.appinfo.PROCES const IS_RELEASE_OR_BETA = AppConstants.RELEASE_OR_BETA; -// Pref that tells if activity stream is enabled -const PREF_ACTIVITY_STREAM_ENABLED = "browser.newtabpage.activity-stream.enabled"; const PREF_ACTIVITY_STREAM_PRERENDER_ENABLED = "browser.newtabpage.activity-stream.prerender"; const PREF_ACTIVITY_STREAM_DEBUG = "browser.newtabpage.activity-stream.debug"; @@ -36,14 +37,13 @@ const PREF_ACTIVITY_STREAM_DEBUG = "browser.newtabpage.activity-stream.debug"; function AboutNewTabService() { Services.obs.addObserver(this, TOPIC_APP_QUIT); Services.obs.addObserver(this, TOPIC_LOCALES_CHANGE); - Services.prefs.addObserver(PREF_ACTIVITY_STREAM_ENABLED, this); Services.prefs.addObserver(PREF_ACTIVITY_STREAM_PRERENDER_ENABLED, this); if (!IS_RELEASE_OR_BETA) { Services.prefs.addObserver(PREF_ACTIVITY_STREAM_DEBUG, this); } // More initialization happens here - this.toggleActivityStream(); + this.toggleActivityStream(true); this.initialized = true; if (IS_MAIN_PROCESS) { @@ -53,8 +53,6 @@ function AboutNewTabService() { /* * A service that allows for the overriding, at runtime, of the newtab page's url. - * Additionally, the service manages pref state between a activity stream, or the regular - * about:newtab page. * * There is tight coupling with browser/about/AboutRedirector.cpp. * @@ -70,9 +68,8 @@ function AboutNewTabService() { * 2. Redirector Access: * * When the URL loaded is about:newtab, the default behavior, or when entered in the - * URL bar, the redirector is hit. The service is then called to return either of - * two URLs, a chrome or the activity stream one, based on the - * browser.newtabpage.activity-stream.enabled pref. + * URL bar, the redirector is hit. The service is then called to return the + * appropriate activity stream url based on prefs and locales. * * NOTE: "about:newtab" will always result in a default newtab page, and never an overridden URL. * @@ -107,11 +104,7 @@ AboutNewTabService.prototype = { observe(subject, topic, data) { switch (topic) { case "nsPref:changed": - if (data === PREF_ACTIVITY_STREAM_ENABLED) { - if (this.toggleActivityStream()) { - this.notifyChange(); - } - } else if (data === PREF_ACTIVITY_STREAM_PRERENDER_ENABLED) { + if (data === PREF_ACTIVITY_STREAM_PRERENDER_ENABLED) { this._activityStreamPrerender = Services.prefs.getBoolPref(PREF_ACTIVITY_STREAM_PRERENDER_ENABLED); this.notifyChange(); } else if (!IS_RELEASE_OR_BETA && data === PREF_ACTIVITY_STREAM_DEBUG) { @@ -138,11 +131,7 @@ AboutNewTabService.prototype = { }, /** - * React to changes to the activity stream pref. - * - * If browser.newtabpage.activity-stream.enabled is true, this will change the default URL to the - * activity stream page URL. If browser.newtabpage.activity-stream.enabled is false, the default URL - * will be a local chrome URL. + * React to changes to the activity stream being enabled or not. * * This will only act if there is a change of state and if not overridden. * @@ -151,8 +140,7 @@ AboutNewTabService.prototype = { * @param {Boolean} stateEnabled activity stream enabled state to set to * @param {Boolean} forceState force state change */ - toggleActivityStream(stateEnabled = Services.prefs.getBoolPref(PREF_ACTIVITY_STREAM_ENABLED), - forceState = false) { + toggleActivityStream(stateEnabled, forceState = false) { if (!forceState && (this.overridden || stateEnabled === this.activityStreamEnabled)) { // exit there is no change of state @@ -190,27 +178,22 @@ AboutNewTabService.prototype = { /* * Returns the default URL. * - * This URL only depends on the browser.newtabpage.activity-stream.enabled pref. Overriding + * This URL depends on various activity stream prefs and locales. Overriding * the newtab page has no effect on the result of this function. - * - * @returns {String} the default newtab URL, activity-stream or regular depending on browser.newtabpage.activity-stream.enabled */ get defaultURL() { - if (this.activityStreamEnabled) { - // Generate the desired activity stream resource depending on state, e.g., - // resource://activity-stream/prerendered/ar/activity-stream.html - // resource://activity-stream/prerendered/en-US/activity-stream-prerendered.html - // resource://activity-stream/prerendered/static/activity-stream-debug.html - return [ - "resource://activity-stream/prerendered/", - this._activityStreamPath, - "activity-stream", - this._activityStreamPrerender ? "-prerendered" : "", - this._activityStreamDebug ? "-debug" : "", - ".html" - ].join(""); - } - return LOCAL_NEWTAB_URL; + // Generate the desired activity stream resource depending on state, e.g., + // resource://activity-stream/prerendered/ar/activity-stream.html + // resource://activity-stream/prerendered/en-US/activity-stream-prerendered.html + // resource://activity-stream/prerendered/static/activity-stream-debug.html + return [ + "resource://activity-stream/prerendered/", + this._activityStreamPath, + "activity-stream", + this._activityStreamPrerender ? "-prerendered" : "", + this._activityStreamDebug ? "-debug" : "", + ".html" + ].join(""); }, get newTabURL() { @@ -252,7 +235,7 @@ AboutNewTabService.prototype = { resetNewTabURL() { this._overridden = false; this._newTabURL = ABOUT_URL; - this.toggleActivityStream(undefined, true); + this.toggleActivityStream(true, true); this.notifyChange(); }, @@ -262,7 +245,6 @@ AboutNewTabService.prototype = { } Services.obs.removeObserver(this, TOPIC_APP_QUIT); Services.obs.removeObserver(this, TOPIC_LOCALES_CHANGE); - Services.prefs.removeObserver(PREF_ACTIVITY_STREAM_ENABLED, this); Services.prefs.removeObserver(PREF_ACTIVITY_STREAM_PRERENDER_ENABLED, this); if (!IS_RELEASE_OR_BETA) { Services.prefs.removeObserver(PREF_ACTIVITY_STREAM_DEBUG, this); diff --git a/browser/components/newtab/tests/browser/browser_newtab_overrides.js b/browser/components/newtab/tests/browser/browser_newtab_overrides.js index 031dcfc89dce..084460a1fadb 100644 --- a/browser/components/newtab/tests/browser/browser_newtab_overrides.js +++ b/browser/components/newtab/tests/browser/browser_newtab_overrides.js @@ -2,16 +2,12 @@ ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); ChromeUtils.import("resource://gre/modules/Services.jsm"); -const PREF_NEWTAB_ACTIVITY_STREAM = "browser.newtabpage.activity-stream.enabled"; - -Services.prefs.setBoolPref(PREF_NEWTAB_ACTIVITY_STREAM, false); XPCOMUtils.defineLazyServiceGetter(this, "aboutNewTabService", "@mozilla.org/browser/aboutnewtab-service;1", "nsIAboutNewTabService"); registerCleanupFunction(function() { - Services.prefs.clearUserPref(PREF_NEWTAB_ACTIVITY_STREAM); aboutNewTabService.resetNewTabURL(); }); @@ -48,9 +44,9 @@ add_task(async function redirector_ignores_override() { await ContentTask.spawn(browser, {}, async function() { Assert.equal(content.location.href, "about:newtab", "Got right URL"); Assert.equal(content.document.location.href, "about:newtab", "Got right URL"); - Assert.equal(content.document.nodePrincipal, + Assert.notEqual(content.document.nodePrincipal, Services.scriptSecurityManager.getSystemPrincipal(), - "nodePrincipal should match systemPrincipal"); + "activity stream principal should not match systemPrincipal"); }); }); // jshint ignore:line } diff --git a/browser/components/newtab/tests/xpcshell/test_AboutNewTabService.js b/browser/components/newtab/tests/xpcshell/test_AboutNewTabService.js index 4787bdcc76fa..e207c22f1886 100644 --- a/browser/components/newtab/tests/xpcshell/test_AboutNewTabService.js +++ b/browser/components/newtab/tests/xpcshell/test_AboutNewTabService.js @@ -19,14 +19,11 @@ const ACTIVITY_STREAM_PRERENDER_DEBUG_URL = "resource://activity-stream/prerende const ACTIVITY_STREAM_URL = "resource://activity-stream/prerendered/en-US/activity-stream.html"; const ACTIVITY_STREAM_DEBUG_URL = "resource://activity-stream/prerendered/static/activity-stream-debug.html"; -const DEFAULT_CHROME_URL = "chrome://browser/content/newtab/newTab.xhtml"; const DOWNLOADS_URL = "chrome://browser/content/downloads/contentAreaDownloadsView.xul"; -const ACTIVITY_STREAM_PREF = "browser.newtabpage.activity-stream.enabled"; const ACTIVITY_STREAM_PRERENDER_PREF = "browser.newtabpage.activity-stream.prerender"; const ACTIVITY_STREAM_DEBUG_PREF = "browser.newtabpage.activity-stream.debug"; function cleanup() { - Services.prefs.clearUserPref(ACTIVITY_STREAM_PREF); Services.prefs.clearUserPref(ACTIVITY_STREAM_PRERENDER_PREF); Services.prefs.clearUserPref(ACTIVITY_STREAM_DEBUG_PREF); aboutNewTabService.resetNewTabURL(); @@ -35,7 +32,7 @@ function cleanup() { registerCleanupFunction(cleanup); add_task(async function test_as_and_prerender_initialized() { - Assert.equal(aboutNewTabService.activityStreamEnabled, Services.prefs.getBoolPref(ACTIVITY_STREAM_PREF), + Assert.ok(aboutNewTabService.activityStreamEnabled, ".activityStreamEnabled should be set to the correct initial value"); Assert.equal(aboutNewTabService.activityStreamPrerender, Services.prefs.getBoolPref(ACTIVITY_STREAM_PRERENDER_PREF), ".activityStreamPrerender should be set to the correct initial value"); @@ -49,11 +46,6 @@ add_task(async function test_as_and_prerender_initialized() { */ add_task(async function test_override_activity_stream_disabled() { let notificationPromise; - Services.prefs.setBoolPref(ACTIVITY_STREAM_PREF, false); - - // tests default is the local newtab resource - Assert.equal(aboutNewTabService.defaultURL, DEFAULT_CHROME_URL, - `Default newtab URL should be ${DEFAULT_CHROME_URL}`); // override with some remote URL let url = "http://example.com/"; @@ -89,14 +81,14 @@ add_task(async function test_override_activity_stream_enabled() { Assert.ok(aboutNewTabService.activityStreamEnabled, "Activity Stream should be enabled"); Assert.ok(aboutNewTabService.activityStreamPrerender, "Activity Stream should be prerendered"); - // change to local newtab page while activity stream is enabled - notificationPromise = nextChangeNotificationPromise(DEFAULT_CHROME_URL); - aboutNewTabService.newTabURL = DEFAULT_CHROME_URL; + // change to a chrome URL while activity stream is enabled + notificationPromise = nextChangeNotificationPromise(DOWNLOADS_URL); + aboutNewTabService.newTabURL = DOWNLOADS_URL; await notificationPromise; - Assert.equal(aboutNewTabService.newTabURL, DEFAULT_CHROME_URL, + Assert.equal(aboutNewTabService.newTabURL, DOWNLOADS_URL, "Newtab URL set to chrome url"); - Assert.equal(aboutNewTabService.defaultURL, DEFAULT_CHROME_URL, - "Newtab URL defaultURL set to the default chrome URL"); + Assert.equal(aboutNewTabService.defaultURL, ACTIVITY_STREAM_PRERENDER_URL, + "Newtab URL defaultURL still set to the default activity stream prerendered URL"); Assert.ok(aboutNewTabService.overridden, "Newtab URL should be overridden"); Assert.ok(!aboutNewTabService.activityStreamEnabled, "Activity Stream should not be enabled"); @@ -198,15 +190,11 @@ function setBoolPrefAndWaitForChange(pref, value, testMessage) { function setupASPrerendered() { - if (Services.prefs.getBoolPref(ACTIVITY_STREAM_PREF) && - Services.prefs.getBoolPref(ACTIVITY_STREAM_PRERENDER_PREF)) { + if (Services.prefs.getBoolPref(ACTIVITY_STREAM_PRERENDER_PREF)) { return Promise.resolve(); } - let notificationPromise; - // change newtab page to activity stream - notificationPromise = nextChangeNotificationPromise("about:newtab"); - Services.prefs.setBoolPref(ACTIVITY_STREAM_PREF, true); + let notificationPromise = nextChangeNotificationPromise("about:newtab"); Services.prefs.setBoolPref(ACTIVITY_STREAM_PRERENDER_PREF, true); return notificationPromise; } diff --git a/browser/components/nsBrowserGlue.js b/browser/components/nsBrowserGlue.js index 4e19a8f9d5a9..8375c5cd3710 100644 --- a/browser/components/nsBrowserGlue.js +++ b/browser/components/nsBrowserGlue.js @@ -367,13 +367,10 @@ BrowserGlue.prototype = { }, _sendMainPingCentrePing() { - const ACTIVITY_STREAM_ENABLED_PREF = "browser.newtabpage.activity-stream.enabled"; const ACTIVITY_STREAM_ID = "activity-stream"; - let asEnabled = Services.prefs.getBoolPref(ACTIVITY_STREAM_ENABLED_PREF, false); - const payload = { event: "AS_ENABLED", - value: asEnabled + value: true }; const options = {filter: ACTIVITY_STREAM_ID}; this.pingCentre.sendPing(payload, options); diff --git a/browser/components/originattributes/test/browser/browser_firstPartyIsolation_about_newtab.js b/browser/components/originattributes/test/browser/browser_firstPartyIsolation_about_newtab.js index 98d4a3d75aa0..1cd19d5098e3 100644 --- a/browser/components/originattributes/test/browser/browser_firstPartyIsolation_about_newtab.js +++ b/browser/components/originattributes/test/browser/browser_firstPartyIsolation_about_newtab.js @@ -1,14 +1,8 @@ add_task(async function setup() { Services.prefs.setBoolPref("privacy.firstparty.isolate", true); - // activity-stream is only enabled in Nightly, and if activity-stream is not - // enabled, about:newtab is loaded without the flag - // nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT, so it will be loaded with - // System Principal. - Services.prefs.setBoolPref("browser.newtabpage.activity-stream.enabled", true); registerCleanupFunction(function() { Services.prefs.clearUserPref("privacy.firstparty.isolate"); - Services.prefs.clearUserPref("browser.newtabpage.activity-stream.enabled"); }); }); diff --git a/browser/components/sessionstore/test/browser_background_tab_crash.js b/browser/components/sessionstore/test/browser_background_tab_crash.js index 34d92a9bdb39..2e5113bf853d 100644 --- a/browser/components/sessionstore/test/browser_background_tab_crash.js +++ b/browser/components/sessionstore/test/browser_background_tab_crash.js @@ -227,12 +227,6 @@ add_task(async function test_preload_crash() { return; } - // Since new tab is only crashable for the activity-stream version, - // we need to flip the pref - await SpecialPowers.pushPrefEnv({ - set: [[ "browser.newtabpage.activity-stream.enabled", true ]] - }); - // Release any existing preloaded browser gBrowser.removePreloadedBrowser(); diff --git a/browser/components/tests/unit/test_browserGlue_pingcentre.js b/browser/components/tests/unit/test_browserGlue_pingcentre.js index 9050858255b0..0ee6887b7122 100644 --- a/browser/components/tests/unit/test_browserGlue_pingcentre.js +++ b/browser/components/tests/unit/test_browserGlue_pingcentre.js @@ -1,21 +1,18 @@ ChromeUtils.import("resource:///modules/PingCentre.jsm"); const TOPIC_SHIELD_INIT_COMPLETE = "shield-init-complete"; -const ACTIVITY_STREAM_ENABLED_PREF = "browser.newtabpage.activity-stream.enabled"; const SEND_PING_MOCK = sinon.stub(PingCentre.prototype, "sendPing"); let gBrowserGlue = Cc["@mozilla.org/browser/browserglue;1"] .getService(Ci.nsIObserver); add_task(async function() { - let asEnabled = Services.prefs.getBoolPref(ACTIVITY_STREAM_ENABLED_PREF, false); - // Simulate ping centre sendPing() trigger. gBrowserGlue.observe(null, TOPIC_SHIELD_INIT_COMPLETE, null); const SEND_PING_CALL_ARGS = { event: "AS_ENABLED", - value: asEnabled + value: true }; const SEND_PING_FILTER = { filter: "activity-stream" }; diff --git a/browser/extensions/activity-stream/README.md b/browser/extensions/activity-stream/README.md index f114571ef97a..6ec99dda3072 100644 --- a/browser/extensions/activity-stream/README.md +++ b/browser/extensions/activity-stream/README.md @@ -1,8 +1,7 @@ # activity-stream This system add-on replaces the new tab page in Firefox with a new design and -functionality as part of the Activity Stream project. It can be enabled (or disabled) -via the browser.newtabpage.activity-stream.enabled pref. +functionality as part of the Activity Stream project. The files in this directory, including vendor dependencies, are imported from the system-addon directory in https://github.com/mozilla/activity-stream. diff --git a/browser/extensions/activity-stream/bootstrap.js b/browser/extensions/activity-stream/bootstrap.js index e84659dd1def..070995ca492a 100644 --- a/browser/extensions/activity-stream/bootstrap.js +++ b/browser/extensions/activity-stream/bootstrap.js @@ -9,7 +9,6 @@ Cu.importGlobalProperties(["fetch"]); ChromeUtils.defineModuleGetter(this, "Services", "resource://gre/modules/Services.jsm"); -const ACTIVITY_STREAM_ENABLED_PREF = "browser.newtabpage.activity-stream.enabled"; const BROWSER_READY_NOTIFICATION = "sessionstore-windows-restored"; const PREF_CHANGED_TOPIC = "nsPref:changed"; const REASON_SHUTDOWN_ON_PREF_CHANGE = "PREF_OFF"; @@ -47,8 +46,7 @@ XPCOMUtils.defineLazyModuleGetter(this, "ActivityStream", /** * init - Initializes an instance of ActivityStream. This could be called by - * the startup() function exposed by bootstrap.js, or it could be called - * when ACTIVITY_STREAM_ENABLED_PREF is changed from false to true. + * the startup() function exposed by bootstrap.js. * * @param {string} reason - Reason for initialization. Could be install, upgrade, or PREF_ON */ @@ -68,8 +66,7 @@ function init(reason) { /** * uninit - Uninitializes the activityStream instance, if it exsits.This could be - * called by the shutdown() function exposed by bootstrap.js, or it could - * be called when ACTIVITY_STREAM_ENABLED_PREF is changed from true to false. + * called by the shutdown() function exposed by bootstrap.js. * * @param {type} reason Reason for uninitialization. Could be uninstall, upgrade, or PREF_OFF */ @@ -81,18 +78,6 @@ function uninit(reason) { } } -/** - * onPrefChanged - handler for changes to ACTIVITY_STREAM_ENABLED_PREF - * - */ -function onPrefChanged() { - if (Services.prefs.getBoolPref(ACTIVITY_STREAM_ENABLED_PREF, false)) { - init(REASON_STARTUP_ON_PREF_CHANGE); - } else { - uninit(REASON_SHUTDOWN_ON_PREF_CHANGE); - } -} - /** * Check if an old pref has a custom value to migrate. Clears the pref so that * it's the default after migrating (to avoid future need to migrate). @@ -130,14 +115,7 @@ function migratePref(oldPrefName, cbIfNotDefault) { */ function onBrowserReady() { waitingForBrowserReady = false; - - // Listen for changes to the pref that enables Activity Stream - Services.prefs.addObserver(ACTIVITY_STREAM_ENABLED_PREF, observe); // eslint-disable-line no-use-before-define - - // Only initialize if the pref is true - if (Services.prefs.getBoolPref(ACTIVITY_STREAM_ENABLED_PREF, false)) { - init(startupReason); - } + init(startupReason); // Do a one time migration of Tiles about:newtab prefs that have been modified migratePref("browser.newtabpage.rows", rows => { @@ -165,11 +143,6 @@ function observe(subject, topic, data) { // Avoid running synchronously during this event that's used for timing Services.tm.dispatchToMainThread(() => onBrowserReady()); break; - case PREF_CHANGED_TOPIC: - if (data === ACTIVITY_STREAM_ENABLED_PREF) { - onPrefChanged(); - } - break; } } @@ -201,9 +174,6 @@ this.shutdown = function shutdown(data, reason) { // Stop waiting for browser to be ready if (waitingForBrowserReady) { Services.obs.removeObserver(observe, BROWSER_READY_NOTIFICATION); - } else { - // Stop listening to the pref that enables Activity Stream - Services.prefs.removeObserver(ACTIVITY_STREAM_ENABLED_PREF, observe); } // Unload any add-on modules that might might have been imported diff --git a/browser/extensions/activity-stream/test/functional/mochitest/browser_as_load_location.js b/browser/extensions/activity-stream/test/functional/mochitest/browser_as_load_location.js index 8382499b0f13..c596f703d79b 100644 --- a/browser/extensions/activity-stream/test/functional/mochitest/browser_as_load_location.js +++ b/browser/extensions/activity-stream/test/functional/mochitest/browser_as_load_location.js @@ -36,18 +36,3 @@ add_task(async function checkActivityStreamNotPreloadedLoad() { // Run a second time from a preloaded browser add_task(checkActivityStreamLoads); - -// Test with activity stream off -async function checkNotActivityStreamLoads() { - await SpecialPowers.pushPrefEnv({set: [["browser.newtabpage.activity-stream.enabled", false]]}); - await checkNewtabLoads("body:not(.activity-stream)", "Got Element not for activity-stream"); -} - -// Run a first time not from a preloaded browser -add_task(async function checkNotActivityStreamNotPreloadedLoad() { - gBrowser.removePreloadedBrowser(); - await checkNotActivityStreamLoads(); -}); - -// Run a second time from a preloaded browser -add_task(checkNotActivityStreamLoads); diff --git a/browser/extensions/activity-stream/test/functional/mochitest/head.js b/browser/extensions/activity-stream/test/functional/mochitest/head.js index b2aed3d2b3da..a152fcc5924c 100644 --- a/browser/extensions/activity-stream/test/functional/mochitest/head.js +++ b/browser/extensions/activity-stream/test/functional/mochitest/head.js @@ -10,12 +10,6 @@ function pushPrefs(...prefs) { return SpecialPowers.pushPrefEnv({set: prefs}); } -// Activity Stream tests expect it to be enabled, and make sure to clear out any -// preloaded browsers that might have about:newtab that we don't want to test -const ACTIVITY_STREAM_PREF = "browser.newtabpage.activity-stream.enabled"; -pushPrefs([ACTIVITY_STREAM_PREF, true]); -gBrowser.removePreloadedBrowser(); - async function clearHistoryAndBookmarks() { // eslint-disable-line no-unused-vars await PlacesUtils.bookmarks.eraseEverything(); await PlacesUtils.history.clear(); diff --git a/browser/extensions/onboarding/test/browser/browser_onboarding_accessibility.js b/browser/extensions/onboarding/test/browser/browser_onboarding_accessibility.js index dec23934b70d..8ae5f75ea3e9 100644 --- a/browser/extensions/onboarding/test/browser/browser_onboarding_accessibility.js +++ b/browser/extensions/onboarding/test/browser/browser_onboarding_accessibility.js @@ -30,25 +30,6 @@ add_task(async function test_onboarding_overlay_button() { await BrowserTestUtils.removeTab(tab); }); -add_task(async function test_onboarding_overlay_button_no_activity_steam() { - /* https://bugzilla.mozilla.org/show_bug.cgi?id=1393564 */ - resetOnboardingDefaultState(); - Preferences.set("browser.newtabpage.activity-stream.enabled", false); - - info("Wait for onboarding overlay loaded"); - let tab = await openTab(ABOUT_NEWTAB_URL); - let browser = tab.linkedBrowser; - await promiseOnboardingOverlayLoaded(browser); - - info("Click on overlay button and ensure dialog opens"); - await BrowserTestUtils.synthesizeMouseAtCenter("#onboarding-overlay-button", - {}, browser); - await promiseOnboardingOverlayOpened(browser); - - Preferences.reset("browser.newtabpage.activity-stream.enabled"); - await BrowserTestUtils.removeTab(tab); -}); - add_task(async function test_onboarding_notification_bar() { resetOnboardingDefaultState(); skipMuteNotificationOnFirstSession(); diff --git a/dom/base/test/browser_messagemanager_loadprocessscript.js b/dom/base/test/browser_messagemanager_loadprocessscript.js index 0154d0afaf00..80072e29ab89 100644 --- a/dom/base/test/browser_messagemanager_loadprocessscript.js +++ b/dom/base/test/browser_messagemanager_loadprocessscript.js @@ -7,13 +7,8 @@ function checkBaseProcessCount(description) { const {childCount} = ppmm; // With preloaded activity-stream, process count is a bit undeterministic, so // allow for some variation - if (Services.prefs.getBoolPref("browser.newtabpage.activity-stream.enabled")) { - const extraCount = BASE_NUMBER_OF_PROCESSES + 1; - ok(childCount === BASE_NUMBER_OF_PROCESSES || childCount === extraCount, `${description} (${BASE_NUMBER_OF_PROCESSES} or ${extraCount})`); - } - else { - is(childCount, BASE_NUMBER_OF_PROCESSES, `${description} (${BASE_NUMBER_OF_PROCESSES})`); - } + const extraCount = BASE_NUMBER_OF_PROCESSES + 1; + ok(childCount === BASE_NUMBER_OF_PROCESSES || childCount === extraCount, `${description} (${BASE_NUMBER_OF_PROCESSES} or ${extraCount})`); } function processScript() {