--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -1190,30 +1190,18 @@ pref("browser.newtabpage.rows", 3);
pref("browser.newtabpage.columns", 5);
// directory tiles download URL
pref("browser.newtabpage.directory.source", "https://tiles.services.mozilla.com/v3/links/fetch/%LOCALE%/%CHANNEL%");
// endpoint to send newtab click and view pings
pref("browser.newtabpage.directory.ping", "https://tiles.services.mozilla.com/v3/links/");
-// activates the remote-hosted newtab page
-pref("browser.newtabpage.remote", false);
-
-// remote newtab version targeted
-pref("browser.newtabpage.remote.version", "1");
-
-// Toggles endpoints allowed for remote newtab communications
-pref("browser.newtabpage.remote.mode", "production");
-
-// content-signature tests for remote newtab
-pref("browser.newtabpage.remote.content-signing-test", false);
-
-// verification keys for remote-hosted newtab page
-pref("browser.newtabpage.remote.keys", "");
+// activates Activity Stream
+pref("browser.newtabpage.activity-stream.enabled", false);
// Enable the DOM fullscreen API.
pref("full-screen-api.enabled", true);
// Startup Crash Tracking
// number of startup crashes that can occur before starting into safe mode automatically
// (this pref has no effect if more than 6 hours have passed since the last crash)
pref("toolkit.startup.max_resumed_crashes", 3);
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -2534,21 +2534,18 @@ function URLBarSetURI(aURI) {
if (value == null) {
let uri = aURI || gBrowser.currentURI;
// Strip off "wyciwyg://" and passwords for the location bar
try {
uri = Services.uriFixup.createExposableURI(uri);
} catch (e) {}
// Replace initial page URIs with an empty string
- // 1. only if there's no opener (bug 370555).
- // 2. if remote newtab is enabled and it's the default remote newtab page
- let defaultRemoteURL = gAboutNewTabService.remoteEnabled &&
- uri.spec === gAboutNewTabService.newTabURL;
- if ((gInitialPages.includes(uri.spec) || defaultRemoteURL) &&
+ // only if there's no opener (bug 370555).
+ if (gInitialPages.includes(uri.spec) &&
checkEmptyPageOrigin(gBrowser.selectedBrowser, uri)) {
value = "";
} else {
// We should deal with losslessDecodeURI throwing for exotic URIs
try {
value = losslessDecodeURI(uri);
} catch (ex) {
value = "about:blank";
--- a/browser/components/about/AboutRedirector.cpp
+++ b/browser/components/about/AboutRedirector.cpp
@@ -144,26 +144,16 @@ AboutRedirector::NewChannel(nsIURI* aURI
if (path.EqualsLiteral("newtab")) {
// let the aboutNewTabService decide where to redirect
nsCOMPtr<nsIAboutNewTabService> aboutNewTabService =
do_GetService("@mozilla.org/browser/aboutnewtab-service;1", &rv);
NS_ENSURE_SUCCESS(rv, rv);
rv = aboutNewTabService->GetDefaultURL(url);
NS_ENSURE_SUCCESS(rv, rv);
-
- // if about:newtab points to an external resource we have to make sure
- // the content is signed and trusted
- bool remoteEnabled = false;
- rv = aboutNewTabService->GetRemoteEnabled(&remoteEnabled);
- NS_ENSURE_SUCCESS(rv, rv);
- if (remoteEnabled) {
- NS_ENSURE_ARG_POINTER(aLoadInfo);
- aLoadInfo->SetVerifySignedContent(true);
- }
}
// fall back to the specified url in the map
if (url.IsEmpty()) {
url.AssignASCII(redir.url);
}
nsCOMPtr<nsIChannel> tempChannel;
nsCOMPtr<nsIURI> tempURI;
--- a/browser/components/newtab/NewTabPrefsProvider.jsm
+++ b/browser/components/newtab/NewTabPrefsProvider.jsm
@@ -12,27 +12,23 @@ Cu.import("resource://gre/modules/XPCOMU
XPCOMUtils.defineLazyGetter(this, "EventEmitter", function() {
const {EventEmitter} = Cu.import("resource://devtools/shared/event-emitter.js", {});
return EventEmitter;
});
// Supported prefs and data type
const gPrefsMap = new Map([
- ["browser.newtabpage.remote", "bool"],
- ["browser.newtabpage.remote.mode", "str"],
- ["browser.newtabpage.remote.version", "str"],
+ ["browser.newtabpage.activity-stream.enabled", "bool"],
["browser.newtabpage.enabled", "bool"],
["browser.newtabpage.enhanced", "bool"],
["browser.newtabpage.introShown", "bool"],
["browser.newtabpage.updateIntroShown", "bool"],
["browser.newtabpage.pinned", "str"],
["browser.newtabpage.blocked", "str"],
- ["intl.locale.matchOS", "bool"],
- ["general.useragent.locale", "localized"],
["browser.search.hiddenOneOffs", "str"],
]);
// prefs that are important for the newtab page
const gNewtabPagePrefs = new Set([
"browser.newtabpage.enabled",
"browser.newtabpage.enhanced",
"browser.newtabpage.pinned",
--- a/browser/components/newtab/aboutNewTabService.js
+++ b/browser/components/newtab/aboutNewTabService.js
@@ -1,289 +1,168 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-/* globals XPCOMUtils, NewTabPrefsProvider, Services,
- Locale, UpdateUtils, NewTabRemoteResources
-*/
+/* globals XPCOMUtils, NewTabPrefsProvider, Services */
"use strict";
const {utils: Cu, interfaces: Ci} = Components;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
-XPCOMUtils.defineLazyModuleGetter(this, "UpdateUtils",
- "resource://gre/modules/UpdateUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "NewTabPrefsProvider",
"resource:///modules/NewTabPrefsProvider.jsm");
-XPCOMUtils.defineLazyModuleGetter(this, "Locale",
- "resource://gre/modules/Locale.jsm");
-XPCOMUtils.defineLazyModuleGetter(this, "NewTabRemoteResources",
- "resource:///modules/NewTabRemoteResources.jsm");
const LOCAL_NEWTAB_URL = "chrome://browser/content/newtab/newTab.xhtml";
-const REMOTE_NEWTAB_PATH = "/newtab/v%VERSION%/%CHANNEL%/%LOCALE%/index.html";
+const ACTIVITY_STREAM_URL = "resource://activity-stream/data/content/activity-stream.html";
const ABOUT_URL = "about:newtab";
-// Pref that tells if remote newtab is enabled
-const PREF_REMOTE_ENABLED = "browser.newtabpage.remote";
-
-// Pref branch necesssary for testing
-const PREF_REMOTE_CS_TEST = "browser.newtabpage.remote.content-signing-test";
-
-// The preference that tells whether to match the OS locale
-const PREF_MATCH_OS_LOCALE = "intl.locale.matchOS";
-
-// The preference that tells what locale the user selected
-const PREF_SELECTED_LOCALE = "general.useragent.locale";
-
-// The preference that tells what remote mode is enabled.
-const PREF_REMOTE_MODE = "browser.newtabpage.remote.mode";
-
-// The preference that tells which remote version is expected.
-const PREF_REMOTE_VERSION = "browser.newtabpage.remote.version";
-
-const VALID_CHANNELS = new Set(["esr", "release", "beta", "aurora", "nightly"]);
+// Pref that tells if activity stream is enabled
+const PREF_ACTIVITY_STREAM_ENABLED = "browser.newtabpage.activity-stream.enabled";
function AboutNewTabService() {
- NewTabPrefsProvider.prefs.on(PREF_REMOTE_ENABLED, this._handleToggleEvent.bind(this));
-
- this._updateRemoteMaybe = this._updateRemoteMaybe.bind(this);
-
- // trigger remote change if needed, according to pref
- this.toggleRemote(Services.prefs.getBoolPref(PREF_REMOTE_ENABLED));
+ NewTabPrefsProvider.prefs.on(PREF_ACTIVITY_STREAM_ENABLED, this._handleToggleEvent.bind(this));
+ this.toggleActivityStream(Services.prefs.getBoolPref(PREF_ACTIVITY_STREAM_ENABLED));
}
/*
* A service that allows for the overriding, at runtime, of the newtab page's url.
- * Additionally, the service manages pref state between a remote and local newtab page.
+ * 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.
*
* 1. Browser chrome access:
*
* When the user issues a command to open a new tab page, usually clicking a button
* in the browser chrome or using shortcut keys, the browser chrome code invokes the
* service to obtain the newtab URL. It then loads that URL in a new tab.
*
* When not overridden, the default URL emitted by the service is "about:newtab".
* When overridden, it returns the overriden URL.
*
* 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 remote one, based on the browser.newtabpage.remote pref.
+ * two URLs, a chrome or the activity stream one, based on the
+ * browser.newtabpage.activity-stream.enabled pref.
*
* NOTE: "about:newtab" will always result in a default newtab page, and never an overridden URL.
*
* Access patterns:
*
* The behavior is different when accessing the service via browser chrome or via redirector
* largely to maintain compatibility with expectations of add-on developers.
*
* Loading a chrome resource, or an about: URL in the redirector with either the
* LOAD_NORMAL or LOAD_REPLACE flags yield unexpected behaviors, so a roundtrip
* to the redirector from browser chrome is avoided.
*/
AboutNewTabService.prototype = {
_newTabURL: ABOUT_URL,
- _remoteEnabled: false,
- _remoteURL: null,
+ _activityStreamEnabled: false,
_overridden: false,
classID: Components.ID("{dfcd2adc-7867-4d3a-ba70-17501f208142}"),
QueryInterface: XPCOMUtils.generateQI([Ci.nsIAboutNewTabService]),
_xpcom_categories: [{
service: true
}],
_handleToggleEvent(prefName, stateEnabled, forceState) { // jshint unused:false
- if (this.toggleRemote(stateEnabled, forceState)) {
+ if (this.toggleActivityStream(stateEnabled, forceState)) {
Services.obs.notifyObservers(null, "newtab-url-changed", ABOUT_URL);
}
},
/**
- * React to changes to the remote newtab pref.
+ * React to changes to the activity stream pref.
*
- * If browser.newtabpage.remote is true, this will change the default URL to the
- * remote newtab page URL. If browser.newtabpage.remote is false, the default URL
+ * 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.
*
* This will only act if there is a change of state and if not overridden.
*
* @returns {Boolean} Returns if there has been a state change
*
- * @param {Boolean} stateEnabled remote state to set to
+ * @param {Boolean} stateEnabled activity stream enabled state to set to
* @param {Boolean} forceState force state change
*/
- toggleRemote(stateEnabled, forceState) {
+ toggleActivityStream(stateEnabled, forceState) {
- if (!forceState && (this._overriden || stateEnabled === this._remoteEnabled)) {
+ if (!forceState && (this.overridden || stateEnabled === this.activityStreamEnabled)) {
// exit there is no change of state
return false;
}
-
- let csTest = Services.prefs.getBoolPref(PREF_REMOTE_CS_TEST);
if (stateEnabled) {
- if (!csTest) {
- this._remoteURL = this.generateRemoteURL();
- } else {
- this._remoteURL = this._newTabURL;
- }
- NewTabPrefsProvider.prefs.on(
- PREF_SELECTED_LOCALE,
- this._updateRemoteMaybe);
- NewTabPrefsProvider.prefs.on(
- PREF_MATCH_OS_LOCALE,
- this._updateRemoteMaybe);
- NewTabPrefsProvider.prefs.on(
- PREF_REMOTE_MODE,
- this._updateRemoteMaybe);
- NewTabPrefsProvider.prefs.on(
- PREF_REMOTE_VERSION,
- this._updateRemoteMaybe);
- this._remoteEnabled = true;
+ this._activityStreamEnabled = true;
} else {
- NewTabPrefsProvider.prefs.off(PREF_SELECTED_LOCALE, this._updateRemoteMaybe);
- NewTabPrefsProvider.prefs.off(PREF_MATCH_OS_LOCALE, this._updateRemoteMaybe);
- NewTabPrefsProvider.prefs.off(PREF_REMOTE_MODE, this._updateRemoteMaybe);
- NewTabPrefsProvider.prefs.off(PREF_REMOTE_VERSION, this._updateRemoteMaybe);
- this._remoteEnabled = false;
+ this._activityStreamEnabled = false;
}
- if (!csTest) {
- this._newTabURL = ABOUT_URL;
- }
+ this._newtabURL = ABOUT_URL;
return true;
},
/*
- * Generate a default url based on remote mode, version, locale and update channel
- */
- generateRemoteURL() {
- let releaseName = this.releaseFromUpdateChannel(UpdateUtils.UpdateChannel);
- let path = REMOTE_NEWTAB_PATH
- .replace("%VERSION%", this.remoteVersion)
- .replace("%LOCALE%", Locale.getLocale())
- .replace("%CHANNEL%", releaseName);
- let mode = Services.prefs.getCharPref(PREF_REMOTE_MODE);
- if (!(mode in NewTabRemoteResources.MODE_CHANNEL_MAP)) {
- mode = "production";
- }
- return NewTabRemoteResources.MODE_CHANNEL_MAP[mode].origin + path;
- },
-
- /*
* Returns the default URL.
*
- * This URL only depends on the browser.newtabpage.remote pref. Overriding
+ * This URL only depends on the browser.newtabpage.activity-stream.enabled pref. Overriding
* the newtab page has no effect on the result of this function.
*
- * The result is also the remote URL if this is in a test (PREF_REMOTE_CS_TEST)
- *
- * @returns {String} the default newtab URL, remote or local depending on browser.newtabpage.remote
+ * @returns {String} the default newtab URL, activity-stream or regular depending on browser.newtabpage.activity-stream.enabled
*/
get defaultURL() {
- let csTest = Services.prefs.getBoolPref(PREF_REMOTE_CS_TEST);
- if (this._remoteEnabled || csTest) {
- return this._remoteURL;
+ if (this.activityStreamEnabled) {
+ return this.activityStreamURL;
}
return LOCAL_NEWTAB_URL;
},
- /*
- * Updates the remote location when the page is not overriden.
- *
- * Useful when there is a dependent pref change
- */
- _updateRemoteMaybe() {
- if (!this._remoteEnabled || this._overridden) {
- return;
- }
-
- let url = this.generateRemoteURL();
- if (url !== this._remoteURL) {
- this._remoteURL = url;
- Services.obs.notifyObservers(null, "newtab-url-changed",
- this._remoteURL);
- }
- },
-
- /**
- * Returns the release name from an Update Channel name
- *
- * @returns {String} a release name based on the update channel. Defaults to nightly
- */
- releaseFromUpdateChannel(channelName) {
- return VALID_CHANNELS.has(channelName) ? channelName : "nightly";
- },
-
get newTabURL() {
return this._newTabURL;
},
- get remoteVersion() {
- return Services.prefs.getCharPref(PREF_REMOTE_VERSION);
- },
-
- get remoteReleaseName() {
- return this.releaseFromUpdateChannel(UpdateUtils.UpdateChannel);
- },
-
set newTabURL(aNewTabURL) {
- let csTest = Services.prefs.getBoolPref(PREF_REMOTE_CS_TEST);
aNewTabURL = aNewTabURL.trim();
if (aNewTabURL === ABOUT_URL) {
// avoid infinite redirects in case one sets the URL to about:newtab
this.resetNewTabURL();
return;
} else if (aNewTabURL === "") {
aNewTabURL = "about:blank";
}
- let remoteURL = this.generateRemoteURL();
- let prefRemoteEnabled = Services.prefs.getBoolPref(PREF_REMOTE_ENABLED);
- let isResetLocal = !prefRemoteEnabled && aNewTabURL === LOCAL_NEWTAB_URL;
- let isResetRemote = prefRemoteEnabled && aNewTabURL === remoteURL;
- if (isResetLocal || isResetRemote) {
- if (this._overriden && !csTest) {
- // only trigger a reset if previously overridden and this is no test
- this.resetNewTabURL();
- }
- return;
- }
- // turn off remote state if needed
- if (!csTest) {
- this.toggleRemote(false);
- } else {
- // if this is a test, we want the remoteURL to be set
- this._remoteURL = aNewTabURL;
- }
+ this.toggleActivityStream(false);
this._newTabURL = aNewTabURL;
this._overridden = true;
Services.obs.notifyObservers(null, "newtab-url-changed", this._newTabURL);
},
get overridden() {
return this._overridden;
},
- get remoteEnabled() {
- return this._remoteEnabled;
+ get activityStreamEnabled() {
+ return this._activityStreamEnabled;
+ },
+
+ get activityStreamURL() {
+ return ACTIVITY_STREAM_URL;
},
resetNewTabURL() {
this._overridden = false;
this._newTabURL = ABOUT_URL;
- this.toggleRemote(Services.prefs.getBoolPref(PREF_REMOTE_ENABLED), true);
+ this.toggleActivityStream(Services.prefs.getBoolPref(PREF_ACTIVITY_STREAM_ENABLED), true);
Services.obs.notifyObservers(null, "newtab-url-changed", this._newTabURL);
}
};
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([AboutNewTabService]);
--- a/browser/components/newtab/nsIAboutNewTabService.idl
+++ b/browser/components/newtab/nsIAboutNewTabService.idl
@@ -14,50 +14,34 @@ interface nsIAboutNewTabService : nsISup
{
/**
* Returns the url of the resource for the newtab page if not overridden,
* otherwise a string represenation of the new URL.
*/
attribute ACString newTabURL;
/**
- * Returns the default URL (remote or local depending on pref)
+ * Returns the default URL (local or activity stream depending on pref)
*/
attribute ACString defaultURL;
/**
* Returns true if the default resource got overridden.
*/
readonly attribute bool overridden;
/**
- * Returns true if the default resource is remotely hosted and isn't
+ * Returns true if the default resource is activity stream and isn't
* overridden
*/
- readonly attribute bool remoteEnabled;
-
-
- /**
- * Returns the version of the remote newtab page expected
- */
- readonly attribute ACString remoteVersion;
+ readonly attribute bool activityStreamEnabled;
/**
- * Returns the expected channel for the remote the newtab page
- */
- readonly attribute ACString remoteReleaseName;
-
- /**
- * Generates and returns the remote newtab page url
+ * Returns the activity stream resource URL for the newtab page
*/
- ACString generateRemoteURL();
-
- /**
- * Returns a remote new tab release name given an update channel name
- */
- ACString releaseFromUpdateChannel(in ACString channelName);
+ readonly attribute ACString activityStreamURL;
/**
* Resets to the default resource and also resets the
* overridden attribute to false.
*/
void resetNewTabURL();
};
--- a/browser/components/newtab/tests/browser/browser.ini
+++ b/browser/components/newtab/tests/browser/browser.ini
@@ -1,16 +1,8 @@
[DEFAULT]
support-files =
blue_page.html
dummy_page.html
- newtabwebchannel_basic.html
- newtabmessages_places.html
- newtabmessages_prefs.html
- newtabmessages_preview.html
- newtabmessages_search.html
[browser_PreviewProvider.js]
[browser_remotenewtab_pageloads.js]
[browser_newtab_overrides.js]
-[browser_newtabmessages.js]
-skip-if = true # Bug 1271177, bug 1262719
-[browser_newtabwebchannel.js]
--- a/browser/components/newtab/tests/browser/browser_newtab_overrides.js
+++ b/browser/components/newtab/tests/browser/browser_newtab_overrides.js
@@ -18,17 +18,17 @@ Cu.import("resource://gre/modules/XPCOMU
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/Preferences.jsm");
XPCOMUtils.defineLazyServiceGetter(this, "aboutNewTabService",
"@mozilla.org/browser/aboutnewtab-service;1",
"nsIAboutNewTabService");
registerCleanupFunction(function() {
- Services.prefs.setBoolPref("browser.newtabpage.remote", false);
+ Services.prefs.setBoolPref("browser.newtabpage.activity-stream.enabled", false);
aboutNewTabService.resetNewTabURL();
});
/*
* Tests that the default newtab page is always returned when one types "about:newtab" in the URL bar,
* even when overridden.
*/
add_task(function* redirector_ignores_override() {
deleted file mode 100644
--- a/browser/components/newtab/tests/browser/browser_newtabmessages.js
+++ /dev/null
@@ -1,222 +0,0 @@
-/* globals Cu, XPCOMUtils, Preferences, is, registerCleanupFunction, NewTabWebChannel,
-PlacesTestUtils, NewTabMessages, ok, Services, PlacesUtils, NetUtil, Task */
-
-"use strict";
-
-Cu.import("resource://gre/modules/Preferences.jsm");
-Cu.import("resource://gre/modules/Services.jsm");
-Cu.import("resource://gre/modules/Task.jsm");
-XPCOMUtils.defineLazyModuleGetter(this, "NewTabWebChannel",
- "resource:///modules/NewTabWebChannel.jsm");
-XPCOMUtils.defineLazyModuleGetter(this, "NewTabMessages",
- "resource:///modules/NewTabMessages.jsm");
-XPCOMUtils.defineLazyModuleGetter(this, "PlacesTestUtils",
- "resource://testing-common/PlacesTestUtils.jsm");
-
-let setup = Task.async(function*() {
- Preferences.set("browser.newtabpage.enhanced", true);
- Preferences.set("browser.newtabpage.remote.mode", "test");
- Preferences.set("browser.newtabpage.remote", true);
- NewTabMessages.init();
- yield PlacesTestUtils.clearHistory();
-});
-
-let cleanup = Task.async(function*() {
- NewTabMessages.uninit();
- Preferences.set("browser.newtabpage.remote", false);
- Preferences.set("browser.newtabpage.remote.mode", "production");
-});
-registerCleanupFunction(cleanup);
-
-/*
- * Sanity tests for pref messages
- */
-add_task(function* prefMessages_request() {
- yield setup();
-
- let testURL = "https://example.com/browser/browser/components/newtab/tests/browser/newtabmessages_prefs.html";
-
- let tabOptions = {
- gBrowser,
- url: testURL
- };
-
- let prefResponseAck = new Promise(resolve => {
- NewTabWebChannel.once("responseAck", () => {
- ok(true, "a request response has been received");
- resolve();
- });
- });
-
- yield BrowserTestUtils.withNewTab(tabOptions, function*() {
- yield prefResponseAck;
- let prefChangeAck = new Promise(resolve => {
- NewTabWebChannel.once("responseAck", () => {
- ok(true, "a change response has been received");
- resolve();
- });
- });
- Preferences.set("browser.newtabpage.enhanced", false);
- yield prefChangeAck;
- });
- yield cleanup();
-});
-
-/*
- * Sanity tests for preview messages
- */
-add_task(function* previewMessages_request() {
- yield setup();
- var oldEnabledPref = Services.prefs.getBoolPref("browser.pagethumbnails.capturing_disabled");
- Services.prefs.setBoolPref("browser.pagethumbnails.capturing_disabled", false);
-
- let testURL = "https://example.com/browser/browser/components/newtab/tests/browser/newtabmessages_preview.html";
-
- let tabOptions = {
- gBrowser,
- url: testURL
- };
-
- let previewResponseAck = new Promise(resolve => {
- NewTabWebChannel.once("responseAck", () => {
- ok(true, "a request response has been received");
- resolve();
- });
- });
-
- yield BrowserTestUtils.withNewTab(tabOptions, function*() {
- yield previewResponseAck;
- });
- yield cleanup();
- Services.prefs.setBoolPref("browser.pagethumbnails.capturing_disabled", oldEnabledPref);
-});
-
-/*
- * Sanity tests for places messages
- */
-add_task(function* placesMessages_request() {
- yield setup();
- let testURL = "https://example.com/browser/browser/components/newtab/tests/browser/newtabmessages_places.html";
-
- // url prefix for test history population
- const TEST_URL = "https://mozilla.com/";
- // time when the test starts execution
- const TIME_NOW = (new Date()).getTime();
-
- // utility function to compute past timestamp
- function timeDaysAgo(numDays) {
- return TIME_NOW - (numDays * 24 * 60 * 60 * 1000);
- }
-
- // utility function to make a visit for insertion into places db
- function makeVisit(index, daysAgo, isTyped, domain = TEST_URL) {
- let {
- TRANSITION_TYPED,
- TRANSITION_LINK
- } = PlacesUtils.history;
-
- return {
- uri: NetUtil.newURI(`${domain}${index}`),
- visitDate: timeDaysAgo(daysAgo),
- transition: (isTyped) ? TRANSITION_TYPED : TRANSITION_LINK,
- };
- }
-
- yield PlacesTestUtils.clearHistory();
-
- // all four visits must come from different domains to avoid deduplication
- let visits = [
- makeVisit(0, 0, true, "http://bar.com/"), // frecency 200, today
- makeVisit(1, 0, true, "http://foo.com/"), // frecency 200, today
- makeVisit(2, 2, true, "http://buz.com/"), // frecency 200, 2 days ago
- makeVisit(3, 2, false, "http://aaa.com/"), // frecency 10, 2 days ago, transition
- ];
-
- yield PlacesTestUtils.addVisits(visits);
-
- /** Test Begins **/
-
- let tabOptions = {
- gBrowser,
- url: testURL
- };
-
- let placesResponseAck = new Promise(resolve => {
- NewTabWebChannel.once("numItemsAck", (_, msg) => {
- ok(true, "a request response has been received");
- is(msg.data, visits.length + 1, "received an expected number of history items");
- resolve();
- });
- });
-
- yield BrowserTestUtils.withNewTab(tabOptions, function*() {
- yield placesResponseAck;
- ok(true, "a change response has been received");
- let placesChangeAck = new Promise(resolve => {
- NewTabWebChannel.once("clearHistoryAck", (_, msg) => {
- is(msg.data, "clearHistory", "a clear history message has been received");
- resolve();
- });
- });
- yield PlacesTestUtils.clearHistory();
- yield placesChangeAck;
- });
- yield cleanup();
-});
-
-/*
- * Sanity tests for search messages
- */
-add_task(function* searchMessages_request() {
- yield setup();
- let testURL = "https://example.com/browser/browser/components/newtab/tests/browser/newtabmessages_search.html";
-
- // create dummy test engines
- Services.search.addEngineWithDetails("Engine1", "", "", "", "GET",
- "http://example.com/?q={searchTerms}");
- Services.search.addEngineWithDetails("Engine2", "", "", "", "GET",
- "http://example.com/?q={searchTerms}");
-
- let tabOptions = {
- gBrowser,
- url: testURL
- };
-
- let UIStringsResponseAck = new Promise(resolve => {
- NewTabWebChannel.once("UIStringsAck", (_, msg) => {
- ok(true, "a search request response for UI string has been received");
- ok(msg.data, "received the UI Strings");
- resolve();
- });
- });
- let suggestionsResponseAck = new Promise(resolve => {
- NewTabWebChannel.once("suggestionsAck", (_, msg) => {
- ok(true, "a search request response for suggestions has been received");
- ok(msg.data, "received the suggestions");
- resolve();
- });
- });
- let stateResponseAck = new Promise(resolve => {
- NewTabWebChannel.once("stateAck", (_, msg) => {
- ok(true, "a search request response for state has been received");
- ok(msg.data, "received a state object");
- resolve();
- });
- });
- let currentEngineResponseAck = new Promise(resolve => {
- NewTabWebChannel.once("currentEngineAck", (_, msg) => {
- ok(true, "a search request response for current engine has been received");
- ok(msg.data, "received a current engine");
- resolve();
- });
- });
-
- yield BrowserTestUtils.withNewTab(tabOptions, function*() {
- yield UIStringsResponseAck;
- yield suggestionsResponseAck;
- yield stateResponseAck;
- yield currentEngineResponseAck;
- });
-
- cleanup();
-});
deleted file mode 100644
--- a/browser/components/newtab/tests/browser/browser_newtabwebchannel.js
+++ /dev/null
@@ -1,251 +0,0 @@
-/* globals XPCOMUtils, Cu, Preferences, NewTabWebChannel, is, registerCleanupFunction */
-
-"use strict";
-
-Cu.import("resource://gre/modules/Preferences.jsm");
-Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-
-XPCOMUtils.defineLazyModuleGetter(this, "NewTabWebChannel",
- "resource:///modules/NewTabWebChannel.jsm");
-XPCOMUtils.defineLazyModuleGetter(this, "NewTabMessages",
- "resource:///modules/NewTabMessages.jsm");
-
-const TEST_URL = "https://example.com/browser/browser/components/newtab/tests/browser/newtabwebchannel_basic.html";
-const TEST_URL_2 = "http://mochi.test:8888/browser/browser/components/newtab/tests/browser/newtabwebchannel_basic.html";
-
-function setup(mode = "test") {
- Preferences.set("browser.newtabpage.remote.mode", mode);
- Preferences.set("browser.newtabpage.remote", true);
- NewTabWebChannel.init();
- NewTabMessages.init();
-}
-
-function cleanup() {
- NewTabMessages.uninit();
- NewTabWebChannel.uninit();
- Preferences.set("browser.newtabpage.remote", false);
- Preferences.set("browser.newtabpage.remote.mode", "production");
-}
-registerCleanupFunction(cleanup);
-
-/*
- * Tests flow of messages from newtab to chrome and chrome to newtab
- */
-add_task(function* open_webchannel_basic() {
- setup();
-
- let tabOptions = {
- gBrowser,
- url: TEST_URL
- };
-
- let messagePromise = new Promise(resolve => {
- NewTabWebChannel.once("foo", function(name, msg) {
- is(name, "foo", "Correct message type sent: foo");
- is(msg.data, "bar", "Correct data sent: bar");
- resolve(msg.target);
- });
- });
-
- let replyPromise = new Promise(resolve => {
- NewTabWebChannel.once("reply", function(name, msg) {
- is(name, "reply", "Correct message type sent: reply");
- is(msg.data, "quuz", "Correct data sent: quuz");
- resolve(msg.target);
- });
- });
-
- let unloadPromise = new Promise(resolve => {
- NewTabWebChannel.once("targetUnload", function(name) {
- is(name, "targetUnload", "Correct message type sent: targetUnload");
- resolve();
- });
- });
-
- is(NewTabWebChannel.numBrowsers, 0, "Sanity check");
- yield BrowserTestUtils.withNewTab(tabOptions, function*(browser) {
- let target = yield messagePromise;
- is(NewTabWebChannel.numBrowsers, 1, "One target expected");
- is(target.browser, browser, "Same browser");
- NewTabWebChannel.send("respond", null, target);
- yield replyPromise;
- });
-
- Cu.forceGC();
- is(NewTabWebChannel.numBrowsers, 0, "Sanity check");
- yield unloadPromise;
- cleanup();
-});
-
-/*
- * Tests message broadcast reaches all open newtab pages
- */
-add_task(function* webchannel_broadcast() {
- setup();
-
- let countingMessagePromise = new Promise(resolve => {
- let count = 0;
- NewTabWebChannel.on("foo", function test_message(name, msg) {
- count += 1;
- if (count === 2) {
- NewTabWebChannel.off("foo", test_message);
- resolve(msg.target);
- }
- });
- });
-
- let countingReplyPromise = new Promise(resolve => {
- let count = 0;
- NewTabWebChannel.on("reply", function test_message(name, msg) {
- count += 1;
- if (count === 2) {
- NewTabWebChannel.off("reply", test_message);
- resolve(msg.target);
- }
- });
- });
-
- let countingUnloadPromise = new Promise(resolve => {
- let count = 0;
- NewTabWebChannel.on("targetUnload", function test_message() {
- count += 1;
- if (count === 2) {
- NewTabWebChannel.off("targetUnload", test_message);
- resolve();
- }
- });
- });
-
- let tabs = [];
- is(NewTabWebChannel.numBrowsers, 0, "Sanity check");
- tabs.push(yield BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_URL));
- tabs.push(yield BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_URL));
-
- yield countingMessagePromise;
- is(NewTabWebChannel.numBrowsers, 2, "Two targets expected");
-
- NewTabWebChannel.broadcast("respond", null);
- yield countingReplyPromise;
-
- for (let tab of tabs) {
- yield BrowserTestUtils.removeTab(tab);
- }
- Cu.forceGC();
-
- is(NewTabWebChannel.numBrowsers, 0, "Sanity check");
- yield countingUnloadPromise;
- cleanup();
-});
-
-/*
- * Tests switching modes
- */
-add_task(function* webchannel_switch() {
- setup();
-
- function newMessagePromise() {
- return new Promise(resolve => {
- NewTabWebChannel.once("foo", function(name, msg) {
- resolve(msg.target);
- });
- });
- }
-
- let replyCount = 0;
- function newReplyPromise() {
- return new Promise(resolve => {
- NewTabWebChannel.on("reply", function() {
- replyCount += 1;
- resolve();
- });
- });
- }
-
- let unloadPromise = new Promise(resolve => {
- NewTabWebChannel.once("targetUnload", function() {
- resolve();
- });
- });
-
- let unloadAllPromise = new Promise(resolve => {
- NewTabWebChannel.once("targetUnloadAll", function() {
- resolve();
- });
- });
-
- let tabs = [];
- let messagePromise;
- is(NewTabWebChannel.numBrowsers, 0, "Sanity check");
-
- messagePromise = newMessagePromise();
- tabs.push(yield BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_URL));
- yield messagePromise;
- is(NewTabWebChannel.numBrowsers, 1, "Correct number of targets");
-
- messagePromise = newMessagePromise();
- Preferences.set("browser.newtabpage.remote.mode", "test2");
- tabs.push(yield BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_URL_2));
- yield unloadAllPromise;
- yield messagePromise;
- is(NewTabWebChannel.numBrowsers, 1, "Correct number of targets");
-
- NewTabWebChannel.broadcast("respond", null);
- yield newReplyPromise();
- is(replyCount, 1, "only current channel is listened to for replies");
-
- const webchannelWhitelistPref = "webchannel.allowObject.urlWhitelist";
- let origWhitelist = Services.prefs.getCharPref(webchannelWhitelistPref);
- let newWhitelist = origWhitelist + " http://mochi.test:8888";
- Services.prefs.setCharPref(webchannelWhitelistPref, newWhitelist);
- try {
- NewTabWebChannel.broadcast("respond_object", null);
- yield newReplyPromise();
- } finally {
- Services.prefs.clearUserPref(webchannelWhitelistPref);
- }
-
- for (let tab of tabs) {
- yield BrowserTestUtils.removeTab(tab);
- }
-
- Cu.forceGC();
- is(NewTabWebChannel.numBrowsers, 0, "Sanity check");
- yield unloadPromise;
- cleanup();
-});
-
-add_task(function* open_webchannel_reload() {
- setup();
-
- let tabOptions = {
- gBrowser,
- url: TEST_URL
- };
-
- let messagePromise = new Promise(resolve => {
- NewTabWebChannel.once("foo", function(name, msg) {
- is(name, "foo", "Correct message type sent: foo");
- is(msg.data, "bar", "Correct data sent: bar");
- resolve(msg.target);
- });
- });
- let unloadPromise = new Promise(resolve => {
- NewTabWebChannel.once("targetUnload", function() {
- resolve();
- });
- });
-
- is(NewTabWebChannel.numBrowsers, 0, "Sanity check");
- yield BrowserTestUtils.withNewTab(tabOptions, function*(browser) {
- let target = yield messagePromise;
- is(NewTabWebChannel.numBrowsers, 1, "One target expected");
- is(target.browser, browser, "Same browser");
-
- browser.reload();
- });
-
- Cu.forceGC();
- is(NewTabWebChannel.numBrowsers, 0, "Sanity check");
- yield unloadPromise;
- cleanup();
-});
deleted file mode 100644
--- a/browser/components/newtab/tests/browser/newtabmessages_places.html
+++ /dev/null
@@ -1,49 +0,0 @@
-<html>
- <head>
- <meta charset="utf8">
- <title>Newtab WebChannel test</title>
- </head>
- <body>
- <script>
- window.addEventListener("WebChannelMessageToContent", function(e) {
- if (e.detail.message) {
- let reply;
- switch (e.detail.message.type) {
- case "RECEIVE_FRECENT":
- reply = new window.CustomEvent("WebChannelMessageToChrome", {
- detail: JSON.stringify({
- id: "newtab",
- message: JSON.stringify({type: "numItemsAck", data: e.detail.message.data.length}),
- })
- });
- window.dispatchEvent(reply);
- break;
- case "RECEIVE_PLACES_CHANGE":
- if (e.detail.message.data.type === "clearHistory") {
- reply = new window.CustomEvent("WebChannelMessageToChrome", {
- detail: JSON.stringify({
- id: "newtab",
- message: JSON.stringify({type: "clearHistoryAck", data: e.detail.message.data.type}),
- })
- });
- window.dispatchEvent(reply);
- }
- break;
- }
- }
- }, true);
-
- document.onreadystatechange = function() {
- if (document.readyState === "complete") {
- let msg = new window.CustomEvent("WebChannelMessageToChrome", {
- detail: JSON.stringify({
- id: "newtab",
- message: JSON.stringify({type: "REQUEST_FRECENT"}),
- })
- });
- window.dispatchEvent(msg);
- }
- }
- </script>
- </body>
-</html>
deleted file mode 100644
--- a/browser/components/newtab/tests/browser/newtabmessages_prefs.html
+++ /dev/null
@@ -1,32 +0,0 @@
-<html>
- <head>
- <meta charset="utf8">
- <title>Newtab WebChannel test</title>
- </head>
- <body>
- <script>
- window.addEventListener("WebChannelMessageToContent", function(e) {
- if (e.detail.message && e.detail.message.type === "RECEIVE_PREFS") {
- let reply = new window.CustomEvent("WebChannelMessageToChrome", {
- detail: JSON.stringify({
- id: "newtab",
- message: JSON.stringify({type: "responseAck"}),
- })
- });
- window.dispatchEvent(reply);
- }
- }, true);
-
- document.onreadystatechange = function() {
- let msg = new window.CustomEvent("WebChannelMessageToChrome", {
- detail: JSON.stringify({
- id: "newtab",
- message: JSON.stringify({type: "REQUEST_PREFS"}),
- })
- });
- window.dispatchEvent(msg);
- };
-
- </script>
- </body>
-</html>
deleted file mode 100644
--- a/browser/components/newtab/tests/browser/newtabmessages_preview.html
+++ /dev/null
@@ -1,37 +0,0 @@
-<html>
- <head>
- <meta charset="utf8">
- <title>Newtab WebChannel test</title>
- </head>
- <body>
- <script>
- let thumbURL = "https://example.com/browser/browser/components/newtab/tests/browser/blue_page.html";
-
- window.addEventListener("WebChannelMessageToContent", function(e) {
- if (e.detail.message && e.detail.message.type === "RECEIVE_THUMB") {
- if (e.detail.message.data.imgData && e.detail.message.data.url === thumbURL) {
- let reply = new window.CustomEvent("WebChannelMessageToChrome", {
- detail: JSON.stringify({
- id: "newtab",
- message: JSON.stringify({type: "responseAck"}),
- })
- });
- window.dispatchEvent(reply);
- }
- }
- }, true);
-
- document.onreadystatechange = function() {
- if (document.readyState === "complete") {
- let msg = new window.CustomEvent("WebChannelMessageToChrome", {
- detail: JSON.stringify({
- id: "newtab",
- message: JSON.stringify({type: "REQUEST_THUMB", data: thumbURL}),
- })
- });
- window.dispatchEvent(msg);
- }
- };
- </script>
- </body>
-</html>
deleted file mode 100644
--- a/browser/components/newtab/tests/browser/newtabmessages_search.html
+++ /dev/null
@@ -1,113 +0,0 @@
-<html>
- <head>
- <meta charset="utf8">
- <title>Newtab WebChannel test</title>
- </head>
- <body>
- <script>
- let suggestionsData = {
- engineName: "Engine1",
- searchString: "test",
- };
- let removeFormHistoryData = "test";
- let performSearchData = {
- engineName: "Engine1",
- healthReportKey: "1",
- searchPurpose: "d",
- searchString: "test",
- };
- let cycleEngineData = "Engine2";
-
- window.addEventListener("WebChannelMessageToContent", function(e) {
- if (e.detail.message) {
- let reply;
- switch (e.detail.message.type) {
- case "RECEIVE_UISTRINGS":
- reply = new window.CustomEvent("WebChannelMessageToChrome", {
- detail: {
- id: "newtab",
- message: JSON.stringify({type: "UIStringsAck", data: e.detail.message.data}),
- }
- });
- window.dispatchEvent(reply);
- break;
- case "RECEIVE_SEARCH_SUGGESTIONS":
- reply = new window.CustomEvent("WebChannelMessageToChrome", {
- detail: {
- id: "newtab",
- message: JSON.stringify({type: "suggestionsAck", data: e.detail.message.data}),
- }
- });
- window.dispatchEvent(reply);
- break;
- case "RECEIVE_SEARCH_STATE":
- reply = new window.CustomEvent("WebChannelMessageToChrome", {
- detail: {
- id: "newtab",
- message: JSON.stringify({type: "stateAck", data: e.detail.message.data}),
- }
- });
- window.dispatchEvent(reply);
- break;
- case "RECEIVE_CURRENT_ENGINE":
- reply = new window.CustomEvent("WebChannelMessageToChrome", {
- detail: {
- id: "newtab",
- message: JSON.stringify({type: "currentEngineAck", data: e.detail.message.data}),
- }
- });
- window.dispatchEvent(reply);
- break;
- }
- }
- }, true);
-
- document.onreadystatechange = function() {
- if (document.readyState === "complete") {
- let msg = new window.CustomEvent("WebChannelMessageToChrome", {
- detail: {
- id: "newtab",
- message: JSON.stringify({type: "REQUEST_UISTRINGS"}),
- }
- });
- window.dispatchEvent(msg);
- msg = new window.CustomEvent("WebChannelMessageToChrome", {
- detail: {
- id: "newtab",
- message: JSON.stringify({type: "REQUEST_SEARCH_SUGGESTIONS", data: suggestionsData}),
- }
- });
- window.dispatchEvent(msg);
- msg = new window.CustomEvent("WebChannelMessageToChrome", {
- detail: {
- id: "newtab",
- message: JSON.stringify({type: "REQUEST_SEARCH_STATE"}),
- }
- });
- window.dispatchEvent(msg);
- msg = new window.CustomEvent("WebChannelMessageToChrome", {
- detail: {
- id: "newtab",
- message: JSON.stringify({type: "REQUEST_REMOVE_FORM_HISTORY", data: removeFormHistoryData}),
- }
- });
- window.dispatchEvent(msg);
- msg = new window.CustomEvent("WebChannelMessageToChrome", {
- detail: {
- id: "newtab",
- message: JSON.stringify({type: "REQUEST_PERFORM_SEARCH", data: performSearchData}),
- }
- });
- window.dispatchEvent(msg);
- msg = new window.CustomEvent("WebChannelMessageToChrome", {
- detail: {
- id: "newtab",
- message: JSON.stringify({type: "REQUEST_CYCLE_ENGINE", data: cycleEngineData}),
- }
- });
- window.dispatchEvent(msg);
- }
- }
- </script>
- </body>
-</html>
deleted file mode 100644
--- a/browser/components/newtab/tests/browser/newtabwebchannel_basic.html
+++ /dev/null
@@ -1,36 +0,0 @@
-<html>
- <head>
- <meta charset="utf8">
- <title>Newtab WebChannel test</title>
- </head>
- <body>
- <script>
- document.onreadystatechange = function() {
- let msg = new window.CustomEvent("WebChannelMessageToChrome", {
- detail: JSON.stringify({
- id: "newtab",
- message: JSON.stringify({type: "foo", data: "bar"}),
- })
- });
- window.dispatchEvent(msg);
- };
-
- window.addEventListener("WebChannelMessageToContent", function(e) {
- if (e.detail.message && e.detail.message.type.startsWith("respond")) {
- var detail = {
- id: "newtab",
- message: JSON.stringify({type: "reply", data: "quuz"}),
- };
- if (e.detail.message.type !== "respond_object") {
- detail = JSON.stringify(detail);
- }
- let reply = new window.CustomEvent("WebChannelMessageToChrome", {
- detail
- });
- window.dispatchEvent(reply);
- }
- }, true);
-
- </script>
- </body>
-</html>
--- a/browser/components/newtab/tests/xpcshell/test_AboutNewTabService.js
+++ b/browser/components/newtab/tests/xpcshell/test_AboutNewTabService.js
@@ -13,223 +13,129 @@ Cu.import("resource://gre/modules/Prefer
XPCOMUtils.defineLazyModuleGetter(this, "NewTabPrefsProvider",
"resource:///modules/NewTabPrefsProvider.jsm");
XPCOMUtils.defineLazyServiceGetter(this, "aboutNewTabService",
"@mozilla.org/browser/aboutnewtab-service;1",
"nsIAboutNewTabService");
-XPCOMUtils.defineLazyModuleGetter(this, "Locale",
- "resource://gre/modules/Locale.jsm");
-
-const DEFAULT_HREF = aboutNewTabService.generateRemoteURL();
+const DEFAULT_HREF = aboutNewTabService.activityStreamURL;
const DEFAULT_CHROME_URL = "chrome://browser/content/newtab/newTab.xhtml";
const DOWNLOADS_URL = "chrome://browser/content/downloads/contentAreaDownloadsView.xul";
-const DEFAULT_VERSION = aboutNewTabService.remoteVersion;
function cleanup() {
- Services.prefs.setBoolPref("browser.newtabpage.remote", false);
- Services.prefs.setCharPref("browser.newtabpage.remote.version", DEFAULT_VERSION);
+ Services.prefs.setBoolPref("browser.newtabpage.activity-stream.enabled", false);
aboutNewTabService.resetNewTabURL();
NewTabPrefsProvider.prefs.uninit();
}
do_register_cleanup(cleanup);
/**
* Test the overriding of the default URL
*/
-add_task(function* test_override_remote_disabled() {
+add_task(function* test_override_activity_stream_disabled() {
NewTabPrefsProvider.prefs.init();
let notificationPromise;
- Services.prefs.setBoolPref("browser.newtabpage.remote", false);
+ Services.prefs.setBoolPref("browser.newtabpage.activity-stream.enabled", 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/";
notificationPromise = nextChangeNotificationPromise(url);
aboutNewTabService.newTabURL = url;
yield notificationPromise;
Assert.ok(aboutNewTabService.overridden, "Newtab URL should be overridden");
- Assert.ok(!aboutNewTabService.remoteEnabled, "Newtab remote should not be enabled");
+ Assert.ok(!aboutNewTabService.activityStreamEnabled, "Newtab activity stream should not be enabled");
Assert.equal(aboutNewTabService.newTabURL, url, "Newtab URL should be the custom URL");
- // test reset with remote disabled
+ // test reset with activity stream disabled
notificationPromise = nextChangeNotificationPromise("about:newtab");
aboutNewTabService.resetNewTabURL();
yield notificationPromise;
Assert.ok(!aboutNewTabService.overridden, "Newtab URL should not be overridden");
Assert.equal(aboutNewTabService.newTabURL, "about:newtab", "Newtab URL should be the default");
// test override to a chrome URL
notificationPromise = nextChangeNotificationPromise(DOWNLOADS_URL);
aboutNewTabService.newTabURL = DOWNLOADS_URL;
yield notificationPromise;
Assert.ok(aboutNewTabService.overridden, "Newtab URL should be overridden");
Assert.equal(aboutNewTabService.newTabURL, DOWNLOADS_URL, "Newtab URL should be the custom URL");
cleanup();
});
-add_task(function* test_override_remote_enabled() {
+add_task(function* test_override_activity_stream_enabled() {
NewTabPrefsProvider.prefs.init();
let notificationPromise;
- // change newtab page to remote
+ // change newtab page to activity stream
notificationPromise = nextChangeNotificationPromise("about:newtab");
- Services.prefs.setBoolPref("browser.newtabpage.remote", true);
+ Services.prefs.setBoolPref("browser.newtabpage.activity-stream.enabled", true);
yield notificationPromise;
- let remoteHref = aboutNewTabService.generateRemoteURL();
- Assert.equal(aboutNewTabService.defaultURL, remoteHref, "Newtab URL should be the default remote URL");
+ let activityStreamURL = aboutNewTabService.activityStreamURL;
+ Assert.equal(aboutNewTabService.defaultURL, activityStreamURL, "Newtab URL should be the default activity stream URL");
Assert.ok(!aboutNewTabService.overridden, "Newtab URL should not be overridden");
- Assert.ok(aboutNewTabService.remoteEnabled, "Newtab remote should be enabled");
+ Assert.ok(aboutNewTabService.activityStreamEnabled, "Activity Stream should be enabled");
- // change to local newtab page while remote is enabled
+ // change to local newtab page while activity stream is enabled
notificationPromise = nextChangeNotificationPromise(DEFAULT_CHROME_URL);
aboutNewTabService.newTabURL = DEFAULT_CHROME_URL;
yield notificationPromise;
Assert.equal(aboutNewTabService.newTabURL, DEFAULT_CHROME_URL,
"Newtab URL set to chrome url");
Assert.equal(aboutNewTabService.defaultURL, DEFAULT_CHROME_URL,
"Newtab URL defaultURL set to the default chrome URL");
Assert.ok(aboutNewTabService.overridden, "Newtab URL should be overridden");
- Assert.ok(!aboutNewTabService.remoteEnabled, "Newtab remote should not be enabled");
+ Assert.ok(!aboutNewTabService.activityStreamEnabled, "Activity Stream should not be enabled");
cleanup();
});
/**
* Tests reponse to updates to prefs
*/
add_task(function* test_updates() {
/*
* Simulates a "cold-boot" situation, with some pref already set before testing a series
* of changes.
*/
- Preferences.set("browser.newtabpage.remote", true);
+ Preferences.set("browser.newtabpage.activity-stream.enabled", true);
aboutNewTabService.resetNewTabURL(); // need to set manually because pref notifs are off
let notificationPromise;
- let productionModeBaseUrl = "https://content.cdn.mozilla.net";
- let testModeBaseUrl = "https://example.com";
- let expectedPath = `/newtab` +
- `/v${aboutNewTabService.remoteVersion}` +
- `/${aboutNewTabService.remoteReleaseName}` +
- "/en-GB" +
- "/index.html";
- let expectedHref = productionModeBaseUrl + expectedPath;
- Preferences.set("intl.locale.matchOS", true);
- Preferences.set("general.useragent.locale", "en-GB");
- Preferences.set("browser.newtabpage.remote.mode", "production");
NewTabPrefsProvider.prefs.init();
- // test update checks for prefs
- notificationPromise = nextChangeNotificationPromise(
- expectedHref, "Remote href should be updated");
- Preferences.set("intl.locale.matchOS", false);
- yield notificationPromise;
-
- notificationPromise = nextChangeNotificationPromise(
- DEFAULT_HREF, "Remote href changes back to default");
- Preferences.set("general.useragent.locale", "en-US");
- yield notificationPromise;
-
- // test update fires when mode is changed
- expectedPath = expectedPath.replace("/en-GB/", "/en-US/");
- notificationPromise = nextChangeNotificationPromise(
- testModeBaseUrl + expectedPath, "Remote href changes back to origin of test mode");
- Preferences.set("browser.newtabpage.remote.mode", "test");
- yield notificationPromise;
-
- // test invalid mode ends up pointing to production url
- notificationPromise = nextChangeNotificationPromise(
- DEFAULT_HREF, "Remote href changes back to production default");
- Preferences.set("browser.newtabpage.remote.mode", "invalid");
- yield notificationPromise;
-
// test update fires on override and reset
let testURL = "https://example.com/";
notificationPromise = nextChangeNotificationPromise(
testURL, "a notification occurs on override");
aboutNewTabService.newTabURL = testURL;
yield notificationPromise;
// from overridden to default
notificationPromise = nextChangeNotificationPromise(
"about:newtab", "a notification occurs on reset");
aboutNewTabService.resetNewTabURL();
- Assert.ok(aboutNewTabService.remoteEnabled, "Newtab remote should be enabled");
- Assert.equal(aboutNewTabService.defaultURL, DEFAULT_HREF, "Default URL should be the remote page");
+ Assert.ok(aboutNewTabService.activityStreamEnabled, "Activity Stream should be enabled");
+ Assert.equal(aboutNewTabService.defaultURL, DEFAULT_HREF, "Default URL should be the activity stream page");
yield notificationPromise;
- // override to default URL from default URL
- notificationPromise = nextChangeNotificationPromise(
- testURL, "a notification only occurs for a change in overridden urls");
- aboutNewTabService.newTabURL = aboutNewTabService.generateRemoteURL();
- Assert.ok(aboutNewTabService.remoteEnabled, "Newtab remote should be enabled");
- aboutNewTabService.newTabURL = testURL;
- yield notificationPromise;
- Assert.ok(!aboutNewTabService.remoteEnabled, "Newtab remote should not be enabled");
-
// reset twice, only one notification for default URL
notificationPromise = nextChangeNotificationPromise(
"about:newtab", "reset occurs");
aboutNewTabService.resetNewTabURL();
yield notificationPromise;
cleanup();
});
-/**
- * Verifies that releaseFromUpdateChannel
- * Returns the correct release names
- */
-add_task(function* test_release_names() {
- let valid_channels = ["esr", "release", "beta", "aurora", "nightly"];
- let invalid_channels = new Set(["default", "invalid"]);
-
- for (let channel of valid_channels) {
- Assert.equal(channel, aboutNewTabService.releaseFromUpdateChannel(channel),
- "release == channel name when valid");
- }
-
- for (let channel of invalid_channels) {
- Assert.equal("nightly", aboutNewTabService.releaseFromUpdateChannel(channel),
- "release == nightly when invalid");
- }
-});
-
-/**
- * Verifies that remote version updates changes the remote newtab url
- */
-add_task(function* test_version_update() {
- NewTabPrefsProvider.prefs.init();
-
- Services.prefs.setBoolPref("browser.newtabpage.remote", true);
- Assert.ok(aboutNewTabService.remoteEnabled, "remote mode enabled");
-
- let productionModeBaseUrl = "https://content.cdn.mozilla.net";
- let version_incr = String(parseInt(DEFAULT_VERSION) + 1);
- let expectedPath = `/newtab` +
- `/v${version_incr}` +
- `/${aboutNewTabService.remoteReleaseName}` +
- `/${Locale.getLocale()}` +
- `/index.html`;
- let expectedHref = productionModeBaseUrl + expectedPath;
-
- let notificationPromise;
- notificationPromise = nextChangeNotificationPromise(expectedHref);
- Preferences.set("browser.newtabpage.remote.version", version_incr);
- yield notificationPromise;
-
- cleanup();
-});
-
function nextChangeNotificationPromise(aNewURL, testMessage) {
return new Promise(resolve => {
Services.obs.addObserver(function observer(aSubject, aTopic, aData) { // jshint unused:false
Services.obs.removeObserver(observer, aTopic);
Assert.equal(aData, aNewURL, testMessage);
resolve();
}, "newtab-url-changed", false);
});
--- a/browser/components/newtab/tests/xpcshell/test_NewTabURL.js
+++ b/browser/components/newtab/tests/xpcshell/test_NewTabURL.js
@@ -12,35 +12,35 @@ Cu.import("resource://gre/modules/Servic
XPCOMUtils.defineLazyModuleGetter(this, "NewTabPrefsProvider",
"resource:///modules/NewTabPrefsProvider.jsm");
XPCOMUtils.defineLazyServiceGetter(this, "aboutNewTabService",
"@mozilla.org/browser/aboutnewtab-service;1",
"nsIAboutNewTabService");
add_task(function*() {
let defaultURL = aboutNewTabService.newTabURL;
- Services.prefs.setBoolPref("browser.newtabpage.remote", false);
+ Services.prefs.setBoolPref("browser.newtabpage.activity-stream.enabled", false);
Assert.equal(NewTabURL.get(), defaultURL, `Default newtab URL should be ${defaultURL}`);
let url = "http://example.com/";
let notificationPromise = promiseNewtabURLNotification(url);
NewTabURL.override(url);
yield notificationPromise;
Assert.ok(NewTabURL.overridden, "Newtab URL should be overridden");
Assert.equal(NewTabURL.get(), url, "Newtab URL should be the custom URL");
notificationPromise = promiseNewtabURLNotification(defaultURL);
NewTabURL.reset();
yield notificationPromise;
Assert.ok(!NewTabURL.overridden, "Newtab URL should not be overridden");
Assert.equal(NewTabURL.get(), defaultURL, "Newtab URL should be the default");
- // change newtab page to remote
+ // change newtab page to activity stream
NewTabPrefsProvider.prefs.init();
- Services.prefs.setBoolPref("browser.newtabpage.remote", true);
+ Services.prefs.setBoolPref("browser.newtabpage.activity-stream.enabled", true);
Assert.equal(NewTabURL.get(), "about:newtab", `Newtab URL should be about:newtab`);
Assert.ok(!NewTabURL.overridden, "Newtab URL should not be overridden");
NewTabPrefsProvider.prefs.uninit();
});
function promiseNewtabURLNotification(aNewURL) {
return new Promise(resolve => {
Services.obs.addObserver(function observer(aSubject, aTopic, aData) { // jshint ignore:line
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -7701,27 +7701,16 @@ nsDocShell::EndPageLoad(nsIWebProgress*
//
if (url && NS_FAILED(aStatus)) {
if (aStatus == NS_ERROR_FILE_NOT_FOUND ||
aStatus == NS_ERROR_FILE_ACCESS_DENIED ||
aStatus == NS_ERROR_CORRUPTED_CONTENT ||
aStatus == NS_ERROR_INVALID_CONTENT_ENCODING) {
DisplayLoadError(aStatus, url, nullptr, aChannel);
return NS_OK;
- } else if (aStatus == NS_ERROR_INVALID_SIGNATURE) {
- // NS_ERROR_INVALID_SIGNATURE indicates a content-signature error.
- // This currently only happens in case a remote about page fails.
- // We have to load a fallback in this case.
- // XXX: We always load about blank here, firefox has to overwrite this if
- // it wants to display something else.
- return LoadURI(u"about:blank", // URI string
- nsIChannel::LOAD_NORMAL, // Load flags
- nullptr, // Referring URI
- nullptr, // Post data stream
- nullptr); // Headers stream
}
// Handle iframe document not loading error because source was
// a tracking URL. We make a note of this iframe node by including
// it in a dedicated array of blocked tracking nodes under its parent
// document. (document of parent window of blocked document)
if (isTopFrame == false && aStatus == NS_ERROR_TRACKING_URI) {
// frameElement is our nsIContent to be annotated
@@ -9745,37 +9734,16 @@ nsDocShell::CreatePrincipalFromReferrer(
attrs.Inherit(mOriginAttributes);
nsCOMPtr<nsIPrincipal> prin =
BasePrincipal::CreateCodebasePrincipal(aReferrer, attrs);
prin.forget(aResult);
return *aResult ? NS_OK : NS_ERROR_FAILURE;
}
-bool
-nsDocShell::IsAboutNewtab(nsIURI* aURI)
-{
- if (!aURI) {
- return false;
- }
- bool isAbout;
- if (NS_WARN_IF(NS_FAILED(aURI->SchemeIs("about", &isAbout)))) {
- return false;
- }
- if (!isAbout) {
- return false;
- }
-
- nsAutoCString module;
- if (NS_WARN_IF(NS_FAILED(NS_GetAboutModuleName(aURI, module)))) {
- return false;
- }
- return module.Equals("newtab");
-}
-
NS_IMETHODIMP
nsDocShell::InternalLoad(nsIURI* aURI,
nsIURI* aOriginalURI,
bool aLoadReplace,
nsIURI* aReferrer,
uint32_t aReferrerPolicy,
nsIPrincipal* aTriggeringPrincipal,
nsIPrincipal* aPrincipalToInherit,
@@ -10594,26 +10562,18 @@ nsDocShell::InternalLoad(nsIURI* aURI,
if (mTiming && timeBeforeUnload) {
mTiming->NotifyUnloadAccepted(mCurrentURI);
}
// Check if the webbrowser chrome wants the load to proceed; this can be
// used to cancel attempts to load URIs in the wrong process.
nsCOMPtr<nsIWebBrowserChrome3> browserChrome3 = do_GetInterface(mTreeOwner);
if (browserChrome3) {
- // In case this is a remote newtab load, set aURI to aOriginalURI (newtab).
- // This ensures that the verifySignedContent flag is set on loadInfo in
- // DoURILoad.
- nsIURI* uriForShouldLoadCheck = aURI;
- if (IsAboutNewtab(aOriginalURI)) {
- uriForShouldLoadCheck = aOriginalURI;
- }
bool shouldLoad;
- rv = browserChrome3->ShouldLoadURI(this, uriForShouldLoadCheck, aReferrer,
- aTriggeringPrincipal, &shouldLoad);
+ rv = browserChrome3->ShouldLoadURI(this, aURI, aReferrer, aTriggeringPrincipal, &shouldLoad);
if (NS_SUCCEEDED(rv) && !shouldLoad) {
return NS_OK;
}
}
if (browserChrome3 && aCheckForPrerender) {
nsCOMPtr<nsIRunnable> ev =
new InternalLoadEvent(this, aURI, aOriginalURI, aLoadReplace,
@@ -11270,25 +11230,16 @@ nsDocShell::DoURILoad(nsIURI* aURI,
if (aHeadersData) {
rv = AddHeadersToChannel(aHeadersData, httpChannel);
}
// Set the referrer explicitly
if (aReferrerURI && aSendReferrer) {
// Referrer is currenly only set for link clicks here.
httpChannel->SetReferrerWithPolicy(aReferrerURI, aReferrerPolicy);
}
- // set Content-Signature enforcing bit if aOriginalURI == about:newtab
- if (aOriginalURI && httpChannel) {
- if (IsAboutNewtab(aOriginalURI)) {
- nsCOMPtr<nsILoadInfo> loadInfo = httpChannel->GetLoadInfo();
- if (loadInfo) {
- loadInfo->SetVerifySignedContent(true);
- }
- }
- }
}
nsCOMPtr<nsIScriptChannel> scriptChannel = do_QueryInterface(channel);
if (scriptChannel) {
// Allow execution against our context if the principals match
scriptChannel->SetExecutionPolicy(nsIScriptChannel::EXECUTE_NORMAL);
}
--- a/docshell/base/nsDocShell.h
+++ b/docshell/base/nsDocShell.h
@@ -733,19 +733,16 @@ protected:
nsIChannel* GetCurrentDocChannel();
bool ShouldBlockLoadingForBackButton();
// Convenience method for getting our parent docshell. Can return null
already_AddRefed<nsDocShell> GetParentDocshell();
- // Check if aURI is about:newtab.
- bool IsAboutNewtab(nsIURI* aURI);
-
protected:
nsresult GetCurScrollPos(int32_t aScrollOrientation, int32_t* aCurPos);
nsresult SetCurScrollPosEx(int32_t aCurHorizontalPos,
int32_t aCurVerticalPos);
// Override the parent setter from nsDocLoader
virtual nsresult SetDocLoaderParent(nsDocLoader* aLoader) override;
--- a/dom/security/test/moz.build
+++ b/dom/security/test/moz.build
@@ -23,12 +23,11 @@ MOCHITEST_MANIFESTS += [
'sri/mochitest.ini',
]
MOCHITEST_CHROME_MANIFESTS += [
'general/chrome.ini',
]
BROWSER_CHROME_MANIFESTS += [
- 'contentverifier/browser.ini',
'csp/browser.ini',
'hsts/browser.ini',
]
--- a/netwerk/protocol/http/nsHttpChannel.cpp
+++ b/netwerk/protocol/http/nsHttpChannel.cpp
@@ -1741,21 +1741,16 @@ nsHttpChannel::ProcessContentSignatureHe
{
nsresult rv = NS_OK;
// we only do this if we require it in loadInfo
if (!mLoadInfo || !mLoadInfo->GetVerifySignedContent()) {
return NS_OK;
}
- // check if we verify content signatures on this newtab channel
- if (gHttpHandler->NewTabContentSignaturesDisabled()) {
- return NS_OK;
- }
-
NS_ENSURE_TRUE(aResponseHead, NS_ERROR_ABORT);
nsAutoCString contentSignatureHeader;
nsHttpAtom atom = nsHttp::ResolveAtom("Content-Signature");
rv = aResponseHead->GetHeader(atom, contentSignatureHeader);
if (NS_FAILED(rv)) {
LOG(("Content-Signature header is missing but expected."));
DoInvalidateCacheEntry(mURI);
return NS_ERROR_INVALID_SIGNATURE;
--- a/netwerk/protocol/http/nsHttpHandler.cpp
+++ b/netwerk/protocol/http/nsHttpHandler.cpp
@@ -94,17 +94,16 @@
#define INTL_ACCEPT_LANGUAGES "intl.accept_languages"
#define BROWSER_PREF_PREFIX "browser.cache."
#define DONOTTRACK_HEADER_ENABLED "privacy.donottrackheader.enabled"
#define H2MANDATORY_SUITE "security.ssl3.ecdhe_rsa_aes_128_gcm_sha256"
#define TELEMETRY_ENABLED "toolkit.telemetry.enabled"
#define ALLOW_EXPERIMENTS "network.allow-experiments"
#define SAFE_HINT_HEADER_VALUE "safeHint.enabled"
#define SECURITY_PREFIX "security."
-#define NEW_TAB_REMOTE_MODE "browser.newtabpage.remote.mode"
#define UA_PREF(_pref) UA_PREF_PREFIX _pref
#define HTTP_PREF(_pref) HTTP_PREF_PREFIX _pref
#define BROWSER_PREF(_pref) BROWSER_PREF_PREFIX _pref
#define NS_HTTP_PROTOCOL_FLAGS (URI_STD | ALLOWS_PROXY | ALLOWS_PROXY_HTTP | URI_LOADABLE_BY_ANYONE)
//-----------------------------------------------------------------------------
@@ -310,17 +309,16 @@ nsHttpHandler::Init()
prefBranch->AddObserver(BROWSER_PREF("disk_cache_ssl"), this, true);
prefBranch->AddObserver(DONOTTRACK_HEADER_ENABLED, this, true);
prefBranch->AddObserver(TELEMETRY_ENABLED, this, true);
prefBranch->AddObserver(H2MANDATORY_SUITE, this, true);
prefBranch->AddObserver(HTTP_PREF("tcp_keepalive.short_lived_connections"), this, true);
prefBranch->AddObserver(HTTP_PREF("tcp_keepalive.long_lived_connections"), this, true);
prefBranch->AddObserver(SAFE_HINT_HEADER_VALUE, this, true);
prefBranch->AddObserver(SECURITY_PREFIX, this, true);
- prefBranch->AddObserver(NEW_TAB_REMOTE_MODE, this, true);
PrefsChanged(prefBranch, nullptr);
}
nsHttpChannelAuthProvider::InitializePrefs();
mMisc.AssignLiteral("rv:" MOZILLA_UAVERSION);
mCompatFirefox.AssignLiteral("Firefox/" MOZILLA_UAVERSION);
@@ -1694,29 +1692,16 @@ nsHttpHandler::PrefsChanged(nsIPrefBranc
if (NS_SUCCEEDED(rv) && cVar) {
mEnforceH1Framing = FRAMECHECK_BARELY;
} else {
mEnforceH1Framing = FRAMECHECK_LAX;
}
}
}
- // remote content-signature testing option
- if (PREF_CHANGED(NEW_TAB_REMOTE_MODE)) {
- nsAutoCString channel;
- prefs->GetCharPref(NEW_TAB_REMOTE_MODE, getter_Copies(channel));
- if (channel.EqualsLiteral("test") ||
- channel.EqualsLiteral("test2") ||
- channel.EqualsLiteral("dev")) {
- mNewTabContentSignaturesDisabled = true;
- } else {
- mNewTabContentSignaturesDisabled = false;
- }
- }
-
if (PREF_CHANGED(HTTP_PREF("keep_empty_response_headers_as_empty_string"))) {
rv = prefs->GetBoolPref(HTTP_PREF("keep_empty_response_headers_as_empty_string"),
&cVar);
if (NS_SUCCEEDED(rv)) {
mKeepEmptyResponseHeadersAsEmtpyString = cVar;
}
}
--- a/netwerk/protocol/http/nsHttpHandler.h
+++ b/netwerk/protocol/http/nsHttpHandler.h
@@ -340,23 +340,16 @@ public:
return mPipelineRescheduleTimeout;
}
PRIntervalTime GetPipelineTimeout() { return mPipelineReadTimeout; }
SpdyInformation *SpdyInfo() { return &mSpdyInfo; }
bool IsH2MandatorySuiteEnabled() { return mH2MandatorySuiteEnabled; }
- // Returns true if content-signature test pref is set such that they are
- // NOT enforced on remote newtabs.
- bool NewTabContentSignaturesDisabled()
- {
- return mNewTabContentSignaturesDisabled;
- }
-
// returns true in between Init and Shutdown states
bool Active() { return mHandlerActive; }
// When the disk cache is responding slowly its use is suppressed
// for 1 minute for most requests. Callable from main thread only.
TimeStamp GetCacheSkippedUntil() { return mCacheSkippedUntil; }
void SetCacheSkippedUntil(TimeStamp arg) { mCacheSkippedUntil = arg; }
void ClearCacheSkippedUntil() { mCacheSkippedUntil = TimeStamp(); }
@@ -584,19 +577,16 @@ private:
int32_t mTCPKeepaliveLongLivedIdleTimeS;
// if true, generate NS_ERROR_PARTIAL_TRANSFER for h1 responses with
// incorrect content lengths or malformed chunked encodings
FrameCheckLevel mEnforceH1Framing;
nsCOMPtr<nsIRequestContextService> mRequestContextService;
- // True if remote newtab content-signature disabled because of the channel.
- bool mNewTabContentSignaturesDisabled;
-
// If it is set to false, headers with empty value will not appear in the
// header array - behavior as it used to be. If it is true: empty headers
// coming from the network will exits in header array as empty string.
// Call SetHeader with an empty value will still delete the header.
// (Bug 6699259)
bool mKeepEmptyResponseHeadersAsEmtpyString;
// The default size (in bytes) of the HPACK decompressor table.