зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1340181 - Hide Activity Stream URL in URLbar r=fkiefer,mconley
MozReview-Commit-ID: F0P5tn2wyG --HG-- extra : rebase_source : a9f766913b8340e12a4f526dc741e8ed752e6acf
This commit is contained in:
Родитель
d4db7e6f3a
Коммит
6b1858e254
|
@ -1190,20 +1190,8 @@ pref("browser.newtabpage.directory.source", "https://tiles.services.mozilla.com/
|
|||
// 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);
|
||||
|
|
|
@ -2540,11 +2540,8 @@ function URLBarSetURI(aURI) {
|
|||
} 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 {
|
||||
|
|
|
@ -149,16 +149,6 @@ AboutRedirector::NewChannel(nsIURI* aURI,
|
|||
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()) {
|
||||
|
|
|
@ -17,17 +17,13 @@ XPCOMUtils.defineLazyGetter(this, "EventEmitter", function() {
|
|||
|
||||
// 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"],
|
||||
]);
|
||||
|
||||
|
|
|
@ -4,9 +4,7 @@
|
|||
* 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;
|
||||
|
@ -14,53 +12,27 @@ 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.
|
||||
*
|
||||
|
@ -77,7 +49,8 @@ function AboutNewTabService() {
|
|||
*
|
||||
* 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.
|
||||
*
|
||||
|
@ -93,8 +66,7 @@ function AboutNewTabService() {
|
|||
AboutNewTabService.prototype = {
|
||||
|
||||
_newTabURL: ABOUT_URL,
|
||||
_remoteEnabled: false,
|
||||
_remoteURL: null,
|
||||
_activityStreamEnabled: false,
|
||||
_overridden: false,
|
||||
|
||||
classID: Components.ID("{dfcd2adc-7867-4d3a-ba70-17501f208142}"),
|
||||
|
@ -104,140 +76,60 @@ AboutNewTabService.prototype = {
|
|||
}],
|
||||
|
||||
_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;
|
||||
}
|
||||
if (!csTest) {
|
||||
this._newTabURL = ABOUT_URL;
|
||||
this._activityStreamEnabled = false;
|
||||
}
|
||||
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
|
||||
|
@ -246,25 +138,8 @@ AboutNewTabService.prototype = {
|
|||
} 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);
|
||||
|
@ -274,14 +149,18 @@ AboutNewTabService.prototype = {
|
|||
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);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -19,7 +19,7 @@ interface nsIAboutNewTabService : nsISupports
|
|||
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;
|
||||
|
||||
|
@ -29,31 +29,15 @@ interface nsIAboutNewTabService : nsISupports
|
|||
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;
|
||||
|
||||
readonly attribute bool activityStreamEnabled;
|
||||
|
||||
/**
|
||||
* Returns the version of the remote newtab page expected
|
||||
*/
|
||||
readonly attribute ACString remoteVersion;
|
||||
|
||||
/**
|
||||
* Returns the expected channel for the remote the newtab page
|
||||
* Returns the activity stream resource URL for the newtab page
|
||||
*/
|
||||
readonly attribute ACString remoteReleaseName;
|
||||
|
||||
/**
|
||||
* Generates and returns the remote newtab page url
|
||||
*/
|
||||
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
|
||||
|
|
|
@ -2,15 +2,7 @@
|
|||
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]
|
||||
|
|
|
@ -23,7 +23,7 @@ XPCOMUtils.defineLazyServiceGetter(this, "aboutNewTabService",
|
|||
"nsIAboutNewTabService");
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
Services.prefs.setBoolPref("browser.newtabpage.remote", false);
|
||||
Services.prefs.setBoolPref("browser.newtabpage.activity-stream.enabled", false);
|
||||
aboutNewTabService.resetNewTabURL();
|
||||
});
|
||||
|
||||
|
|
|
@ -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();
|
||||
});
|
|
@ -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();
|
||||
});
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -18,17 +18,12 @@ 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();
|
||||
}
|
||||
|
@ -38,10 +33,10 @@ 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,
|
||||
|
@ -53,10 +48,10 @@ add_task(function* test_override_remote_disabled() {
|
|||
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;
|
||||
|
@ -73,19 +68,19 @@ add_task(function* test_override_remote_disabled() {
|
|||
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;
|
||||
|
@ -94,7 +89,7 @@ add_task(function* test_override_remote_enabled() {
|
|||
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();
|
||||
});
|
||||
|
@ -107,46 +102,11 @@ 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(
|
||||
|
@ -158,19 +118,10 @@ add_task(function* test_updates() {
|
|||
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");
|
||||
|
@ -180,51 +131,6 @@ add_task(function* test_updates() {
|
|||
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
|
||||
|
|
|
@ -17,7 +17,7 @@ XPCOMUtils.defineLazyServiceGetter(this, "aboutNewTabService",
|
|||
|
||||
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/";
|
||||
|
@ -33,9 +33,9 @@ add_task(function*() {
|
|||
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();
|
||||
|
|
|
@ -7706,17 +7706,6 @@ nsDocShell::EndPageLoad(nsIWebProgress* aProgress,
|
|||
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
|
||||
|
@ -9750,27 +9739,6 @@ nsDocShell::CreatePrincipalFromReferrer(nsIURI* aReferrer,
|
|||
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,
|
||||
|
@ -10606,16 +10574,8 @@ nsDocShell::InternalLoad(nsIURI* aURI,
|
|||
// 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;
|
||||
}
|
||||
|
@ -11282,15 +11242,6 @@ nsDocShell::DoURILoad(nsIURI* aURI,
|
|||
// 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);
|
||||
|
|
|
@ -738,9 +738,6 @@ protected:
|
|||
// 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,
|
||||
|
|
|
@ -28,7 +28,6 @@ MOCHITEST_CHROME_MANIFESTS += [
|
|||
]
|
||||
|
||||
BROWSER_CHROME_MANIFESTS += [
|
||||
'contentverifier/browser.ini',
|
||||
'csp/browser.ini',
|
||||
'hsts/browser.ini',
|
||||
]
|
||||
|
|
|
@ -1705,11 +1705,6 @@ nsHttpChannel::ProcessContentSignatureHeader(nsHttpResponseHead *aResponseHead)
|
|||
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");
|
||||
|
|
|
@ -98,7 +98,6 @@
|
|||
#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
|
||||
|
@ -299,7 +298,6 @@ nsHttpHandler::Init()
|
|||
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);
|
||||
}
|
||||
|
||||
|
@ -1562,19 +1560,6 @@ nsHttpHandler::PrefsChanged(nsIPrefBranch *prefs, const char *pref)
|
|||
}
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
|
|
@ -321,13 +321,6 @@ public:
|
|||
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; }
|
||||
|
||||
|
@ -553,9 +546,6 @@ private:
|
|||
|
||||
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.
|
||||
|
|
Загрузка…
Ссылка в новой задаче