Bug 1433324 - Part 3. Assume true for browser.newtabpage.activity-stream.enabled. r=ursula

MozReview-Commit-ID: KMgNw5QsMIX

--HG--
extra : rebase_source : b3f3e2dbd568e88c0e8461fb4bfadbbdd9baaa99
This commit is contained in:
Ed Lee 2018-02-13 16:53:50 -08:00
Родитель 4632096315
Коммит 6497dc1292
23 изменённых файлов: 60 добавлений и 275 удалений

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

@ -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);

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

@ -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;

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

@ -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.");
});
});

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

@ -11,7 +11,7 @@ requestLongerTimeout(2);
function frame_script() {
content.document.body.innerHTML = `
<a href="about:home" target="_blank" id="testAnchor">Open a window</a>
<a href="http://example.com/" target="_blank" id="testAnchor">Open a window</a>
`;
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.");

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

@ -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

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

@ -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();

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

@ -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<nsIIOService> 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<nsIAboutNewTabService> 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;
}

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

@ -24,11 +24,6 @@ public:
protected:
virtual ~AboutRedirector() {}
private:
static bool sActivityStreamEnabled;
static void LoadActivityStreamPrefs();
};
} // namespace browser

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

@ -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);

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

@ -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"],

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

@ -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);

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

@ -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
}

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

@ -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;
}

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

@ -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);

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

@ -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");
});
});

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

@ -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();

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

@ -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" };

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

@ -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.

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

@ -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

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

@ -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 <body> 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);

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

@ -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();

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

@ -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();

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

@ -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() {